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


C++ ORB_ptr::register_initial_reference方法代码示例

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


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

示例1: test_orb

int test_orb (CORBA::ORB_ptr orb)
{
    int errors = 0;

    POA_TestModule::test* test = 0;
    ACE_NEW_RETURN (test,
                    test_i, 1);
    PortableServer::ServantBase_var safe (test);

    CORBA::Object_var object = test->_this ();

    orb->register_initial_reference ("ORBMyService",
                                     object.in ());

    bool invalid_name = false;
    try
    {
        // Registering with an empty string should give an exception
        orb->register_initial_reference ("",
                                         object.in ());
    }
    catch (const CORBA::ORB::InvalidName&)
    {
        invalid_name = true;
    }
    catch (const CORBA::Exception&)
    {
    }

    if (!invalid_name)
    {
        errors++;
        ACE_ERROR ((LM_ERROR, "ERROR: Registering with an empty string with the ORB"
                    "doesn't throw an exception\n"));
    }

    bool duplicate_name = false;
    try
    {
        // Registering with an duplicate string should give an exception
        orb->register_initial_reference ("ORBMyService",
                                         object.in ());
    }
    catch (const CORBA::ORB::InvalidName&)
    {
        duplicate_name = true;
    }
    catch (const CORBA::Exception&)
    {
    }

    if (!duplicate_name)
    {
        errors++;
        ACE_ERROR ((LM_ERROR, "ERROR: Registering with a duplicate with ORB "
                    "doesn't throw the expected exception\n"));
    }

    bool invalid_object = false;
    try
    {
        // Registering with a nil object
        orb->register_initial_reference ("ORBNilServer",
                                         CORBA::Object::_nil());
    }
    catch (const CORBA::BAD_PARAM& ex)
    {
        if ((ex.minor() & 0xFFFU) == 27)
        {
            invalid_object = true;
        }
    }
    catch (const CORBA::Exception&)
    {
    }

    if (!invalid_object)
    {
        errors++;
        ACE_ERROR ((LM_ERROR, "ERROR: Registering with a nil object to ORB "
                    "doesn't throw bad param with minor code 27\n"));
    }

    return errors;
}
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:85,代码来源:server.cpp

示例2: directory


//.........这里部分代码省略.........
                          -1);

          if (this->context_index_->open (persistence_location,
                                          base_addr) == -1
              || this->context_index_->init (context_size) == -1)
            {
              if (TAO_debug_level >0)
                ORBSVCS_DEBUG ((LM_DEBUG,
                            "TAO_Naming_Server: context_index initialization failed\n"));
              return -1;
            }

          // Set the root Naming Context reference.
          this->naming_context_ =
            this->context_index_->root_context ();
        }
      else
#endif /* CORBA_E_MICRO */
        {
          //
          // Initialize Transient Naming Service.
          //
          this->naming_context_ =
            TAO_Transient_Naming_Context::make_new_context (poa,
                                                            TAO_ROOT_NAMING_CONTEXT,
                                                            context_size);

        }

#if !defined (CORBA_E_MICRO)
      // Register with the ORB's resolve_initial_references()
      // mechanism.  Primarily useful for dynamically loaded Name
      // Services.
      orb->register_initial_reference ("NameService",
                                       this->naming_context_.in ());
#endif /* CORBA_E_MICRO */

      // Set the ior of the root Naming Context.
      this->naming_service_ior_=
        orb->object_to_string (this->naming_context_.in ());

      CORBA::Object_var table_object =
        orb->resolve_initial_references ("IORTable");

      IORTable::Table_var adapter =
        IORTable::Table::_narrow (table_object.in ());
      if (CORBA::is_nil (adapter.in ()))
        {
          ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
        }
      else
        {
          CORBA::String_var ior =
            orb->object_to_string (this->naming_context_.in ());
          adapter->bind ("NameService", ior.in ());
        }

#if defined (ACE_HAS_IP_MULTICAST)
      if (enable_multicast)
        {
          // @@ Marina: is there anyway to implement this stuff
          // without using ORB_Core_instance()? For example can you
          // pass the ORB as an argument?

          //
          // Install ior multicast handler.
开发者ID:CCJY,项目名称:ATCD,代码行数:67,代码来源:Naming_Server.cpp


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