Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Dr.Bob's Delphi Notes Dr.Bob's Kylix Kicks
 Delphi and CORBA: Object Activation Daemon (OAD)
See Also: CORBA Book Reviews or Programming Papers

Delphi 5 Enterprise (and Delphi 4 Client/Server) come with a number of CORBA demos. One of them, found in the demos\corba directory, is the Account demo. I've had some questions laterly about the ability to automatically load the Account server using the Object Activation Daemon, so here goes...

The Object Activation Daemon (OAD) is a deployment-time service that allows CORBA Server to be automatically started when a CORBA client makes requests. When a CORBA Server (an implementation) is registered with the OAD, the Daemon creates a Forwarder which masquerades as the actual (as yet unspawned) server. As such, it registers with the VisiBroker Smart Agent. When a client requests the object, the following actions occur "under the covers" before a reference is actually returned to the client:

  1. The client's ORB asks the Smart Agent for the location of a Provider that matches the bind criteria. Unbeknownst to the Agent or the client's ORB, the location actually refers to the Forwarder within the OAD.
  2. The client's ORB generates an unbound stub that points to the Forwarder within the OAD. At this point there has been no spawn and there is no knowledge that the obtained Provider actually lives within the OAD. Upon the first method invocation by the client, the following actions occur:
  3. The client's ORB sends a request to the server to find out if the desired object is alive. The OAD responds by:
    1. spawning the desired server according to its registration
    2. waiting for the spawned server to call BOA::obj_is_ready on the requested object
  4. When the spawned server notifies the OAD that the requested object is active (implicitly as part of the BOA::obj_is_ready call within the spawned server), the OAD responds to the original client with the new location of the desired object.
  5. The client (now with the new/real location of the desired object) makes all subsequent invocations on the real object.

Account Example
The Account project group consists of two projects: AccountClient and AccountServer. The goal of this short example is to show how to register the AccountServer with the OAD, so it can be automatically started when the AccountClient tries to make a connection. First, we need to start the Smart Agent (osagent.exe), so any ORB can make a connection. Second, we need to run the OAD itself on the command-line, using the -C switch. Third, we need to register our executable with the OAD, using the OADUTIL program, which for the AcountServer is as follows (one a single command-line, of course):

  OADUTIL reg
   -r IDL:AccountServer/AccountFactory:1.0
   -o Account
   -cpp "c:\program files\borland\delphi4\demos\corba\account\accountserver.exe"
We can unregister the CORBA Server as follows:
  OADUTIL unreg
   -r IDL:AccountServer/AccountFactory:1.0
   -o Account
And we can get a list of entires in the Object Activation Daemon as follows:
  OADUTIL list
Now, once the AcountServer is registered, we can compile and run the AccountClient. Since both applications are CONSOLE apps, it's best to open a CONSOLE window, and start the AccountClient from there. The AccountServer won't display any output, but you can add a ShowMessage dialog to it just to make sure you can see it when it comes alive.

A final remark: don't use the OAD Service from the services manager (this may give you problems - it doesn't work (at all) for some people :). However, using the oad -c from a command-line works just fine.


This webpage © 1993-2017 by Bob Swart (aka Dr.Bob - www.drbob42.com). All Rights Reserved.