1 7 8 package com.sun.corba.se.impl.naming.cosnaming; 9 10 import org.omg.CORBA.INITIALIZE ; 12 import org.omg.CORBA.ORB ; 13 import org.omg.CORBA.CompletionStatus ; 14 15 import org.omg.CORBA.Policy ; 16 import org.omg.CORBA.INTERNAL ; 17 import org.omg.PortableServer.POA ; 18 import org.omg.PortableServer.LifespanPolicyValue ; 19 import org.omg.PortableServer.RequestProcessingPolicyValue ; 20 import org.omg.PortableServer.IdAssignmentPolicyValue ; 21 import org.omg.PortableServer.ServantRetentionPolicyValue ; 22 23 import org.omg.CosNaming.NamingContext ; 25 26 import com.sun.corba.se.impl.naming.cosnaming.TransientNamingContext; 28 import com.sun.corba.se.impl.orbutil.ORBConstants; 29 30 import com.sun.corba.se.spi.logging.CORBALogDomains; 31 32 import com.sun.corba.se.impl.logging.NamingSystemException; 33 34 46 public class TransientNameService 47 { 48 56 public TransientNameService(com.sun.corba.se.spi.orb.ORB orb ) 57 throws org.omg.CORBA.INITIALIZE 58 { 59 initialize( orb, "NameService" ); 63 } 64 65 74 public TransientNameService(com.sun.corba.se.spi.orb.ORB orb, 75 String serviceName ) throws org.omg.CORBA.INITIALIZE 76 { 77 initialize( orb, serviceName ); 80 } 81 82 83 87 private void initialize( com.sun.corba.se.spi.orb.ORB orb, 88 String nameServiceName ) 89 throws org.omg.CORBA.INITIALIZE 90 { 91 NamingSystemException wrapper = NamingSystemException.get( orb, 92 CORBALogDomains.NAMING ) ; 93 94 try { 95 POA rootPOA = (POA ) orb.resolve_initial_references( 96 ORBConstants.ROOT_POA_NAME ); 97 rootPOA.the_POAManager().activate(); 98 99 int i = 0; 100 Policy [] poaPolicy = new Policy [3]; 101 poaPolicy[i++] = rootPOA.create_lifespan_policy( 102 LifespanPolicyValue.TRANSIENT); 103 poaPolicy[i++] = rootPOA.create_id_assignment_policy( 104 IdAssignmentPolicyValue.SYSTEM_ID); 105 poaPolicy[i++] = rootPOA.create_servant_retention_policy( 106 ServantRetentionPolicyValue.RETAIN); 107 108 POA nsPOA = rootPOA.create_POA( "TNameService", null, poaPolicy ); 109 nsPOA.the_POAManager().activate(); 110 111 TransientNamingContext initialContext = 113 new TransientNamingContext(orb, null, nsPOA); 114 byte[] rootContextId = nsPOA.activate_object( initialContext ); 115 initialContext.localRoot = 116 nsPOA.id_to_reference( rootContextId ); 117 theInitialNamingContext = initialContext.localRoot; 118 orb.register_initial_reference( nameServiceName, 119 theInitialNamingContext ); 120 } catch (org.omg.CORBA.SystemException e) { 121 throw wrapper.transNsCannotCreateInitialNcSys( e ) ; 122 } catch (Exception e) { 123 throw wrapper.transNsCannotCreateInitialNc( e ) ; 124 } 125 } 126 127 128 132 public org.omg.CORBA.Object initialNamingContext() 133 { 134 return theInitialNamingContext; 135 } 136 137 138 private org.omg.CORBA.Object theInitialNamingContext; 140 } 141 | Popular Tags |