I am using Servant Activator for my poa. I have implemented
ServantActivator::incarnate() method to create a new servant of a
specific type from heap. I am using create_reference() method to
create an object reference of a particular type before making any
call.
My problem: Let there are two interfaces A and B. I need to create a
servant of either of thees two types (A or B) on need basis at run
time. But I don't know how to do it within incarnate method as I don't
know the type of the object reference being referred by oid parameter
of incarnate method. Is there any way to perform this?
I tried a logic given below but it failed due to poa->id_to_reference
() method with the following error:
12 [sig] server 504 _cygtls::handle_exceptions: Error
while dumping state
probably corrupted stack)
Piece of code:
PortableServer::Servant incarnate( const PortableServer::ObjectId &
oid,
PortableServer::POA_ptr poa )
{
PortableServer::Servant servant= 0;
CORBA::Object_var obj= poa->id_to_reference(oid);
Example_var ex=
Example::_narrow(obj.in());
if (!CORBA::is_nil(nC))
{
servant= new Example_i(poa);
}
return servant;
}
}
Any help would be highly appreciated.
Regards,
Amit