Reputation: 2552
I'm using MICO to create a C++ CORBA server.
In my system a client should be able to directly access the corba object in the server using a corbaloc address (no name service). Do you know if MICO provides such feature? How can I implement that? I tried with:
ORB_ptr orb = CORBA::ORB_init (argc, argv, "mico-local-orb");
Object_var obj = orb -> resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj );
PortableServer::POAManager_var pman = poa -> the_POAManager();
pman -> activate();
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId( "hello" );
HelloImpl* servant = new HelloImpl();
poa -> activate_object_with_id( oid.in(), servant );
servant -> _remove_ref();
orb -> run();
this code works with OMNIORB but not with MICO.
EDIT: I also tried with a persistent lifespan policy but it doesn't work either:
ORB_ptr orb = ORB_init( argc, argv );
Object_var obj = orb -> resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj );
PortableServer::POAManager_var pman = poa -> the_POAManager();
pman -> activate();
PortableServer::LifespanPolicy_var lifespan =
poa -> create_lifespan_policy( PortableServer::PERSISTENT );
PortableServer::IdAssignmentPolicy_var idassignment =
poa -> create_id_assignment_policy ( PortableServer::USER_ID );
CORBA::PolicyList policies( 2 );
policies.length( 2 );
policies[0] = PortableServer::IdAssignmentPolicy::_duplicate( idassignment );
policies[1] = PortableServer::LifespanPolicy::_duplicate( lifespan );
PortableServer::POA_var child_poa =
poa -> create_POA( "childPOA", pman.in(), policies );
PortableServer::POAManager_var child_pman = child_poa -> the_POAManager();
child_pman -> activate();
idassignment -> destroy();
lifespan -> destroy();
HelloImpl* servant = new HelloImpl();
PortableServer::ObjectId_var oid = child_poa -> activate_object( servant );
CORBA::Object_var ref = child_poa -> id_to_reference( oid.in() );
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId( "hello" );
child_poa -> activate_object_with_id ( oid.in (), servant );
orb -> run();
EDIT2:
I tested the server with a client that tries to string_to_object
the following corbaloc addresses:
corbaloc:iiop:localhost:12345/hello
corbaloc:iiop:localhost:12345/childPOA/hello
but none of them worked. I always get a CORBA::OBJECT_NOT_EXIST
exception.
Thanks
Upvotes: 2
Views: 506
Reputation: 9391
For Mico you have to use the poa hierarchy in the corbalo url as well. For your example corbaloc::localhost:12345/childPOA/hello
should work.
See also the Diploma thesis of Frank Pilhofer, the implementor of Mico's POA, which states
create a persistent POA with the name ``MyPOA'', and then activate an object
using the ``MyObject'' Object Id, you could refer to that object using the IOR
iioploc://thishost:1234/MyService/MyPOA/MyObject
Edit: You have to start your serving executable with a service name -POAImplName MyService
Upvotes: 1