[omniORB] activate_object

yashik@veon.com yashik@veon.com
Tue, 7 May 2002 22:17:21 +0200


Hello,

I'm trying to activate an object just like as it said in "Advanced CORBA
programming" book (page 469):

PortableServer::ObjectId_var oid = m_POA->activate_object(my_servant);
CORBA::Object_var obj = m_POA->id_to_reference(oid.in());


Unfortunately, I get a crash as soon as 'oid' variable gets out of scope.
Adding
     oid._retn();
after id_to_reference call corrects the problem, but this looks like a
potential problem: if the exception is thrown before the oid._retn() call,
the variable will be released, causing the crash.

I tried to change ObjectId_var to , ObjectId_ptr but there is no such type
defined.
Then I changed it to
     PortableServer::ObjectId* oid = m_POA->activate_object(encoder);
     CORBA::Object_var obj = m_POA->id_to_reference(*oid);
and this works fine.

My questions are
     1. What is the portable way to receive the ObjectId from
activate_object
     2. Can I assume that activate_object never returns NULL pointer (in
case of any error throws an exception)?

Thank you
Yakov.