【问题标题】:MICO CORBA server with corbaloc access具有 corbaloc 访问权限的 MICO CORBA 服务器
【发布时间】:2014-01-22 09:27:52
【问题描述】:

我正在使用 MICO 创建一个 C++ CORBA 服务器。

在我的系统中,客户端应该能够使用 corbaloc 地址(无名称服务)直接访问服务器中的 corba 对象。 你知道MICO是否提供这样的功能吗?我该如何实施?我试过了:

ORB_ptr orb = CORBA::ORB_init (argc, argv, "mico-local-orb");
Object_var obj = orb -> resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj );
PortableServer::POAManager_var pman = poa -> the_POAManager();
pman -> activate();

PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId( "hello" );

HelloImpl* servant = new HelloImpl();

poa -> activate_object_with_id( oid.in(), servant );
servant -> _remove_ref();

orb -> run();

此代码适用于 OMNIORB,但不适用于 MICO。

编辑:我也尝试了持久的生命周期政策,但它也不起作用:

ORB_ptr orb = ORB_init( argc, argv );
Object_var obj = orb -> resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj );
PortableServer::POAManager_var pman = poa -> the_POAManager();
pman -> activate();

PortableServer::LifespanPolicy_var lifespan = 
    poa -> create_lifespan_policy( PortableServer::PERSISTENT );
PortableServer::IdAssignmentPolicy_var idassignment = 
    poa ->  create_id_assignment_policy ( PortableServer::USER_ID );
CORBA::PolicyList policies( 2 );
policies.length( 2 );
policies[0] = PortableServer::IdAssignmentPolicy::_duplicate( idassignment );
policies[1] = PortableServer::LifespanPolicy::_duplicate( lifespan );
PortableServer::POA_var child_poa = 
    poa -> create_POA( "childPOA", pman.in(), policies );
PortableServer::POAManager_var child_pman = child_poa -> the_POAManager();
child_pman -> activate();

idassignment -> destroy();
lifespan -> destroy();

HelloImpl* servant = new HelloImpl();

PortableServer::ObjectId_var oid = child_poa -> activate_object( servant );
CORBA::Object_var ref = child_poa -> id_to_reference( oid.in() );
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId( "hello" );
child_poa -> activate_object_with_id ( oid.in (), servant );

orb -> run();

编辑2: 我用一个尝试string_to_object以下corbaloc地址的客户端测试了服务器:

  • corbaloc:iiop:localhost:12345/hello
  • corbaloc:iiop:localhost:12345/childPOA/hello

但他们都没有工作。我总是收到CORBA::OBJECT_NOT_EXIST 异常。

谢谢

【问题讨论】:

  • @Reimeus 我也尝试了持久寿命策略(我将代码添加到我的问题中)。但它也不起作用。
  • 究竟是什么不起作用,您是如何检查的?
  • @tuergeist 我写了一个客户端,使用ORB::string_to_object解析corbaloc地址corbaloc:iiop:localhost:12345/hello,但是找不到远程对象。
  • 你得到了什么样的异常? Object_not_found / 存在?还是瞬态的?
  • @tuergeist 我得到一个CORBA::OBJECT_NOT_EXIST 异常。

标签: c++ corba


【解决方案1】:

对于 Mico,您还必须在 corbalo url 中使用 poa 层次结构。对于您的示例,corbaloc::localhost:12345/childPOA/hello 应该可以工作。

另见the Diploma thesis of Frank Pilhofer, the implementor of Mico's POA,其中指出

 create a persistent POA with the name ``MyPOA'', and then activate an object 
 using the ``MyObject'' Object Id, you could refer to that object using the IOR

  iioploc://thishost:1234/MyService/MyPOA/MyObject

编辑:您必须使用服务名称-POAImplName MyService 启动您的服务可执行文件

【讨论】:

  • 我尝试了corbaloc::localhost:12345/childPOA/hello,但我总是得到CORBA::OBJECT_NOT_EXIST 异常
  • 成功了,谢谢。我必须用server.exe -ORBIIOPAddr inet:localhost:12345 -POAImplName MyService 启动服务器,用client.exe corbaloc::localhost:12345/MyService/childPOA/hello 启动客户端
猜你喜欢
  • 1970-01-01
  • 2020-04-02
  • 1970-01-01
  • 2015-07-13
  • 1970-01-01
  • 2012-06-14
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多