Creating an in-process NameService

The ORB provides a NameServiceFactory initial object reference that can be used to create instances of COS NameServices.

Using the LifespanPolicy argument you can specify whether you want a transient or a persistent namespace. A Transient namespace has transient NamingContext objects and the state of the objects is also not made persistent. That is, when the server in which the NameService terminates, the namespace is no longer accessible. Persistent NameService uses persistent NamingContext objects and their state is also persistent. A persistent namespace is always available even when its server is not active.

You can also secure the namespace using the AccessPolicy.

package com.sssw.jbroker.api.naming;
 
import org.omg.PortableServer.POA;
import org.omg.PortableServer.LifespanPolicyValue;
 
public interface NameServiceFactory extends org.omg.CORBA.Object
{
    /**
     * Create a Name Service.
     */
    NameService createNameService(POA parent, String serviceName,
        LifespanPolicyValue lifespan, AccessPolicy accessPolicy,
        String realm);
    /**
     * Create a Name Service using the user supplied DataStore.
     */
    NameService createNameService(POA parent, String serviceName,
        LifespanPolicyValue lifespan, DataStore dataStore,
        AccessPolicy accessPolicy, String realm);
}
 
Transient NameService Example
In this sample program we will use the NameServiceFactory to create a transient NameService and then we will bind its root context as an initial object reference using the Initial References Service (IRS).
Persistent NameService Example
In this sample program we will use the NameServiceFactory to create a persistent NameService and then we will bind its root context as an initial object reference using the Initial References Service (IRS). The Datastore provided by the ORB, by default, saves naming context state in the $(JBROKER_HOME)/db/names/<server alias>/<serviceName>. You can override that by specifying the "ORBNamesDirectory" property. See the example Makefile.

Copyright © 1998-2003, Novell, Inc. All rights reserved.