[omniORB] IOR Distributor?

Nick Murtagh murtaghn@tcd.ie
Wed, 17 Apr 2002 22:46:50 +0100


On Wednesday 17 April 2002 22:13, you wrote:
> This would be perfect!  Is there an example of it
> somewhere, or detailed instructions on how to do
> the omniORB server side?  All I have in my current
> program is the root POA.  Do I just substitute the
> string "omniINSPOA"?  And how do I give it a name?

I did this myself recently. Replace <hostname>, <port>, <objectid> with your 
own bits. And changes all the references to Object_i to whatever your server 
implementation is called. Hope this helps!

// start here

// Initialise the ORB.
const char * options[][2] = 
  {{ "endPoint","giop:tcp:<hostname>:<port>" }, { 0, 0 }};
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);

// Obtain a reference to the omniINSPOA.
CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);

// We allocate the objects on the heap.  Since these are reference
// counted objects, they will be deleted by the POA when they are no
// longer needed.
Object_i * object = new Object_i();

// Create simple object ids
PortableServer::ObjectId_var objectId =  
  PortableServer::string_to_ObjectId("<objectid>");

// Activate the objects.  This tells the POA that the objects are
// ready to accept requests.
poa -> activate_object_with_id(objectId, object);

// Remove references - these are now handled by the POA
object -> _remove_ref();

// Obtain a POAManager, and tell the POA to start accepting
// requests on its objects.
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();

orb->run();
orb->destroy();

// end here