当前位置: 首页>>代码示例>>C++>>正文


C++ POA_ptr::id_to_reference方法代码示例

本文整理汇总了C++中portableserver::POA_ptr::id_to_reference方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_ptr::id_to_reference方法的具体用法?C++ POA_ptr::id_to_reference怎么用?C++ POA_ptr::id_to_reference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在portableserver::POA_ptr的用法示例。


在下文中一共展示了POA_ptr::id_to_reference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PingReceiver

void
LiveEntry::do_ping (PortableServer::POA_ptr poa)
{
  this->callback_ = new PingReceiver (this, poa);
  PortableServer::ObjectId_var oid = poa->activate_object (this->callback_.in());
  CORBA::Object_var obj = poa->id_to_reference (oid.in());
  ImplementationRepository::AMI_ServerObjectHandler_var cb =
    ImplementationRepository::AMI_ServerObjectHandler::_narrow (obj.in());
  {
    ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
    this->liveliness_ = LS_PING_AWAY;
  }
  try
    {
      this->ref_->sendc_ping (cb.in());
      if (ImR_Locator_i::debug () > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
                          ACE_TEXT ("sendc_ping returned OK\n")));
        }
    }
  catch (const CORBA::Exception &ex)
    {
      if (ImR_Locator_i::debug () > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
                          ACE_TEXT ("sendc_ping threw %C\n"), ex._name()));
        }
      this->status (LS_DEAD);
    }
}
开发者ID:akostrikov,项目名称:ATCD,代码行数:33,代码来源:LiveCheck.cpp

示例2: INTERNAL

void
activate (T & obj_ref,
          PortableServer::POA_ptr poa,
          PortableServer::ServantBase * servant,
          TAO_EC_Object_Deactivator & suggested_object_deactivator)
{
  // Activate the servant into the POA.
  PortableServer::ObjectId_var obj_id =
    poa->activate_object (servant);

  suggested_object_deactivator.set_values (poa, obj_id.in ());

  // Get the object reference of the activated object.
  CORBA::Object_var obj =
    poa->id_to_reference (obj_id.in ());

  // Don't try to use T::_obj_type::_narrow, some compilers don't like it so
  // do this in two steps
  typedef typename T::_obj_type my_object_type;

  obj_ref =
    my_object_type::_narrow (obj.in());

  if (CORBA::is_nil (obj_ref.in ()))
  {
    throw CORBA::INTERNAL ();
  }
}
开发者ID:CCJY,项目名称:ATCD,代码行数:28,代码来源:EC_Lifetime_Utils_T.cpp

示例3:

void
test_reference_to_servant_active_object(PortableServer::POA_ptr root_poa)
{
  test_i test;
  CORBA::ULong expected_refcount = 1;

  PortableServer::ObjectId_var id =
    root_poa->activate_object (&test);
  expected_refcount++;

  CORBA::Object_var object =
    root_poa->id_to_reference (id.in ());

  PortableServer::ServantBase_var servant =
    root_poa->reference_to_servant (object.in ());
  ++expected_refcount;

  root_poa->deactivate_object (id.in ());
  --expected_refcount;

  CORBA::ULong refcount =
    test._refcount_value ();

  ACE_UNUSED_ARG (refcount);
  ACE_UNUSED_ARG (expected_refcount);
  ACE_ASSERT (expected_refcount == refcount);
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:27,代码来源:Default_Servant.cpp

示例4:

int
create_object (PortableServer::POA_ptr poa,
               CORBA::ORB_ptr orb,
               Test_i *server_impl,
               const ACE_TCHAR *filename)
{
  // Register with poa.
  PortableServer::ObjectId_var id =
    poa->activate_object (server_impl);


  CORBA::Object_var server =
    poa->id_to_reference (id.in ());

  // Print out the IOR.
  CORBA::String_var ior =
    orb->object_to_string (server.in ());

  ACE_DEBUG ((LM_DEBUG, "<%C>\n\n", ior.in ()));

  // Print ior to the file.
  if (filename != 0)
    {
      FILE *output_file= ACE_OS::fopen (filename, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           filename),
                          -1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }

  return 0;
}
开发者ID:manut,项目名称:TAO,代码行数:35,代码来源:server.cpp

示例5: catch

CosNotifyFilter::FilterFactory_ptr
TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
  this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa);

  CORBA::Object_var object = CORBA::Object::_nil();
  try
    {
      PortableServer::ObjectId_var id = filter_poa->activate_object (this);
      object = filter_poa->id_to_reference (id.in());
    }
  catch (PortableServer::POA::ServantAlreadyActive&)
    {
      try
        {
          object = filter_poa->servant_to_reference (this);
        }
      catch (CORBA::Exception& )
        {
         return CosNotifyFilter::FilterFactory::_nil();
        }
    }

  return  CosNotifyFilter::FilterFactory::_narrow (object.in ());
}
开发者ID:binary42,项目名称:OCI,代码行数:25,代码来源:ETCL_FilterFactory.cpp

示例6:

int
make_ior (CORBA::ORB_ptr orb,
          PortableServer::POA_ptr poa,
          Hello * servant,
          const ACE_TCHAR *ior_file)
{
  CORBA::String_var poa_name = poa->the_name();
  ACE_DEBUG ((LM_DEBUG, "Creating IOR from %C\n", poa_name.in()));

  PortableServer::ObjectId_var oid = poa->activate_object (servant);
  CORBA::Object_var o = poa->id_to_reference (oid.in ());


  if (host_form == from_hostname || host_form == use_localhost)
    {
      CORBA::String_var ior =
        orb->object_to_string (o.in ());

      FILE *output_file= ACE_OS::fopen (ior_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file %s for writing IOR: %C",
                           ior_file,
                           ior.in ()),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }
  return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:30,代码来源:server.cpp

示例7: TestException

Callback_ptr
ServerApp::create_callback(
    PortableServer::POA_ptr poa,
    const char* servant_name)
{
    PortableServer::ServantBase_var servant
        = new Callback_i();

    PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId("callback");

    poa->activate_object_with_id(id.in(), servant.in());

    CORBA::Object_var obj = poa->id_to_reference(id.in());

    if (CORBA::is_nil(obj.in()))
    {
        ACE_ERROR((LM_ERROR,
                   "(%P|%t) Failed to activate servant (%s).\n",
                   servant_name));
        throw TestException();
    }

    Callback_var callback = Callback::_narrow (obj.in ());

    return callback._retn ();
}
开发者ID:akostrikov,项目名称:ATCD,代码行数:27,代码来源:ServerApp.cpp

示例8:

CosNaming::NamingContext_ptr
getNamingContextReference(
      PortableServer::POA_ptr poa,
      const char * oid)
{
  PortableServer::ObjectId_var id =
    PortableServer::string_to_ObjectId(oid);

  CORBA::Object_var obj = poa->id_to_reference(id);

  return CosNaming::NamingContext::_narrow(obj);
}
开发者ID:AlvaroVega,项目名称:TIDNaming,代码行数:12,代码来源:ns_server.C

示例9:

CosNotifyFilter::FilterFactory_ptr
TAO_Notify_Tests_RT_Test_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
  this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); // save the filter poa.

  PortableServer::ObjectId_var id = filter_poa->activate_object (this);

  CORBA::Object_var object = filter_poa->id_to_reference (id.in ());

  CosNotifyFilter::FilterFactory_var filter = CosNotifyFilter::FilterFactory::_narrow (object.in ());

  return filter._retn();
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:13,代码来源:RT_Test_FilterFactory.cpp

示例10:

void
create_object (PortableServer::POA_ptr poa,
               CORBA::ORB_ptr orb,
               PortableServer::Servant servant,
               const ACE_TCHAR *filename)
{
  // Register with poa.
  PortableServer::ObjectId_var id =
    poa->activate_object (servant);

  CORBA::Object_var object =
    poa->id_to_reference (id.in ());

  CORBA::String_var ior =
    orb->object_to_string (object.in ());

  FILE *output_file= ACE_OS::fopen (filename, "w");
  ACE_OS::fprintf (output_file, "%s", ior.in ());
  ACE_OS::fclose (output_file);
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:20,代码来源:server.cpp

示例11:

void
ReconnectionCallback_i::init (
  PortableServer::POA_ptr poa,
  CosNotifyChannelAdmin::EventChannelFactory_ptr ecf)
{
  this->ecf_ = CosNotifyChannelAdmin::EventChannelFactory::_duplicate (ecf);
  PortableServer::ObjectId_var reconnection_callback_id =
    poa->activate_object (this);

  CORBA::Object_var obj =
    poa->id_to_reference (reconnection_callback_id.in ());

  NotifyExt::ReconnectionCallback_var callback =
    NotifyExt::ReconnectionCallback::_narrow (obj.in ());

  NotifyExt::ReconnectionRegistry_var registry =
    NotifyExt::ReconnectionRegistry::_narrow (ecf);

  this->callback_id_ = registry->register_callback (callback.in ());
  this->id_is_valid_ = true;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:21,代码来源:Supplier.cpp

示例12: servant

void
test_poas (CORBA::ORB_ptr orb,
           PortableServer::POA_ptr root_poa,
           PortableServer::POA_ptr first_poa,
           PortableServer::POA_ptr second_poa,
           PortableServer::POA_ptr third_poa,
           PortableServer::POA_ptr forth_poa,
           int perform_deactivation_test)
{
  {
    test_i servant (root_poa);

    CORBA::Object_var obj = root_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = root_poa->reference_to_id (obj.in ());

    root_poa->activate_object_with_id (id.in (),
                                       &servant);

    obj = root_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      root_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      root_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = root_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = root_poa->servant_to_id (&servant);

    ACE_ASSERT (id_from_servant.in () == id.in ());

    root_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        root_poa->activate_object_with_id (id.in (),
                                           &servant);

        servant_from_reference = root_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        root_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (root_poa);

    PortableServer::ObjectId_var id = root_poa->activate_object (&servant);

    CORBA::Object_var obj = root_poa->id_to_reference (id.in ());

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = root_poa->create_reference_with_id (id.in (),
                                              "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    root_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (first_poa);

    CORBA::Object_var obj = first_poa->create_reference ("IDL:test:1.0");

//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:Identity.cpp

示例13: TestException

void
FooServantList::create_and_activate(CORBA::ORB_ptr orb,
                                    PortableServer::POA_ptr poa)
{
  poa_ = PortableServer::POA::_duplicate (poa);

  for (unsigned i = 0; i < this->num_servants_; i++)
    {
      ACE_TCHAR buf[32];
      ACE_OS::sprintf(buf, ACE_TEXT("%02d"), i + 1);
      ACE_TString servant_name = this->prefix_ + ACE_TEXT("_") + buf;

      this->servants_[i] = new Foo_i(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str()),this);
      this->safe_servants_[i] = this->servants_[i];

      PortableServer::ObjectId_var id =
                    PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str()));

      poa->activate_object_with_id(id.in(),
                                   this->safe_servants_[i].in());

      CORBA::Object_var obj = poa->id_to_reference(id.in());

      if (CORBA::is_nil(obj.in()))
        {
          ACE_ERROR((LM_ERROR,
                     "(%P|%t) Failed to activate servant (%s).\n",
                     servant_name.c_str()));
          throw TestException();
        }

      // create the collocated object reference.
      if (this->collocated_test_ && i == 0)
        {
          Foo_var collocated = Foo::_narrow (obj.in ());

          // Create the servant object.
          Callback_i* servant = new Callback_i ();

          // local smart pointer variable to deal with releasing the reference
          // to the servant object when the smart pointer object falls out of scope.
          PortableServer::ServantBase_var safe_servant(servant);

          PortableServer::ObjectId_var id =
            PortableServer::string_to_ObjectId("callback");

          poa->activate_object_with_id(id.in(), safe_servant.in());

          CORBA::Object_var obj = poa->id_to_reference(id.in());

          if (CORBA::is_nil(obj.in()))
            {
              ACE_ERROR((LM_ERROR,
                        "(%P|%t) Failed to activate servant (%s).\n",
                        servant_name.c_str()));
              throw TestException();
            }

          Callback_var callback
            = Callback::_narrow (obj.in ());

          collocated_client_
            = new ClientTask(orb, collocated.in (), callback.in (), true);
          if (collocated_client_->open() != 0)
            {
              ACE_ERROR((LM_ERROR,
                "(%P|%t) Failed to open the collocated client.\n"));
              throw TestException();
            }
        }

      CORBA::String_var ior
        = this->orb_->object_to_string(obj.in());

      ACE_TString filename = servant_name + ACE_TEXT(".ior");
      FILE* ior_file = ACE_OS::fopen(filename.c_str(), "w");

      if (ior_file == 0)
        {
          ACE_ERROR((LM_ERROR,
                     "(%P|%t) Cannot open output file (%s) for writing IOR.",
                     filename.c_str()));
          throw TestException();
        }
      else
        {
          ACE_DEBUG((LM_DEBUG,
                     "(%P|%t) writing IOR to file %s\n",
                     filename.c_str()));
        }
      ACE_OS::fprintf(ior_file, "%s", ior.in());
      ACE_OS::fclose(ior_file);
    }
}
开发者ID:asdlei00,项目名称:ACE,代码行数:94,代码来源:FooServantList.cpp

示例14: payload

int
run_buffer_size (CORBA::ORB_ptr orb,
                 PortableServer::POA_ptr root_poa,
                 Test::AMI_Buffering_ptr ami_buffering,
                 Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
  TAO::BufferingConstraint buffering_constraint;
  buffering_constraint.mode = TAO::BUFFER_MESSAGE_BYTES;
  buffering_constraint.message_count = 0;
  buffering_constraint.message_bytes = BUFFER_SIZE;
  buffering_constraint.timeout = 0;

  Test::AMI_Buffering_var flusher;
  int test_failed =
    configure_policies (orb, buffering_constraint,
                        ami_buffering, flusher.out ());

  if (test_failed != 0)
    return test_failed;

  Test::Payload payload (PAYLOAD_LENGTH);
  payload.length (PAYLOAD_LENGTH);

  Reply_Handler *reply_handler_impl;
  ACE_NEW_RETURN (reply_handler_impl,
                  Reply_Handler,
                  1);
  PortableServer::ServantBase_var owner_transfer(reply_handler_impl);

  PortableServer::ObjectId_var id =
    root_poa->activate_object (reply_handler_impl);

  CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

  Test::AMI_AMI_BufferingHandler_var reply_handler =
    Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());

  CORBA::ULong bytes_sent = 0;
  for (int i = 0; i != iterations; ++i)
    {
      sync_server (orb, flusher.in ());

      CORBA::ULong initial_bytes_received =
        ami_buffering_admin->bytes_received_count ();

      if (initial_bytes_received != bytes_sent)
        {
          test_failed = 1;
          ACE_DEBUG ((LM_DEBUG,
                      "DEBUG: Iteration %d data lost (%u != %u)\n",
                      i, initial_bytes_received, bytes_sent));
        }

      while (1)
        {
          ami_buffering->sendc_receive_data (reply_handler.in (),
                                             payload);
          bytes_sent += PAYLOAD_LENGTH;

          CORBA::ULong bytes_received =
            ami_buffering_admin->bytes_received_count ();

          ACE_Time_Value tv (0, 10 * 1000);
          orb->run (tv);

          CORBA::ULong payload_delta =
            bytes_sent - initial_bytes_received;
          if (bytes_received != initial_bytes_received)
            {
              // The queue has been flushed, check that enough data
              // has been sent.  The check cannot be precise because
              // the ORB counts the GIOP message overhead, in this
              // test we assume the overhead to be less than 10%

              if (payload_delta < CORBA::ULong (GIOP_OVERHEAD * BUFFER_SIZE))
                {
                  test_failed = 1;
                  ACE_DEBUG ((LM_DEBUG,
                              "DEBUG: Iteration %d flush before "
                              "minimum buffer size was reached. "
                              "Sent = %u, Minimum buffer = %u bytes\n",
                              i,
                              payload_delta, BUFFER_SIZE));
                }
              break;
            }

          if (payload_delta > 2 * BUFFER_SIZE)
            {
              test_failed = 1;
              ACE_DEBUG ((LM_DEBUG,
                          "DEBUG: Iteration %d no flush past "
                          "buffer size threshold. "
                          "Sent = %u, Minimum buffer = %u bytes\n",
                          i,
                          payload_delta, BUFFER_SIZE));
              break;
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:client.cpp

示例15: catch

void
test_object_deactivation (PortableServer::POA_ptr poa,
                          const PortableServer::ObjectId &id)
{
  test_i servant;
  int expected_exception_raised = 0;

  PortableServer::ObjectId_var invalid_id =
    PortableServer::string_to_ObjectId ("invalid id");

  try
    {
      poa->deactivate_object (invalid_id.in ());
    }
  catch (const PortableServer::POA::ObjectNotActive& )
    {
      // This is the correct exception! Ignore
      expected_exception_raised = 1;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "Exception caught of incorrect type");
      ACE_ASSERT (0);
    }

  // Make sure an exception was raised and it was of the correct
  // type.
  ACE_ASSERT (expected_exception_raised);



  poa->activate_object_with_id (id,
                                &servant);

  poa->deactivate_object (id);

  // Reset flag
  expected_exception_raised = 0;

  try
    {
      poa->deactivate_object (id);
    }
  catch (const PortableServer::POA::ObjectNotActive& )
    {
      // This is the correct exception! Ignore
      expected_exception_raised = 1;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "Exception caught of incorrect type");
      ACE_ASSERT (0);
    }

  // Make sure an exception was raised and it was of the correct
  // type.
  ACE_ASSERT (expected_exception_raised);

  poa->activate_object_with_id (id,
                                &servant);

  servant.poa_ =
    PortableServer::POA::_duplicate (poa);

  servant.id_ = id;

  CORBA::Object_var object = poa->id_to_reference (id);

  test_var test =
    test::_narrow (object.in ());

  test->deactivate_self ();

  // ACE_ASSERT dissappears in non-debug builds
  ACE_UNUSED_ARG (expected_exception_raised);

}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:79,代码来源:Excessive_Object_Deactivations.cpp


注:本文中的portableserver::POA_ptr::id_to_reference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。