[omniORB] trouble destroying ORB and re-initializing it

Len Holgate (Mail List Account) Mail-lists@dial.pipex.com
Sat, 8 Sep 2001 07:52:18 +0100


>
> Hi, I am working on a program where the user can choose the naming
> service host before the ORB is started up.  Later, they can change

I don't think you can shut down the ORB and reinitialise it...

Use corbaloc and string_to_object instead... See snippet below...

CORBA::Object_ptr CCurveServerProxy::ResolveNameToObject(
   CORBA::ORB_ptr orb)
{
   CosNaming::NamingContext_var rootContext;

   try
   {
      // Obtain a reference to the root context of the Name service:

      string uri = "corbaloc:iiop:";

      if (m_initialHost.length() != 0)
      {
         uri += m_initialHost;
      }
      else
      {
         uri += "localhost";
      }

      if (m_initialPort.length() != 0)
      {
         uri += ":" + m_initialPort;
      }

      uri += "/NameService";

      CORBA::Object_var obj = orb->string_to_object(uri.c_str());

      rootContext = CosNaming::NamingContext::_narrow(obj);

      if(CORBA::is_nil(rootContext))
      {
         throw Exception("CORBA Error: Failed to narrow the root naming
context");
      }
   }
   catch(CORBA::ORB::InvalidName& )
   {
      throw Exception("CORBA Error: NameService does not exist");
   }

Len
http://www.jetbyte.com