[omniORB] BOA -> POA questions

David Riddoch djr@uk.research.att.com
Mon, 17 Jul 2000 09:46:50 +0100 (BST)


On Sun, 16 Jul 2000, Stefan Seefeld wrote:

> I'm trying to port berlin's source code to the POA 
> architecture. Now I'm looking for an equivalent of
> the servant->_dispose() call. What I came up with looks so:
> 
> static void destroy(PortableServer::Servant servant)
> {
>   PortableServer::POA_var poa = servant->_default_POA();
>   PortableServer::ObjectId_var oid = poa->servant_to_id(servant);
>   poa->deactivate_object(oid);
> }
> 
> I use the default POA, i.e. implicit activation. My servants
> are derived from PortableServant::RefCountServantBase.
> I would hope that the above code results in the object being
> deactivated and the servant being deleted.
> Could you please confirm this ?

Looks fine as long as you've got your reference counting right.


> Looking through your example code in
> http://www.uk.research.att.com/omniORB/doc/3.0/omniORB/omniORB002.html#toc9
> 
> I find a call to myecho->_remove_ref() which I don't understand.
> Given that the call to _this() increments the ref counter and sets it
> to 1, I would think that a call to 'deactivate_object' sets it back to
> 0, resulting in the deletion.

When a servant is created it has a reference count of 1.  When you
activate it, it becomes 2.  You then call _remove_ref() to take it back to
1.  When you deactivate the servant, it will go to zero and be deleted
(once all outstanding requests have completed).


> PS: is the Servant::_PD_repoId member portable ? I couldn't find any
>     mention of how to access the repoId from a given interface C++ 
>     type...

Do you mean foo::_PD_repoId (there is no Servant::_PD_repoId as far as I
know)?  Anyway, it is non-portable.  The spec gives no way to get at the
repo id, you are expected to generate them yourself I guess.

Hope that helps,
David