FileDocCategorySizeDatePackage
TransientNameService.javaAPI DocJava SE 5 API5156Fri Aug 26 14:54:26 BST 2005com.sun.corba.se.impl.naming.cosnaming

TransientNameService

public class TransientNameService extends Object
Class TransientNameService implements a transient name service using TransientNamingContexts and TransientBindingIterators, which implement the org.omg.CosNaming::NamingContext and org.omg.CosNaming::BindingIterator interfaces specfied by the OMG Common Object Services Specification.

The TransientNameService creates the initial NamingContext object.

see
NamingContextImpl
see
BindingIteratorImpl
see
TransientNamingContext
see
TransientBindingIterator

Fields Summary
private org.omg.CORBA.Object
theInitialNamingContext
Constructors Summary
public TransientNameService(com.sun.corba.se.spi.orb.ORB orb)
Constructs a new TransientNameService, and creates an initial NamingContext, whose object reference can be obtained by the initialNamingContext method.

param
orb The ORB object
exception
org.omg.CORBA.INITIALIZE Thrown if the TransientNameService cannot initialize.

        // Default constructor uses "NameService" as the key for the Root Naming
        // Context. If default constructor is used then INS's object key for
        // Transient Name Service is "NameService"
        initialize( orb, "NameService" );
    
public TransientNameService(com.sun.corba.se.spi.orb.ORB orb, String serviceName)
Constructs a new TransientNameService, and creates an initial NamingContext, whose object reference can be obtained by the initialNamingContext method.

param
orb The ORB object
param
nameserviceName Stringified key used for INS Service registry
exception
org.omg.CORBA.INITIALIZE Thrown if the TransientNameService cannot initialize.

        // This constructor gives the flexibility of providing the Object Key
        // for the Root Naming Context that is registered with INS.
        initialize( orb, serviceName );
    
Methods Summary
public org.omg.CORBA.ObjectinitialNamingContext()
Return the initial NamingContext.

return
the object reference for the initial NamingContext.

	return theInitialNamingContext;
    
private voidinitialize(com.sun.corba.se.spi.orb.ORB orb, java.lang.String nameServiceName)
This method initializes Transient Name Service by associating Root context with POA and registering the root context with INS Object Keymap.

	NamingSystemException wrapper = NamingSystemException.get( orb,
	    CORBALogDomains.NAMING ) ;

        try {
            POA rootPOA = (POA) orb.resolve_initial_references( 
		ORBConstants.ROOT_POA_NAME );
            rootPOA.the_POAManager().activate();

            int i = 0;
            Policy[] poaPolicy = new Policy[3];
            poaPolicy[i++] = rootPOA.create_lifespan_policy(
                LifespanPolicyValue.TRANSIENT);
            poaPolicy[i++] = rootPOA.create_id_assignment_policy(
                IdAssignmentPolicyValue.SYSTEM_ID);
            poaPolicy[i++] = rootPOA.create_servant_retention_policy(
                ServantRetentionPolicyValue.RETAIN);

            POA nsPOA = rootPOA.create_POA( "TNameService", null, poaPolicy );
            nsPOA.the_POAManager().activate();

            // Create an initial context
            TransientNamingContext initialContext =
                new TransientNamingContext(orb, null, nsPOA);
            byte[] rootContextId = nsPOA.activate_object( initialContext );
            initialContext.localRoot =
                nsPOA.id_to_reference( rootContextId );
            theInitialNamingContext = initialContext.localRoot;
            orb.register_initial_reference( nameServiceName, 
                theInitialNamingContext );
        } catch (org.omg.CORBA.SystemException e) {
	    throw wrapper.transNsCannotCreateInitialNcSys( e ) ;
        } catch (Exception e) {
	    throw wrapper.transNsCannotCreateInitialNc( e ) ;
        }