[omniORB] Using `the_servant` in postinvoke() ?
randy.shoup@tumbleweed.com
randy.shoup@tumbleweed.com
Wed, 14 Feb 2001 16:13:19 -0800
I am trying to figure out the best way to get access to my "real"
implementation object from within the implementation of
ServantLocator::postinvoke(). I have consulted the archives of
comp.object.corba, and several ORB mailing lists without success. I
can't consult H&V because I have it at work :-).
My implementation object is declared as a subclass of
RefCountServantBase, e.g.:
class MyImpl : public RefCountServantBase, ...
preinvoke() looks like:
PortableServer::Servant preinvoke( ... ) {
// get my servant out of a pool
MyImpl * servant = ...;
// initialize the servant with some operation-specific information
servant->initialize(...);
return servant;
}
I want to be able to invoke a cleanup method of MyImpl inside
postinvoke(), so I want to do something like:
void postinvoke( ... , PortableServer::Servant the_servant) {
// cast to MyImpl*
MyImpl* servant = (MyImpl *)the_servant;
// clean up
servant->cleanup(...);
}
The cast to MyImpl* does not compile because MyImpl derives from
RefCountServantBase, which inherits *virtually* from ServantBase. Hmmm
...
There are of course alternate ways of getting access to MyImpl, like
1. adding it to the cookie in preinvoke()
2. retaining a map from oid -> MyImpl*
etc.
But these options seem pretty heavyweight when I have the object right
there :-). After further reflection, it seems to me that the inability
to cast here makes `the_servant` pretty much useless in postinvoke().
Sure, you can call _remove_ref() on it, but that is about it.
What am I missing?
Thanks,
-- Randy
_________________________________________________________________
Randy Shoup (650)216-2038
Senior Architect rshoup@tumbleweed.com
Tumbleweed Communications Corporation