6.4.3 Obtaining the initial POA object and registering the first object reference

To complete the implementation of the server we need to write the code that enters it into the CORBA environment. In detail, we need to:

To do this, we need to make use of some additional operations specified in the CORBA module:

module CORBA {    
  interface ORB {     
    typedef string ObjectId;      
    exception InvalidName {};      
    Object resolve_initial_references (in ObjectId identifier)          
        raises (InvalidName);      
    void shutdown( in boolean wait_for_completion );    

The CORBA standard specifies the ORB operation resolve_initial_references . This operation provides a portable method for applications to obtain initial references to a small set of standard objects (objects other than the initial ORB). These objects are identified by a mnemonic name, using a string known as an ObjectId . For instance, the ObjectID for an initial POA object is RootPOA . (References to a select few other objects, such as the InterfaceRepository and NamingService , can also be obtained in this manner.)

The ORB operation resolve_initial_references returns the object associated with an ObjectId , raising the exception InvalidName for an unrecognized ObjectID .

Meanwhile, the shutdown operation instructs the ORB, and its object adapters, to shut down. If the wait_for_completion parameter is TRUE , the operation blocks until all pending ORB processing has completed, otherwise it simply shuts down the ORB immediately.

(defun bank-server ()
  (let* ((orb (op:orb_init nil "LispWorks ORB"))
         (rootPOA (op:resolve_initial_references orb "RootPOA")))
    (let ((bank-impl (make-instance 'bank-implementation 
                                   :connection (connect-to-database)
                                   :poa rootPOA)))
      (let ((bank-ref (op:servant_to_reference rootPOA 
        (object-to-file orb bank-ref)
        (capi:display (make-instance 'server-controller
                                     :bank-poa rootPOA
                                     :bank-ref bank-ref)))
      (op:activate (op:the_poamanager rootPOA)))))

The top-level function first initializes the LispWorks ORB by calling the Common Lisp generic function op:ORB_init , just as we initialized the ORB in the client.

The call returns an ORB pseudo-object. Invoking op:resolve_initial_references on this ORB, passing the
ObjectID RootPOA , returns a POA object of class PortableServer:POA . This is the CORBA standard method for obtaining the initial POA object. Note that root POA is initially in the holding state.

Next, we connect to the database and use the connection to make a bank servant. We register the servant with the POA , RootPOA , and publish the resulting object reference, encoded as a string, in the shared file.

We then obtain the POA Manager for the POA using the POA operation op:the_POAManager . The call to op:activate moves the POA out of the holding state, into the active state, ready to receive and process incoming requests.

This completes the description of our implementation of the server.


Developing Component Software with CORBA - 23 Mar 2005