[omniORB] How to use more than one naming server?
Mark Johnson
mark.johnson@onfiber.com
Tue, 16 Oct 2001 13:15:48 -0500
I'm confused from reading the documentation about how to configure a server
and a client to use redundant naming servers. We have to run our
applications to use a fail over naming service in case we lose the primary
name server.
But I'm confused, in the examples they always the ORB_init() method to pass
the command line and always use "RootPOA" to register the servant. If I
wanted to use two (or more) naming services and have the servant register
with all of them would I do something like this?
myserver -ORBInitRef FOO=corbaname::foo.onfiber.com
BAR=corbaname::bar.onfiber.com
And then in my server code do something like this:
void MyServerApp::setup( int argc, char * argv[] )
{
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB3" );
// should this ALWAYS be "RootPOA"?
//
CORBA::Object_var fooObj = orb->resolve_initial_references( "FOO" );
CORBA::Object_var barObj = orb->resolve_initial_references( "BAR" );
PortableServer::POA_var fooPOA = PortableServer::POA::_narrow(
fooObj ); PortableServer::POA_var barPOA =
PortableServer::POA::_narrow( barObj );
Servant_i * servant = new Servant_i();
// register with both naming servers...
//
PortableServer::ObjectId_var oid = fooPOA->activate_object( servant
);
PortableServer::ObjectId_var oid = barPOA->activate_object( servant
);
// etc..
PortableServer::POAManager_var fooPMAN = fooPOA->the_POAManager();
PortableServer::POAManager_var barPMAN = barPOA->the_POAManager();
fooPMAN->activate();
barPMAN->activate();
// etc...
bindObjectToName(...)
}
I assume that I would do the thing when I called
'resolve_initial_reference()' in the 'bindObjectToName()' and select FOO or
BAR (if there was an exception thrown on FOO).
Do I understand this correctly?
I'll save my questions about the client after I understand this part
first...
Thanks for your help...