[omniORB] How to create a Persistance Corba server

Mahanta, Dhruba Dhruba.Mahanta at kla-tencor.com
Wed Nov 17 20:41:53 GMT 2010


Hi

 

Requirement: Corba server should be persistent so that even if the Corba
server application restarted, or the computer hosting Corba server is
rebooted, Corba Client application need not be reinitialized.

 

Server Side Implementation:

 

main()

{

                CORBA::ORB_var objCorbaOrb;

      objCorbaOrb = CORBA::ORB_init(argc, argv);

      CORBA::Object_var obj =
objCorbaOrb->resolve_initial_references("omniINSPOA");

      PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow(obj);

 

      CServerObj* pSvr = new CServerObj();

      PortableServer::POAManager_var objPOAManager =
rootPOA->the_POAManager();

      PortableServer::ObjectId_var myObjID =
PortableServer::string_to_ObjectId("IMC.context/Diagnostics.Object");

      rootPOA->activate_object_with_id(myObjID, pSvr);

      obj = rootPOA->servant_to_reference(pSvr);

                

                if( !bindObjectToName(objCorbaOrb, obj) )

         return 1;

      CosNaming::NamingContext_var rootContext;

 

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

      CORBA::Object_var obj;

      obj = objCorbaOrb->resolve_initial_references("NameService");

      // Narrow the reference returned.

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

      

      // Bind a context to the root context:

      CosNaming::Name contextName;

      contextName.length(1);

      contextName[0].id   = (const char*) "IMC";       // string copied

      contextName[0].kind = (const char*) "context"; // string copied

      CosNaming::NamingContext_var testContext;

      // Bind the context to root.

      testContext = rootContext->bind_new_context(contextName);

      

      // Bind objref 

      CosNaming::Name objectName;

      objectName.length(1);

      objectName[0].id   = (const char*) "Diagnostics";   // string
copied

      objectName[0].kind = (const char*) "Object"; // string copied

      testContext->bind(objectName, obj);

      

      pSvr->_remove_ref();

      objPOAManager->activate();

      objCorbaOrb->run();

}



 

Client Side Implementation

 

main()

{

                

                std::string       szCorbaName = "corbaname::";

      std::string       szCorbaId   =
":2809#IMC.context/Diagnostics.Object";

 

      szCorbaName += szIPAddress;

      szCorbaName += szCorbaId;

 

      int nArg = 0;

      m_objORB = CORBA::ORB_init(nArg, NULL);

      CORBA::Object_var obj =
m_objORB->string_to_object(szCorbaName.c_str());

      if( CORBA::is_nil(obj) )

      {

            return false;

      } 

 

      m_objServerObj = IServerObj::_narrow(obj);

 

      if( CORBA::is_nil(m_objServerObj) )

      {

            return false;

      }    

}

 

 

Problem:

When the client is freshly initialized the communication object
(m_objServerObj in the client code) there is no issue. But once server
goes down or rebooted, existing client object(m_objServerObj)

fails to invoke server calls for the first time, but if I try(somehow)
to make the invoke call for 2nd time on the same client object it
succeeds.

 

Can someone help me to figure out what could be the issue here. 

 

 

 

Regards

Dhruba

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20101117/2971bfd7/attachment.htm


More information about the omniORB-list mailing list