[omniORB] objectId problem with PERSITENT SYSTEM_ID POA

bjorn rohde jensen bjensen@fastmail.fm
Sat Oct 12 15:39:01 2002


This is a multi-part message in MIME format.
--------------080300070508050202000106
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi guys,

  I have a bit of a problem with the objectId's
omniORB4 is generating for objects activated on
a POA with policies PERSISTENT and SYSTEM_ID.
Maybe i have made some sort of error, but it
seems to me, that the objectId's generated are
just a simple count of object activated in the
POA so far and not at all unique across all
instantiations of the POA as specified in section
11.3.7.4 of the specs.

Yours sincerely,

Bjorn

--------------080300070508050202000106
Content-Type: text/plain;
 name="hello.idl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="hello.idl"

module Hello
{
  interface HelloServer
  {
    string echo(in string msg);
  };
};

--------------080300070508050202000106
Content-Type: text/plain;
 name="server.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="server.cpp"

#include<typeinfo>
#include<iostream>
#include<iomanip>

#include<assert.h>

#include<omniORB4/CORBA.h>
#include<hello.hh>

class HelloServer_impl:public POA_Hello::HelloServer,
		       public PortableServer::RefCountServantBase
{
private:
  PortableServer::POA_ptr myPoa;
public:
  HelloServer_impl(PortableServer::POA_ptr poa);
  virtual ~HelloServer_impl();
  virtual char * echo(const char *msg);
  virtual PortableServer::POA_ptr _default_POA();
};

HelloServer_impl::HelloServer_impl(PortableServer::POA_ptr poa):
  POA_Hello::HelloServer(),PortableServer::RefCountServantBase(),myPoa(poa)
{
}

HelloServer_impl::~HelloServer_impl()
{
  CORBA::release(myPoa);
}

char *
HelloServer_impl::echo(const char *msg)
{
  return CORBA::string_dup(msg);
}

PortableServer::POA_ptr
HelloServer_impl::_default_POA()
{
  return myPoa;
}
  
int
main(int argc,char **argv)
{
  try{
    CORBA::ORB_var orb=CORBA::ORB_init(argc,argv);

    CORBA::Object_var obj=orb->resolve_initial_references("RootPOA");

    assert(!CORBA::is_nil(obj.in()));

    PortableServer::POA_var poa=PortableServer::POA::_narrow(obj.in());

    assert(!CORBA::is_nil(poa.in()));
    
    PortableServer::POAManager_var mgr=poa->the_POAManager();

    CORBA::PolicyList pols;
    pols.length(1);
    pols[0]=poa->create_lifespan_policy(PortableServer::PERSISTENT);

    poa=poa->create_POA("testPOA",mgr.in(),pols);

    mgr->activate();

    HelloServer_impl * server=
      new HelloServer_impl(PortableServer::POA::_duplicate(poa.in()));

    PortableServer::ObjectId_var oid=poa->activate_object(server);

    std::cout<<"ObjectId";

    for(unsigned int i=0;i<oid->length();++i)
      std::cout<<" "<<(int)oid[i];

    std::cout<<std::endl;

    obj=poa->id_to_reference(oid.in());

    std::cout<<orb->object_to_string(obj.in())<<std::endl;

    orb->run();

    orb->destroy();

    return(0);
  }
  catch(CORBA::Exception &e){
    std::cout<<typeid(e).name()<<std::endl;

    return(0);
  }
}

--------------080300070508050202000106--