Next Previous Up Top Contents Index

6.4 Implementing the bank server

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 operationresolve_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 anObjectId. For instance, theObjectID for an initial POA object isRootPOA. (References to a select few other objects, such as theInterfaceRepository andNamingService, can also be obtained in this manner.)

The ORB operationresolve_initial_references returns the object associated with anObjectId, raising the exceptionInvalidName for an unrecognizedObjectID.

Meanwhile, theshutdown operation instructs the ORB, and its object adapters, to shut down. If thewait_for_completion parameter isTRUE, 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 "Harlequin Common Lisp 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 
               bank-impl)))
        (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 Harlequin Common Lisp ORB by calling the Common Lisp generic functionop:ORB_init, just as we initialized the ORB in the client.

The call returns an ORB pseudo-object. Invokingop:resolve_initial_references on this ORB, passing the
ObjectIDRootPOA, returns a POA object of classPortableServer:POA. This is the CORBA standard method for obtaining the initial POA object. Note that rootPOA 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 thePOA,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 operationop:the_POAManager. The call toop: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 - 22 Jan 1999

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker