当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

复旦大学:《高级Web技术》3-应用web_4-EJB_教学课件PPT_EJB开发-6-创建客户程序

资源类别:文库,文档格式:PPT,文档页数:32,文件大小:404KB,团购合买
◼ 创建客户程序 ◼ 运行客户程序 ◼ 客户程序中的异常处理
点击下载完整版文档(PPT)

高级Meb技术 J阳a2 Enterprise Edtion

高级Web技术 Java 2 Enterprise Edtion

本次课程内容 ■创建客户程序 ■运行客户程序 客户程序中的异常处理

本次课程内容 ◼ 创建客户程序 ◼ 运行客户程序 ◼ 客户程序中的异常处理

创建客户程序

创建客户程序

客户端 Client Application Provi des a User Interface 客户端 所有针对EJB而言处于客户调用逻辑的组件与程序 客户应用一般为EJB应用提供用户界面 n客户应用中会调用 enterprise bean提供的方法

客户端 ◼ 客户端 ◼ 所有针对EJB而言处于客户调用逻辑的组件与程序 ◼ 客户应用一般为EJB应用提供用户界面 ◼ 客户应用中会调用enterprise bean提供的方法

J2EE客户端 5种J2EE客户端 Stand Alone client J2EE Application Client JSP JSP访问EJB,最好都通过 Java beans来实现,所以一般 在相应 Java bean的初始化方法中完成创建EJB的步骤 Servlets Servlets一般在它的int0方法中完成创建EJB实例的步骤 其它 Enterprise JavaBeans(处于客户逻辑的EJB)

J2EE客户端 ◼ 5种J2EE客户端 ◼ Stand Alone Client ◼ J2EE Application Client ◼ JSP ◼ JSP访问EJB,最好都通过Java Beans来实现,所以一般 在相应Java Bean的初始化方法中完成创建EJB的步骤 ◼ Servlets ◼ Servlets一般在它的init()方法中完成创建EJB实例的步骤。 ◼ 其它Enterprise JavaBeans(处于客户逻辑的EJB)

客户端访问EJB 访问EJB的步骤 n通过JND定位EJB的 Remote Home Interface 创建JND名称环境,通过在发布时你给EJB定义的JND名 称找到该EJB的 Remote home Interface 创建EJB的实例,得到 Remote Interface 调用上一步得到的 Remote home interface中的 create 方法, EJB Container会创建相应EJB的实例 ■调用 Remote Interface中的商业方法 客户端调用上一步创建的 Remote Interface中的商业方法, EJB Container就会调用相应 Bean class:实例中的相应方法

客户端访问EJB ◼ 访问EJB的步骤 ◼ 通过JNDI定位EJB的Remote Home Interface ◼ 创建JNDI名称环境,通过在发布时你给EJB定义的JNDI名 称找到该EJB的Remote Home Interface ◼ 创建EJB的实例,得到Remote Interface ◼ 调用上一步得到的Remote Home Interface中的create() 方法,EJB Container会创建相应EJB的实例 ◼ 调用Remote Interface中的商业方法 ◼ 客户端调用上一步创建的Remote Interface中的商业方法, EJB Container就会调用相应Bean Class实例中的相应方法

//The code is used to create the client application used by the HelloApp application Import java. rm import Javax. naming public class CLient ublic static void main(String args) InitialContext Init=new InitialContext 0: HelloHome Home=(HelloHome)Init lookup( HelloJ) Hello HelloObjHome createD String RetValHelloObj. say Hello(Ron Floyd) System. out. println( Returned: Retval HelloObj removeD catch (ava. rmi RemoteException exception) System. out. printIn( Remote exception occurred: exception 客户应用使用 catch gavax, ejb. CreateException exception enterprise bean的 System. out. printIn( Create exception occurred: exception home接口和 remote接 catch (avax ejb. Remove Exception exception) 口访问bean提供的服 System. out. printIn( Remove exception occurred: exception) 务 catch (avax naming. NamingException exception System. out. println( Naming exception occurred: + exception)

客户应用 ◼客户应用使用 enterprise bean的 home接口和remote接 口访问bean提供的服 务

//The code is used to create the client application used by the HelloApp application Import java rmi Import Javax. naming ublic class len ublic static void main(String args) InitialContext Init=new InitialContext 0: HelloHome Home=(HelloHome) Init lookup(HelloJ") Hello HelloObjHome createD String RetValHelloObj. say Hello(Ron Floyd) System. out. println( Returned: Retval Helloobj remove catch (ava. rmi RemoteException exception) System. out. printIn( Remote exception occurred: exception catch gavax, ejb. CreateException exception n导入 Java. rm和 System. out. printIn( Create exception occurred: exception Javax. naming包 catch (avax ejb. Remove Exception exception) Java. rm包包含RMI调 用的支持 System. out. printIn( Remove exception occurred: exception) JJavax naming包包含 catch (avax naming. NamingException exception JNDI支持 System. out. println( Naming exception occurred: + exception)

客户应用 ◼导入java.rmi和 javax.naming包 ◼java.rmi包包含RMI调 用的支持 ◼javax.naming包包含 JNDI支持

//The code is used to create the client application used by the HelloApp application Import java. rm public class Client ublic static void main(String args) InitialContext Init=new InitialContext 0: HelloHome Home=(HelloHome) Init lookup(HelloJ") Hello HelloObjHome createD String RetValHelloObj. say Hello(Ron Floyd) System. out. println( Returned: Retval Helloobj remove catch (ava. rmi RemoteException exception) System. out. printIn( Remote exception occurred: exception catch gavax, ejb. CreateException exception System. out. printIn( Create exception occurred: exception CLient是客户应用类 catch (avax ejb. Remove Exception exception) m仅包含一个man System. out. printIn( Remove exception occurred: exception) 方法 catch (avax naming. NamingException exception System. out. println( Naming exception occurred: + exception)

客户应用 ◼HClient是客户应用类 ◼仅包含一个main 方法

//The code is used to create the client application used by the HelloApp application Import java. rm import Javax. naming public class CLient ublic static void main(String args) InitialContext Init=new InitialContext 0: HelloHome Home=(HelloHome)Init lookup( HelloJ) Hello HelloObjHome createD String RetValHelloObj. say Hello(Ron Floyd) System. out. println( Returned: Retval Helloobj remove System. out. printIn( Remote exception occurred: exception catch gavax, ejb. CreateException exception System. out. printIn( Create exception occurred: exception atry模块 catch (avax ejb. Remove Exception exception) a实现了客户应用 System. out. printIn( Remove exception occurred: exception) 的功能 catch (avax naming. NamingException exception System. out. println( Naming exception occurred: + exception)

客户应用 ◼try模块 ◼实现了客户应用 的功能

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共32页,可试读12页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有