《高级Web技术》参考资料:3-应用web_4-EJB_EJB开发-6-创建客户程序

高级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模块 ◼实现了客户应用 的功能
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB开发-5-编写Entity Bean.ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB开发-4-创建Session EJB.ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB基础-3-主要接口设计原则.ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB基础-2-体系结构.ppt
- 《高级Web技术》参考资料:3-WS与工作流_4-Service web_BPELOverview.pdf
- 《高级Web技术》参考资料:2-Web上的数据标准-XML_XML基础—概述与语法.pdf
- 《高级Web技术》参考资料:2-soap&wsdl&uddi_4-Service web_WSDL.ppt
- 《高级Web技术》参考资料:2-soap&wsdl&uddi_4-Service web_UDDI.ppt
- 《高级Web技术》参考资料:2-soap&wsdl&uddi_4-Service web_Tomcat与SOAP&AXIS集成.ppt
- 《高级Web技术》参考资料:2-soap&wsdl&uddi_4-Service web_SOAP.ppt
- 《高级Web技术》参考资料:1-webapp outline_雅蛙网站的使用体验及对WEB2.0的认识.doc
- 《高级Web技术》参考资料:1-webapp outline_离线Web技术在医疗业务应用的设想与尝试.docx
- 《高级Web技术》参考资料:1-webapp outline_拥抱Web3.0.pdf
- 《高级Web技术》参考资料:1-webapp outline_what is web2.0.docx
- 《高级Web技术》参考资料:1-webapp outline_web app outline Web 技术概述.ppt
- 《高级Web技术》参考资料:1-webapp outline_web app outline Web 技术概述.pdf
- 《高级Web技术》参考资料:1-webapp outline_Planetary-Scale Views on a Large Instant-Messaging Network.pdf
- 《高级Web技术》参考资料:1-SOA和WS概述_4-Service web_Web Service概述及其应用.ppt
- 《高级Web技术》参考资料:1-SOA和WS概述_4-Service web_面向服务体系架构概述 SOA Introduction.ppt
- 厦门大学:《大数据技术原理与应用》课程教学资源(PPT课件讲稿)第八章 流计算(2016年春季学期授课版本).ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB开发-7-部署EJB应用.ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB高级-10-安全性控制..ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB高级-11-EJB3..ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB高级-8-资源管理与EJB环境.ppt
- 《高级Web技术》参考资料:3-应用web_4-EJB_EJB高级-9-事务处理.ppt
- 《高级Web技术》参考资料:应用web - EJB 3RD EDITION - Richard Monson-Haefel.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_Hibernate-课件.ppt
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_J2EE模式与框架struts(2).ppt
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_Spring Introduction.ppt
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_ajax.ppt
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_Ajax介绍.ppt
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_DWR_ch03.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_DWR_ch05.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_ajax first essay.doc
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_Ajax in action中文版.doc
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_AJAXBasics.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_AJAXBasics_speakernoted.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_GWT.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_GWT_speakernoted.pdf
- 《高级Web技术》参考资料:3-应用web_5-J2EE框架_阅读参考资料_ajax+J2EE_materials_How_to_Design_a_large_AJAX_Application.pdf