Java Reference
In-Depth Information
Note that once we have a reference to the contained CustomData object, we do
not need to “put it back” into the Holder object.
19.4.2 Server implementation
We now turn to the server class that instantiates the servant and makes it avail-
able to the CORBA subsystem. Our Cor19Server.java class has only a
main() method that initializes CORBA, locates the CORBA naming service,
creates a Cor19Servant instance, and loads that instance into the naming ser-
vice. These steps are analogous to the steps followed in the RMI example, but the
details are quite different for CORBA than for RMI.
Part of the CORBA subsystem is an Object Request Broker (ORB). The
ORB is a library of support code that accomplishes the low-level communi-
cations between CORBA clients and servers. The ORB class is in package
org.omg.CORBA and provides many functions, only a few of which are of inter-
est to the casual CORBA programmer. The only method we use is ORB.init()
to initialize the ORB.
Another concept important in CORBA is the Portable Object Adapter ,orPOA.
We briefly mentioned POA when discussing the abstract Cor19ExamplePOA
class, which must be extended to create the servant class. It is useful to think of an
“object adapter” as the way in which clients, servers, and servants interact with
the ORB. Before the OMG adopted the POA standard, each vendor of CORBA
software implemented their object adapters in different ways. As a result, source
code was not portable between CORBA ORB vendors. To resolve this problem,
the OMG created the portable object adapter specification, or POA. A POA is
a CORBA object, but because of the services it provides, it is a very special
kind of object. A POA manages the implementation of a collection of objects
and provides a namespace for those objects, including other POAs. It is not
necessary to understand all the services provided by the POA, which is a large
and complicated subject. We use only the most basic POA features in this example
without going into detail about what is really happening behind the scenes.
The server class's main() method must perform the following six steps:
1. Create and initialize the ORB.
2. Get the root POA and activate the POAManager.
3. Create an instance of the servant object.
4. Get a reference to the naming service.
5. Bind the servant into the naming service.
6. Tell the ORB to wait for incoming requests from clients.
We discuss each of these six steps in turn. First, though, since any call to a
CORBA method could result in a CORBA exception, we wrap everything in a
try/catch block. Thus,
Search WWH ::




Custom Search