//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 initial elloHome Home=(Hello Home)Init. lookup( HelloJ") Hello HelloObjHome createD String RetValHelloObj. say Hello(Ron Floyd) System. out. println( Returned: Retval 创建 InitialContext的对象 Helloobj remove 实例 catch (ava. rmi RemoteException exception) Initialcontext是客户程 System. out. printIn( Remote exception occurred: exception 序与ND服务之间的接口 catch gavax, ejb. CreateException exception Initialcontext类包含 到各种命名服务的绑定 System. out. printIn( Create exception occurred: exception 如]ND和 CORBA catch (avax ejb. Remove Exception exception) Inta| Context构造函数 System. out. printIn( Remove exception occurred: exception) 抛出 Naming Exception异 常表明对象创建失败 catch (avax naming. NamingException exception System. out. println( Naming exception occurred: + exception)
客户应用 ◼创建InitialContext的对象 实例 ◼InitialContext是客户程 序与JNDI服务之间的接口 ◼InitialContext类包含 到各种命名服务的绑定, 如JNDI和CORBA ◼InitialContext构造函数 抛出NamingException异 常表明对象创建失败
//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. lookuAHelloJ") 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 查找EB System. out. printIn( Create exception occurred: exception m根据EB的名字 catch (avax ejb. Remove Exception exception) Hellot查找E]B 使用 InitialContext的 System. out. printIn( Remove exception occurred: exception) lo0kup方法 catch (avax naming. NamingException exception 返回相应的对象 System. out. println( Naming exception occurred: + exception)
客户应用 ◼查找EJB ◼根据EJB的名字 “HelloJ”查找EJB ◼使用InitialContext的 lookup方法 ◼返回相应的对象