boa.obj_is_ready
method is invoked.
You can use persistent object references to implement long-running services that provide long-term tasks. Light-weight and domain-specific, transient object references take a relatively short amount of time to instantiate. Persistent object references take longer to instantiate. Consequently, the ideal mix is to have some persistent object references and many more transient object references used by your application. The following code example creates and registers a persistent object reference using the name ISB_Bank.
Creating a persistent object.
// Using Enterprise Server's ORB
public class Server {
public static void main(String[] args) {
try {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
// Initialize the BOA.
org.omg.CORBA.BOA boa = orb.BOA_init();
// Create the account manager object.
AccountManager manager = new AccountManager("ISB_Bank");
// Export the newly created object.
boa.obj_is_ready(manager);
String host = java.netInetAddress.getLocalHost().getHostName();
netscape.WAI.Naming.register
("http://" + host + "/ISB_Bank", manager);
// Or, if using Communicator's ORB, the call would be:
// netscape.WAI.Naming.register
// ("http://" + host + "/NameService/ISB_Bank", manager);
// Wait for incoming requests
boa.impl_is_ready();
} catch(org.omg.CORBA.SystemException se) {
System.err.println(se);
}
catch(java.net.UnknownHostException u) {
System.err.println(u);
}
}
} Checking for Persistent Object References
The Object._is_persistent
method allows your client application to determine whether an object reference is persistent or transient. It is important to know whether a reference is persistent because some methods for manipulating object references will fail if the reference is transient. The _is_persistent
method returns true if the reference is persistent and false if it is transient. For information about all of the available methods, see the Netscape Internet Service Broker for Java Reference Guide.
Transient Object References
Object references that are only available during the lifetime of the process that created them are called transient object references. Only those entities that possess an explicit object reference to a transient object reference can invoke its methods. To create a transient object reference, instantiate an object without specifying an object name, as shown below.
Creating a transient object.
// Using Enterprise Server's ORB
public class Server {
public static void main(String[] args) {
try {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
// Initialize the BOA.
org.omg.CORBA.BOA boa = orb.BOA_init();
// Create the account manager object.
AccountManager manager = new AccountManager();
// Export the newly created object.
boa.obj_is_ready(manager);
String host = java.netInetAddress.getLocalHost().getHostName();
netscape.WAI.Naming.register
("http://" + host + "/ISB_Bank", manager);
// Or, if using Communicator's ORB, the call would be:
// netscape.WAI.Naming.register
// ("http://" + host + "/NameService/ISB_Bank", manager);
// Wait for incoming requests
boa.impl_is_ready();
} catch(org.omg.CORBA.SystemException se) {
System.err.println(se);
}
catch(java.net.UnknownHostException u) {
System.err.println(u);
}
}
} Object Registration
Once a server has instantiated the ORB objects that it offers, the BOA must be notified when the objects have been initialized. Lastly, the BOA is notified when the server is ready to receive requests from client applications.
The obj_is_ready
method notifies the BOA that a particular ORB object is ready to receive requests from client applications. If your server offers more than one ORB object, it must invoke obj_is_ready
for each object, passing the object reference as an argument.
If a persistent object reference is passed to obj_is_ready
, the BOA will register the object with the naming service. If the reference is transient, no such registration will occur. If obj_is_ready
has not been invoked for an object by its server and a client attempts to bind to the object, the exception NO_IMPLEMENT is raised.
Once all of the objects have been instantiated and all the invocations of obj_is_ready
have been made, the server must invoke the impl_is_ready
method to enter an event loop and await client requests. Servers that are activated through a GUI (graphical user interface) or are activated by other means do not need to use impl_is_ready
.
Activating Objects Directly
Direct activation of an object involves an object server instantiating all the Java implementation classes, invoking the BOA.obj_is_ready
method for each object, and then invoking BOA.impl_is_ready
to begin receiving requests. The following code example shows how this processing would occur for a server offering two AccountManager objects; one with the object name of Chicago and the other named Dallas. Once the objects have been instantiated and activated, the server invokes BOA.impl_is_ready
to begin receiving client requests.
NOTE:
The method BOA.obj_is_ready
must be called for each object offered by
the implementation.
Server activating two objects and the implementation.
// Using Enterprise Server's ORB
public class Server {
public static void main(String[] args) {
try {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
// Initialize the BOA.
org.omg.CORBA.BOA boa = orb.BOA_init();
// Create the account manager object for Chicago.
AccountManager chicago = new AccountManager("Chicago");
// Create the account manager object for Dallas.
AccountManager dallas = new AccountManager("Dallas");
// Export the newly created objects.
boa.obj_is_ready(chicago);
boa.obj_is_ready(dallas);
System.out.println(chicago + " is ready.");
System.out.println(dallas + " is ready.");
String host = java.netInetAddress.getLocalHost().getHostName();
// Or, if using Communicator's ORB, the call would be:
// netscape.WAI.Naming.register
// ("http://" + host + "/NameService/bank", chicago);
netscape.WAI.Naming.register("http://" + host + "/bank", chicago);
netscape.WAI.Naming.register("http://" + host + "/bank", dallas);
// Wait for incoming requests
boa.impl_is_ready();
} catch(org.omg.CORBA.SystemException se) {
System.err.println(se);
}
catch(java.net.UnknownHostException u) {
System.err.println(u);
}
}
}
obj_is_ready
can be deactivated explicitly by calling deactivate_obj
. Then, the implementation will not be available to service client requests. The service can only be re-activated if it is restarted or if it again calls obj_is_ready
.
Last Updated: 02/04/98 13:46:53