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


C++ portableserver::POA_ptr类代码示例

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


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

示例1: 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

示例2:

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

示例3: 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

示例4:

void
TAO_Notify_POA_Helper::create_i (
  PortableServer::POA_ptr parent_poa,
  const char* poa_name,
  CORBA::PolicyList &policy_list)
{
  PortableServer::POAManager_var manager =
    parent_poa->the_POAManager ();

  // Create the child POA.
  this->poa_ = parent_poa->create_POA (poa_name, manager.in (), policy_list);

  if (DEBUG_LEVEL > 0)
    {
      CORBA::String_var the_name = this->poa_->the_name ();
      ORBSVCS_DEBUG ((LM_DEBUG, "Created POA : %C\n", the_name.in ()));
    }

  /*
  // Destroy the policies
  for (CORBA::ULong index = 0; index < policy_list.length (); ++index)
    {
      policy_list[index]->destroy ();
    }
  */
}
开发者ID:asdlei00,项目名称:ACE,代码行数:26,代码来源:POA_Helper.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:

PortableServer::POA_ptr
createPOA (PortableServer::POA_ptr root_poa,
           bool share_mgr,
           const char* poa_name)
{
  PortableServer::LifespanPolicy_var life =
    root_poa->create_lifespan_policy(PortableServer::PERSISTENT);

  PortableServer::IdAssignmentPolicy_var assign =
    root_poa->create_id_assignment_policy(PortableServer::USER_ID);

  CORBA::PolicyList pols;
  pols.length(2);
  pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in());
  pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in());

  PortableServer::POAManager_var mgr = PortableServer::POAManager::_nil();
  if (share_mgr)
    {
      mgr = root_poa->the_POAManager();
    }
  PortableServer::POA_var poa =
    root_poa->create_POA(poa_name, mgr.in(), pols);

  life->destroy();
  assign->destroy();

  return poa._retn();
}
开发者ID:asdlei00,项目名称:ACE,代码行数:29,代码来源:server.cpp

示例7:

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

示例8: 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

示例9:

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

示例10: policies

PortableServer::POA_ptr
setup_poa (PortableServer::POA_ptr root_poa)
{
  // Policies for the childPOA to be created.
  CORBA::PolicyList policies (2);
  policies.length (2);

  // Tell the POA to use a servant manager.
  policies[0] =
    root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);

  // Allow implicit activation.
  policies[1] =
    root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION);

  PortableServer::POAManager_var poa_manager =
    root_poa->the_POAManager ();

  // Create POA as child of RootPOA with the above policies.  This POA
  // will use a SERVANT_ACTIVATOR because of RETAIN policy.
  PortableServer::POA_var child_poa =
    root_poa->create_POA ("childPOA",
                          poa_manager.in (),
                          policies);

  // Creation of childPOAs is over. Destroy the Policy objects.
  for (CORBA::ULong i = 0;
       i < policies.length ();
       ++i)
    {
      policies[i]->destroy ();
    }

  return child_poa._retn ();
}
开发者ID:asdlei00,项目名称:ACE,代码行数:35,代码来源:server.cpp

示例11: policies

CORBA::Boolean
ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent,
                              const char *name)
{
  ACE_ASSERT (! CORBA::is_nil(parent));
  ACE_ASSERT (name != 0);
  CORBA::PolicyList policies (3);

  const char *exception_message = "Null Message";
  policies.length (3);
  try
    {
      // Servant Retention Policy
      exception_message = "While PortableServer::POA::create_servant_retention_policy";
      policies[0] =
        parent->create_servant_retention_policy (PortableServer::NON_RETAIN);

      // Request Processing Policy
      exception_message = "While PortableServer::POA::create_request_processing_policy";

      policies[1] =
        parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
      policies[2] =
        parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

      PortableServer::POAManager_var poa_manager =
        parent->the_POAManager ();

      exception_message = "While create_POA";
      PortableServer::POA_var child =
        parent->create_POA (name,
                            poa_manager.in (),
                            policies);

      exception_message = "While policy->destroy";
      for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
          CORBA::Policy_ptr policy = policies[i];
          policy->destroy ();
        }

      exception_message = "While child->the_activator";
      child->the_activator (this);

      exception_message = "While set_servant";
      child->set_servant (this->default_servant_);
    }
  catch (const CORBA::Exception& ex)
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  "IMR_Adapter_Activator::unknown_adapter - %s\n",
                  exception_message));
      ex._tao_print_exception ("System Exception");
      return 0;
    }

  // Finally, now everything is fine
  return 1;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:59,代码来源:Adapter_Activator.cpp

示例12: policies

Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
  register_factories(orb);

  CORBA::Object_var objectman =
    orb->resolve_initial_references ("ORBPolicyManager");

  CORBA::PolicyManager_var policy_manager =
    CORBA::PolicyManager::_narrow (objectman.in ());

  PortableServer::POA_var my_compress_poa = 0;
  CORBA::PolicyList policies(4);
  policies.length(4);

  try
    {
      policies[0] = create_compressor_id_level_list_policy (orb);
      policies[1] = create_low_value_policy (orb);
      policies[2] = create_compression_enabled_policy (orb);
      policies[3] = create_min_ratio_policy (orb);

      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }
  catch(const CORBA::PolicyError&)
    {
      policies.length(0);
      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }

  policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  CORBA::Object_var pcobject =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (pcobject.in ());

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager ();

  Hello *hello_impl = 0;
  ACE_NEW_RETURN (hello_impl,
                  Hello (orb),
                  0);
  PortableServer::ServantBase_var owner_transfer(hello_impl);

  PortableServer::ObjectId_var id =
    my_compress_poa->activate_object (hello_impl);

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

  Test::Hello_var hello = Test::Hello::_narrow (object.in ());

  poa_manager->activate ();

  return hello._retn ();
}
开发者ID:jiaoyk,项目名称:ATCD,代码行数:59,代码来源:server.cpp

示例13: test_add_master_manager

    /*! 
     * @brief tests for is_master(), createINSManager(), findManager(), add_master_manager(), get_master_managers(), remove_master_manager()
     *
     *
     */
    void test_add_master_manager()
    {
      ::RTM::ManagerServant *pman = new ::RTM::ManagerServant();
      RTM::ManagerList* list;
      try
      {
        ::RTC::ReturnCode_t ret;
        CORBA::Boolean cbret;
        cbret = pman->is_master();
        // is_master(), default is false
        CPPUNIT_ASSERT(!cbret);

        // get_master_managers()
        list = pman->get_master_managers();
         CPPUNIT_ASSERT_EQUAL(0, (int)list->length());

        // createINSManager()
        bool bret = pman->createINSManager();
        CPPUNIT_ASSERT(bret);

        bret = pman->createINSManager();
        CPPUNIT_ASSERT(!bret);

        std::string host_port("localhost:2810");
        RTM::Manager_var owner;
        // findManager()
        owner = pman->findManager(host_port.c_str());

        // add_master_manager()
        ret = pman->add_master_manager(owner);
        CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret);
        list = pman->get_master_managers();
         CPPUNIT_ASSERT_EQUAL(1, (int)list->length());

        // remove_master_manager()
        ret = pman->remove_master_manager(RTM::Manager::_duplicate(owner));
        CPPUNIT_ASSERT_EQUAL(RTC::RTC_OK, ret);
        list = pman->get_master_managers();
         CPPUNIT_ASSERT_EQUAL(0, (int)list->length());

        CORBA::Object_var obj;
        obj = m_pORB->resolve_initial_references("omniINSPOA");
        PortableServer::POA_ptr poa = PortableServer::POA::_narrow(obj);
        poa->the_POAManager()->deactivate(false, true);
      }
      catch(CORBA::SystemException& e)
      {
        std::cout << "test_add_master_manager() SystemException: " << e._name() << std::endl;
      }
      catch (...)
      {
        std::cout << "test_add_master_manager() other Exception" << std::endl;
      }

      delete list;
      delete pman;
    }
开发者ID:pansas,项目名称:OpenRTM-aist-portable,代码行数:62,代码来源:ManagerServantTests.cpp

示例14: policies

int
create_POA_and_register_servant (CORBA::Policy_ptr threadpool_policy,
                                 const char *poa_name,
                                 PortableServer::POAManager_ptr poa_manager,
                                 PortableServer::POA_ptr root_poa,
                                 CORBA::ORB_ptr orb,
                                 RTCORBA::RTORB_ptr rt_orb)
{
  // Policies for the firstPOA to be created.
  CORBA::PolicyList policies (3); policies.length (3);

  // Implicit_activation policy.
  policies[0] =
    root_poa->create_implicit_activation_policy
    (PortableServer::IMPLICIT_ACTIVATION);

  // Thread pool policy.
  policies[1] =
    CORBA::Policy::_duplicate (threadpool_policy);

  // Priority Model policy.
  policies[2] =
    rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0);

  // Create the POA under the RootPOA.
  PortableServer::POA_var poa =
    root_poa->create_POA (poa_name,
                          poa_manager,
                          policies);

  // Creation of POAs is over. Destroy the Policy objects.
  for (CORBA::ULong i = 0;
       i < policies.length ();
       ++i)
    {
      policies[i]->destroy ();
    }

  test_i *servant =
    new test_i (orb,
                poa.in (),
                nap_time);

  PortableServer::ServantBase_var safe_servant (servant);
  ACE_UNUSED_ARG (safe_servant);

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

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

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

  int const result = write_ior_to_file (orb, test.in ());

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

示例15:

Test_i::Test_i (CORBA::Short server_num,
                Terminator &terminator,
                PortableServer::POA_ptr pa,
                PortableServer::POA_ptr pb)
  : mgr_a (pa->the_POAManager ()),
    mgr_b (pb->the_POAManager ()),
    server_num_ (server_num),
    terminator_ (terminator)
{
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:10,代码来源:Test_i.cpp


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