[omniORB] Dynamic destruction of servants when no client references

Diez B. Roggisch deets at web.de
Tue Apr 12 15:45:01 BST 2005


> The CORBA object model is that objects do not know who their clients
> are, so there is simply no way to automatically deactivate an object
> when its last client goes away. It has to be implemented at the
> application level. There is no one right answer, but there are a number
> of common patterns. The best reference is Henning and Vinoski's Advanced
> CORBA Programming with C++.
>
> The easiest thing to implement is often a timeout so that objects that
> have not been touched for a while are deactivated.

And the easiest way to do so is to create a child POA for each client 
connection (or client session - _not_ the underlying tcp/ip connection) and 
register all objects for one client to that very childPOA. When the timeout 
is hit, you can destroy the child poa (it has a destroy call for that) and 
then all references are gone.

Duncan has made a game example application that shows how to do the child poa 
creation and registering of the objects. Google for it. 

And be aware that calling _this() on a servant will register the servant with 
the default poa, which is AFAIK the RootPOA. So I've written myself a 
this(poa, servant) function that does the necessary calls (only two, but a 
programmer should be as lazy as possible)

For implementing the timeout itself.... tricky in C++ I believe, but easy as 
cake in python - hooray to dynamic languages and metaclasses :)

Diez



More information about the omniORB-list mailing list