1 15 16 package org.objectweb.jac.core.dist.corba; 17 18 import org.objectweb.jac.core.dist.Distd; 19 20 import org.omg.CORBA.ORB ; 21 import org.omg.CosNaming.NameComponent ; 22 import org.omg.CosNaming.NamingContext ; 23 import org.omg.CosNaming.NamingContextHelper ; 24 import org.omg.PortableServer.POA ; 25 import org.omg.PortableServer.POAHelper ; 26 import org.omg.PortableServer.POAManager ; 27 28 29 38 39 public class CORBADistd extends Distd { 40 41 42 protected ORB orb; 43 44 45 protected POA poa; 46 47 48 POAManager manager; 49 50 51 protected NamingContext nc; 52 53 54 57 58 public void init() { 59 60 orb = ORB.init( new String []{}, null ); 61 62 try { 63 poa = POAHelper.narrow( orb.resolve_initial_references("RootPOA") ); 64 manager = poa.the_POAManager(); 65 nc = 66 NamingContextHelper.narrow( 67 orb.resolve_initial_references("NameService") 68 ); 69 } 70 catch( Exception e ) { e.printStackTrace(); } 71 } 72 73 74 79 80 public void newContainer( String name ) { 81 82 registerContainer( new CORBARemoteContainer(verbose), name ); 83 } 84 85 86 90 91 final static protected String cosNamingEntryType = "jac daemon"; 92 93 94 100 101 protected void registerContainer( CORBARemoteContainer container, String name ) { 102 103 try { 104 105 109 110 CORBARemoteContainerInterfPOATie containerTie = 111 new CORBARemoteContainerInterfPOATie(container); 112 113 114 115 116 nc.bind( 117 new NameComponent []{new NameComponent (name,cosNamingEntryType)}, 118 poa.servant_to_reference(containerTie) 119 ); 120 121 System.out.println( 122 "--- org.objectweb.jac.dist.corba.CORBADistd: new container " + name + " ---" 123 ); 124 125 } 126 catch( Exception e ) { e.printStackTrace(); } 127 } 128 129 130 136 137 public void newContainer( String name, String className ) { 138 139 registerContainer( new CORBARemoteContainer(className,verbose), name ); 140 } 141 142 143 147 148 public void run() { 149 150 System.out.println( "--- org.objectweb.jac.dist.corba.CORBADistd is running ---" ); 151 152 try { manager.activate(); } 153 catch( Exception e ) { e.printStackTrace(); } 154 155 orb.run(); 156 } 157 158 159 164 165 public CORBADistd( String [] args ) { super(args); } 166 167 public static void main( String [] args ) { new CORBADistd(args); } 168 169 } 170 | Popular Tags |