Java Reference
In-Depth Information
Here, we passed in the args parameter from the command line as well as the
system properties object, allowing both methods of ORB parameter specification
to be used.
19.4.2.2 Get the root POA and activate the POAManager
When there is an ORB, there are certain important services either already available
or assumed to be available. An example of the latter is the CORBA naming service,
known as COSNaming ,which we learn about shortly. An example of the former
is the root POA. The root POA is the root of a hierarchical chain of POAs. In
many cases, including all the examples used in this topic, you need use only the
root POA. For more complicated cases in which certain POA policies need to
be changed, you would have to create one or more child POAs in order to have
different behaviors.
The ORB class provides the resolve - initial - references() method
to obtain references to services such as the naming service and the root POA.
As usual, the return from resolve - initial - references() is a generic
CORBA object that must be narrowed to a POA using the POAHelper class. A
reference to the root POA is retrieved with the following code snippet;
POA rootpoa =
POAHelper.narrow (orb.resolve - initial - references
("RootPOA"));
Each POA has an associated POAManager object, which may be the manager
of more than one POA. The POAManager class has several methods, as doc-
umented in the org.omg.PortableServer package, but the only thing we
really need to know about the POAManager is that it must be activated, which
permits its associated POAs to start processing requests. The code to activate the
POAManager is
rootpoa.the - POAManager().activate ();
19.4.2.3 Create an instance of the servant object
Recall that a server is a process that instantiates and makes available one or more
servant objects. So our server must create an instance of our servant. Doing so is
a simple Java instantiation:
Servant servant = Cor19ExampleServant ();
At this point, we have a Java servant instance, which is an instance of
org.omg.PortableServer.Servant ,which is a Java object, but not a
CORBA object. To create a CORBA object (actually, an object reference) from
the servant, we use a method on the POA:
org.omg.CORBA.Object obj - ref =
rootpoa.servant - to - reference (servant);
Search WWH ::




Custom Search