1 15 16 package org.objectweb.jac.core.dist.corba; 17 18 import org.objectweb.jac.core.dist.RemoteContainer; 19 import org.objectweb.jac.core.dist.RemoteRef; 20 21 import org.omg.CORBA.ORB ; 22 import org.omg.CosNaming.NameComponent ; 23 import org.omg.CosNaming.NamingContext ; 24 import org.omg.CosNaming.NamingContextHelper ; 25 import org.omg.PortableServer.POA ; 26 import org.omg.PortableServer.POAHelper ; 27 28 29 36 37 public class CORBARemoteRef extends RemoteRef { 38 39 43 44 final static protected String cosNamingEntryType = "jac daemon"; 45 46 47 48 protected String remContString; 49 50 51 58 59 public void resolve( String contName ) { 60 61 org.omg.CORBA.Object obj = null; 62 63 64 65 try { 66 obj = 67 nc.resolve( 68 new NameComponent []{ 69 new NameComponent ( contName, cosNamingEntryType ) 70 } 71 ); 72 } 73 catch( Exception e ) { e.printStackTrace(); } 74 75 CORBARemoteContainerInterf stub = 76 CORBARemoteContainerInterfHelper.narrow(obj); 77 remContString = orb.object_to_string(obj); 78 remCont = new CORBARemoteContainerStub(stub); 79 80 remCont.setName ( contName ); 81 82 } 83 84 85 93 94 public void reresolve() { 95 96 org.omg.CORBA.Object obj = orb.string_to_object(remContString); 97 CORBARemoteContainerInterf stub = 98 CORBARemoteContainerInterfHelper.narrow(obj); 99 remCont = new CORBARemoteContainerStub(stub); 100 } 101 102 103 104 105 static protected ORB orb; 106 107 108 static protected POA poa; 109 110 111 static protected NamingContext nc; 112 113 114 static { 115 116 orb = ORB.init( new String []{}, null ); 117 118 try { 119 poa = POAHelper.narrow( orb.resolve_initial_references("RootPOA") ); 120 nc = 121 NamingContextHelper.narrow( 122 orb.resolve_initial_references("NameService") 123 ); 124 } 125 catch( Exception e ) { e.printStackTrace(); } 126 } 127 128 } 129 | Popular Tags |