正在加载图片...
的》4.7.3编写He1lo0orld服务器程序 mport org. omg CosNaming import org. omg CosNaming. Naming ContextPackage import org. omg CORBA. * 服务器是一种实例化一个或多个 servant 对象的进程。 servant实现 idl to java生 public class HelloServer 成的接口,并实际执行该接口上的操作 public static void main( String argsI 实例化8对象Ha:whr ORB orb= ORB. init(args, null; 0RB对象 获得初始命名上下文 orb. connect(hello Ref 将 servant对象连接到ORB org.omg CORBA Object objRef = orb. resolve_ initial references(" Name Service); 限定对象引用 Naming Context nc Ref== Naming ContextHelper narrow(objRef f) 在名字服务器中注册 Name Component nc= new Name Component("Hello",); servant对象 Name Component pathI=nc]; ncRef. rebind(path, hello Ref); java. lang. Objectsync= new java. lang Objecto 等待调用 synchronized(synck sync waitO 3 catch(Exception e)t System. err println("ERROR: +e); eprintstackTrace(System. out); 西安宦子技力学4.7.3 编写 Hello World 服务器程序 import HelloApp.*; importorg.omg.CosNaming.*; importorg.omg.CosNaming.NamingContextPackage.*; importorg.omg.CORBA.*; public class HelloServer { public static void main(Stringargs[]) { try{ ORB orb = ORB.init(args,null); HelloServant helloRef = new HelloServant(); orb.connect(helloRef); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef= NamingContextHelper.narrow(objRef); NameComponent nc = new NameComponent("Hello", ""); NameComponent path[]= {nc}; ncRef.rebind(path,helloRef); java.lang.Object sync = new java.lang.Object(); synchronized(sync){ sync.wait(); } } catch(Exceptione) { System.err.println("ERROR: " + e); e.printStackTrace(System.out); } } 创建 ORB 对象 将 servant 对象连接到 ORB 实例化 servant 对象 服务器是一种实例化一个或多个 servant 对象的进程。servant 实现 idltojava 生 成的接口,并实际执行该接口上的操作。 获得初始命名上下文 限定对象引用 在名字服务器中注册 servant 对象 等待调用
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有