| 1 24 25 package com.rift.coad.lib.naming.jacorb; 27 28 import java.util.Properties ; 30 import org.omg.CORBA.ORB ; 31 import org.omg.PortableServer.POA ; 32 import org.omg.PortableServer.POAHelper ; 33 import org.omg.CosNaming.NamingContext ; 34 import org.omg.CosNaming.NamingContextHelper ; 35 import org.omg.CosNaming.NameComponent ; 36 37 import org.jacorb.naming.EmbeddedNameServer; 39 40 import com.rift.coad.lib.configuration.Configuration; 42 import com.rift.coad.lib.configuration.ConfigurationFactory; 43 import com.rift.coad.lib.naming.OrbManager; 44 import com.rift.coad.lib.thread.CoadunationThreadGroup; 45 46 47 52 public class JacORBManager implements OrbManager { 53 54 57 public class OrbRunner extends Thread { 58 59 62 public OrbRunner() { 63 64 } 65 66 69 public void run() { 70 orb.run(); 71 } 72 } 73 74 private final static String HOST = "host"; 76 private final static String PORT = "port"; 77 private final static String DEFAULT_PORT = "2000"; 78 private final static String NAME_SERVER_STORE = "name_server_store"; 79 80 private ORB orb = null; 82 private POA poa = null; 83 private OrbRunner orbRunner = null; 84 private EmbeddedNameServer embeddedNameServer = null; 85 86 87 public JacORBManager(CoadunationThreadGroup threadGroup) throws 88 JacORBException { 89 try { 90 Properties properties = new Properties (); 92 Configuration config = ConfigurationFactory.getInstance(). 93 getConfig(this.getClass()); 94 properties.setProperty("org.omg.CORBA.ORBClass", 95 "org.jacorb.orb.ORB"); 96 System.setProperty("org.omg.CORBA.ORBClass", 97 "org.jacorb.orb.ORB"); 98 properties.setProperty("org.omg.CORBA.ORBSingletonClass", 99 "org.jacorb.orb.ORBSingleton"); 100 System.setProperty("org.omg.CORBA.ORBSingletonClass", 101 "org.jacorb.orb.ORBSingleton"); 102 properties.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass", 103 org.objectweb.carol.rmi.multi.JacORBPRODelegate. 104 class.getName()); 105 System.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass", 106 org.objectweb.carol.rmi.multi.JacORBPRODelegate. 107 class.getName()); 108 System.setProperty("javax.rmi.CORBA.UtilClass", 109 org.objectweb.carol.util.delegate.UtilDelegateImpl. 110 class.getName()); 111 properties.setProperty("OAPort",config.getString(PORT,DEFAULT_PORT)); 112 properties.setProperty("OAIAddr",config.getString(HOST)); 113 114 123 properties.put("jacorb.orb.objectKeyMap.NameService", 124 "StandardNS/NameServer-POA/_root"); 125 properties.put("jacorb.implname", "StandardNS"); 126 properties.put("jacorb.naming.db_dir", 127 config.getString(NAME_SERVER_STORE)); 128 orb = ORB.init(new String [0],properties); 130 131 poa = POAHelper.narrow( 133 orb.resolve_initial_references("RootPOA")); 134 135 embeddedNameServer = new EmbeddedNameServer(orb,poa); 137 138 poa.the_POAManager().activate(); 140 141 orbRunner = new OrbRunner(); 143 orbRunner.start(); 144 145 } catch (Exception ex) { 146 throw new JacORBException ("Failed to start the orb : " + 147 ex.getMessage(),ex); 148 } 149 } 150 151 152 157 public ORB getORB() { 158 return orb; 159 } 160 161 162 165 public POA getPOA() { 166 return poa; 167 } 168 169 170 173 public void terminate() { 174 orb.shutdown(true); 175 } 176 } 177 178 | Popular Tags |