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


C++ POA_var::the_POAManager方法代码示例

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


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

示例1: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{

    try {
        // Initialize orb
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

        if (parse_args (argc, argv) != 0)
            return 1;

        //Get reference to Root POA
        CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());

        // Activate POA Manager
        PortableServer::POAManager_var mgr = poa->the_POAManager();
        mgr->activate();

        // Find the Naming Service
        obj = orb->resolve_initial_references("NameService");
        CosNaming::NamingContextExt_var root =
            CosNaming::NamingContextExt::_narrow(obj.in());
        if (CORBA::is_nil(root.in())) {
            std::cerr << "Nil Naming Context reference" << std::endl;
            return 1;
        }

        // Bind a new context.
        CosNaming::Name name;
        name.length( 1 );
        name[0].id = CORBA::string_dup( "root.esc-dot" );
        name[0].kind = CORBA::string_dup( "kind1" );

        try {
            obj = root->resolve(name);
        }
        catch(const CosNaming::NamingContext::NotFound&) {
            CosNaming::NamingContext_var dummy = root->bind_new_context(name);
        }

        name.length( 2 );
        name[1].id = CORBA::string_dup( "leaf/esc-slash" );
        name[1].kind = CORBA::string_dup( "kind2" );

        // Create an object
        PortableServer::Servant_var<Messenger_i> servant = new Messenger_i;
        PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
        CORBA::Object_var messenger_obj = poa->id_to_reference(oid.in());
        root->rebind(name, messenger_obj.in());

        // Also try rebinding to a simple path.
        CosNaming::Name_var simp_name = root->to_name("Simple");
        try {
            obj = root->resolve(simp_name.in());
        }
        catch(const CosNaming::NamingContext::NotFound&) {
            CosNaming::NamingContext_var dummy =
                root->bind_new_context(simp_name.in());
        }
        simp_name = root->to_name("Simple/Messenger");
        root->rebind(simp_name.in(), messenger_obj.in());

        // Convert Name to String Name.
        CORBA::String_var str_name = root->to_string(name);
        std::cout << "str_name:  " << str_name.in() << std::endl;
        CORBA::String_var str_simple = root->to_string(simp_name.in());
        std::cout << "simple: " << str_simple.in() << std::endl;

        // Convert String Name to Name.
        CosNaming::Name_var tname = root->to_name(str_name.in());

        std::cout << "converted back to a CosNaming::Name: " << std::endl;
        std::cout << "   name[0] = " << (* tname)[0].id.in() << " , "
                  << (* tname)[0].kind.in() << std::endl;
        std::cout << "   name[1] = " << (* tname)[1].id.in() << " , "
                  << (* tname)[1].kind.in() << std::endl;

        // Find the application object by resolve_str.
        try {
            obj = root->resolve_str(str_name.in());
        }
        catch(const CosNaming::NamingContext::NotFound&) {
            std::cerr<<"Couldn't resolve the string name:  " << str_name << std::endl;
            return 1;
        }

        ACE_CString base_address (":");
        base_address += ACE_TEXT_ALWAYS_CHAR (hostname);
        base_address += ":";
        base_address += ACE_TEXT_ALWAYS_CHAR (port);
        ACE_CString addr ("");
        addr = base_address + "/key/str";

        // Create an URL string for application object.
        CORBA::String_var address = CORBA::string_dup (addr.c_str());

        std::cout << "call to_url(\"" << address.in() << "\"" << std::endl;
        std::cout << "           ,\"" << str_simple.in() << "\")"<< std::endl;

        CORBA::String_var url_string = root->to_url(address.in(), str_simple.in());
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:ACE-Middleware,代码行数:101,代码来源:MessengerServer.cpp

示例2: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  try {
    // First initialize the ORB, that will remove some arguments...
    CORBA::ORB_var orb =
      CORBA::ORB_init (argc, argv);
    CORBA::Object_var poa_object =
      orb->resolve_initial_references ("RootPOA");
    PortableServer::POA_var poa =
      PortableServer::POA::_narrow (poa_object.in ());
    PortableServer::POAManager_var poa_manager =
      poa->the_POAManager ();
    poa_manager->activate ();

    // Create the servant
    Quoter_Stock_Factory_i stock_factory_i;

    // Activate it to obtain the object reference
    Quoter::Stock_Factory_var stock_factory =
      stock_factory_i._this ();

    // Put the object reference as an IOR string
    CORBA::String_var ior = orb->object_to_string (stock_factory.in ());

    // Print it out!
    cout << ior.in () << endl;

    orb->run ();

    // Destroy the POA, waiting until the destruction terminates
    poa->destroy (1, 1);
    orb->destroy ();
  }
  catch (CORBA::Exception &) {
    cerr << "CORBA exception raised!" << endl;
  }
  return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:38,代码来源:server.cpp

示例3: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  TAO_CEC_Default_Factory::init_svcs ();

  try
    {
      // ORB initialization boiler plate...
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (object.in ());
      PortableServer::POAManager_var poa_manager =
        poa->the_POAManager ();
      poa_manager->activate ();

      // ****************************************************************

      run_test (poa.in (), 0);

      run_test (poa.in (), 1);

      // ****************************************************************

      poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Service");
      return 1;
    }
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:38,代码来源:Shutdown.cpp

示例4: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try{
    orb = CORBA::ORB_init (argc, argv);


    RtecEventChannelAdmin::EventChannel_var channel
      = get_event_channel (argc, argv);


    if (CORBA::is_nil (channel.in ()))
       return -1;

    PortableServer::POA_var poa =
      resolve_init<PortableServer::POA> (orb.in (), "RootPOA");

    PortableServer::POAManager_var mgr = poa->the_POAManager ();

    mgr->activate ();

    PushSupplier_impl push_supplier(orb.in ());
    if (push_supplier.init(channel.in ()) == -1)
      return -1;

    RtecEventComm::PushSupplier_var
      supplier = push_supplier._this();


    orb->run();

  }
  catch (const CORBA::Exception& ex){
      ex._tao_print_exception ("A CORBA Exception occurred.");
  }


  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:38,代码来源:supplier.cpp

示例5: catch

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Initialize orb
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      // Get reference to Root POA.
      CORBA::Object_var obj
        = orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa
        = PortableServer::POA::_narrow (obj.in ());

      // Activate POA manager
      PortableServer::POAManager_var mgr
        = poa->the_POAManager ();
      mgr->activate ();

      // Create an object
      Time_impl time_servant;

      // Write its stringified reference to stdout
      Time_var tm = time_servant._this ();
      CORBA::String_var str = orb->object_to_string (tm.in ());
      cout << str.in () << endl;

      // Accept requests
      orb->run ();
    }
  catch (const CORBA::Exception &)
    {
      cerr << "Uncaught CORBA exception" << endl;
      return 1;
    }
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:37,代码来源:server.cpp

示例6: catch

CORBA::Object_ptr
TAO_Monitor_Init::create_object (CORBA::ORB_ptr orb,
                                 int,
                                 ACE_TCHAR *[])
{
  try
    {
      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

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

      PortableServer::POAManager_var mgr =
        poa->the_POAManager ();

      mgr->activate ();

      Monitor_Impl *servant = 0;
      ACE_NEW_RETURN (servant,
                      Monitor_Impl (orb),
                      CORBA::Object::_nil ());

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

      PortableServer::ServantBase_var safe_servant = servant;
      obj = servant->_this ();

      return obj._retn ();
    }
  catch (const CORBA::Exception&)
    {
    }

  return CORBA::Object::_nil ();
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:37,代码来源:Monitor.cpp

示例7: svc

int NamingTask::svc()
{
  try {
    // Get reference to Root POA
    CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA");
    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());

    // Activate POA Manager
    PortableServer::POAManager_var poaManager = poa->the_POAManager();
    poaManager->activate();

    // Initialize the naming service
    // We are not going to look for other naming servers
    TAO_Naming_Server naming;
    if (naming.init(orb_.in(),
                    poa.in(),
                    ACE_DEFAULT_MAP_SIZE,
                    0,
                    0) == 0) {
      std::cout << "The Naming Service Task is ready." << std::endl;
      initialized_ = true;
      // Accept requests
      orb_->run();
      orb_->destroy();
      return 0;
    }
    else {
      std::cerr << "Unable to initialize the Naming Service." << std::endl;
    }
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "NamingTask::svc() CORBA::Exception: " << ex << std::endl;
  }

  return -1;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:36,代码来源:NamingTask.cpp

示例8: orb

    int
    run() override final
    {
        OrbHelper orb(executable_name_);

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

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

        POA_youtils_test::corba_test_tie<CorbaYoutilsServant>
        corba_youtils_servant(new CorbaYoutilsServant(orb));

        PortableServer::ObjectId_var corba_youtils_servant_id =
            poa->activate_object(&corba_youtils_servant);

        CORBA::Object_var obj1;

        obj1  = corba_youtils_servant._this();
        orb.bindObjectToName(obj1,
                             "context_name",
                             "context_kind",
                             "object_name",
                             "object_kind");


        PortableServer::POAManager_var pman = poa->the_POAManager();
        pman->activate();


        omni_thread::sleep(1);
        orb.orb()->run();

        poa->deactivate_object(corba_youtils_servant_id);

        return 0;
    }
开发者ID:openvstorage,项目名称:volumedriver,代码行数:36,代码来源:corba_youtils_server.cpp

示例9: main


//.........这里部分代码省略.........
         ssl_port = strdup(argv[i+1]);
       }
       if (strcmp(argv[i], "-ORB_ssl_private_key") == 0)
       {
         for (int j = 1; j < argc; j++) {
           if (strcmp(argv[j], "-ORB_ssl_certificate") == 0) {
             ssl_config = true;
             break;
           }
         }
       }
     }
     new_argv[new_argc - 2] = "-ORB_iiop_orb_port";
     new_argv[new_argc - 1] = port;

     int orb_argc     = port_given ? argc : new_argc;
     char ** orb_argv = port_given ? argv : new_argv;

     //
     // ORB initialization
     //
     my_global_orb = CORBA::ORB_init(orb_argc, orb_argv);

     // Get internal ORB 
     TIDorb::core::TIDORB* m_orb = 
       dynamic_cast<TIDorb::core::TIDORB*> (CORBA::ORB::_duplicate(my_global_orb));

     //
     // Getting RootPOA & Manager references
     //
     CORBA::Object_var poa_obj = my_global_orb->resolve_initial_references("RootPOA");
     PortableServer::POA_ptr rootPOA = PortableServer::POA::_narrow(poa_obj);

     PortableServer::POAManager_var manager = rootPOA->the_POAManager();


     //
     // NamingContexts POA creation
     //
     CORBA::PolicyList policies;
     policies.length(4);

     policies[0] = rootPOA->create_servant_retention_policy(PortableServer::RETAIN);
     policies[1] = rootPOA->create_request_processing_policy(
                                                   PortableServer::USE_SERVANT_MANAGER);
     policies[2] = rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
     policies[3] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT);

     PortableServer::POA_var namingContextsPOA = 
       rootPOA->create_POA("namingContextsPOA", manager, policies);

     PortableServer::POAManager_var namingContextsManager = 
       namingContextsPOA->the_POAManager();


     //
     // BindingIterators POA creation
     //
     CORBA::PolicyList bindingIterators_policies;
     bindingIterators_policies.length(2);

     bindingIterators_policies[0] = 
       rootPOA->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL); 
     bindingIterators_policies[1] = 
       rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
开发者ID:AlvaroVega,项目名称:TIDNaming,代码行数:66,代码来源:ns_server.C

示例10: name

int
Consumer::run (int argc, ACE_TCHAR* argv[])
{
  try
    {
      // ORB initialization boiler plate...
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      // Do *NOT* make a copy because we don't want the ORB to outlive
      // the run() method.
      this->orb_ = orb.in ();

      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (object.in ());
      PortableServer::POAManager_var poa_manager =
        poa->the_POAManager ();
      poa_manager->activate ();

      // Obtain the event channel from the naming service
      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      if (CORBA::is_nil (naming_obj.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to get the Naming Service.\n"),
                          1);

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow (naming_obj.in ());

      CosNaming::Name name (1);
      name.length (1);
      name[0].id = CORBA::string_dup ("EventService");

      CORBA::Object_var ec_obj =
        naming_context->resolve (name);

      RtecEventChannelAdmin::EventChannel_var event_channel =
        RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in ());

      // The canonical protocol to connect to the EC
      RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
        event_channel->for_consumers ();

      RtecEventChannelAdmin::ProxyPushSupplier_var supplier =
        consumer_admin->obtain_push_supplier ();

      RtecEventComm::PushConsumer_var consumer =
        this->_this ();

      // Simple subscription, but usually the helper classes in
      // $TAO_ROOT/orbsvcs/Event_Utils.h are a better way to do this.
      RtecEventChannelAdmin::ConsumerQOS qos;
      qos.dependencies.length (2);
      RtecEventComm::EventHeader& h0 =
        qos.dependencies[0].event.header;
      h0.type   = ACE_ES_DISJUNCTION_DESIGNATOR;
      h0.source = ACE_ES_EVENT_SOURCE_ANY;

      RtecEventComm::EventHeader& h1 =
        qos.dependencies[1].event.header;
      h1.type   = ACE_ES_EVENT_UNDEFINED; // first free event type
      h1.source = ACE_ES_EVENT_SOURCE_ANY;

      supplier->connect_push_consumer (consumer.in (), qos);

      // Wait for events, using work_pending()/perform_work() may help
      // or using another thread, this example is too simple for that.
      orb->run ();

      // We don't do any cleanup, it is hard to do it after shutdown,
      // and would complicate the example; plus it is almost
      // impossible to do cleanup after ORB->run() because the POA is
      // in the holding state.  Applications should use
      // work_pending()/perform_work() to do more interesting stuff.
      // Check the supplier for the proper way to do cleanup.
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Consumer::run");
      return 1;
    }
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:87,代码来源:Consumer.cpp

示例11: ecf_name

int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
#if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1)

  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (obj.in ());

      PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
      poa_manager->activate ();

      TAO_Notify_Service* notify_service =
        TAO_Notify_Service::load_default ();

      if (notify_service == 0)
        {
          error ("Unable to load the Notify Service");
        }

      notify_service->init_service (orb.in ());
      ACE_OS::sleep (1);

      const ACE_CString ecf_name ("MonitoringEventChannelFactory");
      CosNotifyChannelAdmin::EventChannelFactory_var ecf =
         notify_service->create (poa.in (), ecf_name.c_str ());
      NotifyMonitoringExt::EventChannelFactory_var monitor_ec_factory =
        NotifyMonitoringExt::EventChannelFactory::_narrow (ecf.in ());

      if (CORBA::is_nil (monitor_ec_factory.in ()))
        {
         error ("Unable to create the Monitoring Event Channel Factory");
        }

      CosNotification::QoSProperties qos_prop;
      CosNotification::AdminProperties admin_prop;
      CosNotifyChannelAdmin::ChannelID id;
      const ACE_CString ec_name ("test1");

      CosNotifyChannelAdmin::EventChannel_var ec =
        monitor_ec_factory->create_named_channel (qos_prop,
                                                  admin_prop,
                                                  id,
                                                  ec_name.c_str ());
      NotifyMonitoringExt::EventChannel_var mec =
        NotifyMonitoringExt::EventChannel::_narrow (ec.in ());

      if (CORBA::is_nil (mec.in ()))
        {
          error ("Unable to narrow the event channel");
        }

      try
        {
          CosNotifyChannelAdmin::ChannelID fake_id;
          CosNotifyChannelAdmin::EventChannel_var fake =
            monitor_ec_factory->create_named_channel (qos_prop,
                                                      admin_prop,
                                                      fake_id,
                                                      "test1");
          error ("Expected a NotifyMonitoringExt::"
                 "NameAlreadyUsed exception");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          // This is expected.
        }

      Monitor_Point_Registry* instance = Monitor_Point_Registry::instance ();
      ACE_CString stat_name =
        ecf_name
        + "/"
        + ACE_CString (NotifyMonitoringExt::InactiveEventChannelCount);

      Monitor_Base* stat = instance->get (stat_name);

      if (stat == 0)
        {
          error ("Could not find InactiveEventChannelCount statistic");
        }

      stat->update ();
      double count = stat->last_sample ();

      if (!ACE::is_equal (count, 1.0))
        {
          error ("Invalid inactive event channel count");
        }

      stat_name =
        ecf_name
        + "/"
        + ACE_CString (NotifyMonitoringExt::ActiveEventChannelCount);

      stat = instance->get (stat_name);

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

示例12: main

int main(int argc, char **argv)
{
    // Removes ORB related arguments
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    // Program options
    std::string register_servant;
    std::string proxy_reference;

    _po::options_description _desc("Proxy Server options");
    _desc.add_options()
        ("help,h", "produce help message")
        ("register-servant,r", _po::value< std::string >(&register_servant),
         "register the servant into the name service")
        ("proxy-reference,p", _po::value< std::string >(&proxy_reference),
         "forward received calls to another servant");

    _po::variables_map _vm;
    _po::store(_po::parse_command_line(argc, argv, _desc), _vm);
    _po::notify(_vm);

    if (_vm.count("help"))
    {
        std::cout << _desc << std::endl;
        return 0;
    }

    bool reference_is_ns_entry = false;
    // TODO

    // Name Service
    CosNaming::NamingContextExt_var nc;

    if (reference_is_ns_entry || !register_servant.empty())
    {
        try {
            CORBA::Object_var ncObj = orb->resolve_initial_references("NameService");

            nc = CosNaming::NamingContextExt::_narrow(ncObj);
        } catch(...) {
        }

        if (CORBA::is_nil(nc))
            std::cerr << "Name service unavailable!" << std::endl;
    }

    // Proxy reference
    prueba::Iface_var reference;

    if (!proxy_reference.empty())
    {
        CORBA::Object_var refObj;

        if (reference_is_ns_entry && !CORBA::is_nil(nc))
            refObj = nc->resolve_str(proxy_reference.c_str());
        else
            refObj = orb->string_to_object(proxy_reference.c_str());

        reference = prueba::Iface::_narrow(refObj);
    }

    // Servant
    prueba_Iface_impl _impl(reference.in());

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

    PortableServer::POA_var rootPOA =
            PortableServer::POA::_narrow(rootPOAObj.in());

    PortableServer::POAManager_var manager = rootPOA->the_POAManager();

    PortableServer::ObjectId_var myObjID =
                rootPOA->activate_object(&_impl);

    CORBA::Object_var obj = rootPOA->servant_to_reference(&_impl);

    // Displaying reference
    CORBA::String_var ref = orb->object_to_string(obj);
    std::cout << ref << std::endl;

    // Registring servant
    CosNaming::Name_var name;

    if (!register_servant.empty() && !CORBA::is_nil(nc))
    {
        name = nc->to_name(register_servant.c_str());

        nc->rebind(name, obj);
    }

    /*PROTECTED REGION ID(prueba_Iface_impl_server::___main) ENABLED START*/
    /*PROTECTED REGION END*/

    // Running
    manager->activate();
    orb->run();

    // Unbinding servant
    if (!CORBA::is_nil(nc) && name)
//.........这里部分代码省略.........
开发者ID:catedrasaes-umu,项目名称:corbasim,代码行数:101,代码来源:prueba_Iface_server.cpp

示例13: schedule_name

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  TAO_EC_Default_Factory::init_svcs ();

  try
    {
      // ORB initialization boiler plate...
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) == -1)
        {
          ACE_ERROR ((LM_ERROR,
                      "Usage: Service [-o IOR_file_name]\n"));
          return 1;
        }

      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA");
      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (object.in ());
      PortableServer::POAManager_var poa_manager =
        poa->the_POAManager ();
      poa_manager->activate ();

      // ****************************************************************

#if 0
      // Obtain a reference to the naming service...
      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow (naming_obj.in ());
#endif /* 0 */

      // ****************************************************************

      // Create an scheduling service
      POA_RtecScheduler::Scheduler* sched_impl = 0;
      if (config_run)
        {
          ACE_NEW_RETURN (sched_impl,
                          RECONFIG_SCHED_TYPE,
                          1);
        }
      else
        {
          ACE_NEW_RETURN (sched_impl,
                          RECONFIG_SCHED_TYPE (configs_size,
                                               configs,
                                               infos_size,
                                               infos,
                                               0, 0,
                                               0),
                          1);
        }

      RtecScheduler::Scheduler_var scheduler =
        sched_impl->_this ();

#if 0
      // Bind the scheduler with the naming service so clients
      // (consumers and suppliers) can resolve it, some (old)
      // implementations of the EC will try to do the same thing
      // (yikes!)
      CosNaming::Name schedule_name (1);
      schedule_name.length (1);
      schedule_name[0].id = CORBA::string_dup ("ScheduleService");
      // Register the servant with the Naming Context....
      naming_context->rebind (schedule_name, scheduler.in ());
#endif /* 0 */

      // ****************************************************************

      TAO_EC_Event_Channel_Attributes attributes (poa.in (),
                                                  poa.in ());
      attributes.scheduler = scheduler.in (); // no need to dup

      TAO_EC_Event_Channel ec_impl (attributes);
      ACE_DEBUG ((LM_DEBUG, "activating EC\n"));
      ec_impl.activate ();
      ACE_DEBUG ((LM_DEBUG, "EC activated\n"));

      RtecEventChannelAdmin::EventChannel_var event_channel =
        ec_impl._this ();

      // ****************************************************************

      // Create a consumer, intialize its RT_Info structures, and
      // connnect to the event channel....

      Consumer consumer_impl;

      RtecScheduler::handle_t consumer_rt_info1 =
        scheduler->create ("consumer_event_1");

      // Let's say that the execution time for event 1 is 2
      // milliseconds...
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:Service.cpp

示例14: worker

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

    if (parse_args (argc, argv) != 0)
    {
      return 1;
    }

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

    ORB_Task worker (orb.in ());
    worker.activate (THR_NEW_LWP | THR_JOINABLE,
                      1);

    PortableServer::POA_var rootPOA =
      PortableServer::POA::_narrow (object.in ());
    PortableServer::POAManager_var poa_manager =
      rootPOA->the_POAManager ();

    CORBA::PolicyList policies (5);
    policies.length (5);

    // Lifespan policy
    policies[0] =
      rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);

    // Servant Retention Policy
    policies[1] =
      rootPOA->create_servant_retention_policy (PortableServer::RETAIN );

    // ID Assignment Policy
    policies[2] =
      rootPOA->create_id_assignment_policy (PortableServer::USER_ID );

    // Request Processing Policy
    policies[3] =
      rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );

    // Threading policy
    policies[4] =
      rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);

    if (server_notify_delay > 0)
    {
      ACE_OS::sleep (server_notify_delay);
      ACE_DEBUG ((LM_DEBUG, "(%P|%t)ServerB Now register with IMR \n"));
    }

    PortableServer::POA_var poa_a = rootPOA->create_POA ("poaB",
        poa_manager.in (),
        policies
        );

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

    Test_Dummy_i* dummy = new Test_Dummy_i();

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId ("Server_B");
    poa_a->activate_object_with_id (oid.in (), dummy);
    CORBA::Object_var dummy_obj = poa_a->id_to_reference(oid.in());
    CORBA::String_var ior =
      orb->object_to_string (dummy_obj.in ());

    poa_manager->activate ();

    // Output the IOR to the <ior_output_file>
    FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
    if (output_file == 0)
      ACE_ERROR_RETURN ((LM_ERROR,
      "Cannot open output file for writing IOR: %s",
      ior_output_file),
      1);
    ACE_OS::fprintf (output_file, "%s", ior.in ());
    ACE_OS::fclose (output_file);

    worker.wait ();

    rootPOA->destroy (1, 1);
    orb->destroy ();
  }
  catch (const CORBA::Exception &ex)
  {
    ex._tao_print_exception ("Exception caught by serverB:");
    return 1;
  }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:100,代码来源:serverB.cpp

示例15: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
    if (parse_args (argc, argv) != 0)
    {
      return 1;
    }

    CORBA::Object_var object =
      orb->resolve_initial_references ("RootPOA");
    PortableServer::POA_var rootPOA =
      PortableServer::POA::_narrow (object.in ());
    PortableServer::POAManager_var poa_manager =
      rootPOA->the_POAManager ();

    CORBA::PolicyList policies (5);
    policies.length (5);

    // Lifespan policy
    policies[0] =
      rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);

    // Servant Retention Policy
    policies[1] =
      rootPOA->create_servant_retention_policy (PortableServer::RETAIN );

    // ID Assignment Policy
    policies[2] =
      rootPOA->create_id_assignment_policy (PortableServer::USER_ID );

    // Request Processing Policy
    policies[3] =
      rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );

    // Threading policy
    policies[4] =
      rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);

    PortableServer::POA_var poa_a = rootPOA->create_POA ("poaA",
        poa_manager.in (),
        policies
        );
    PortableServer::POA_var poa_c = rootPOA->create_POA ("poaC",
        poa_manager.in (),
        policies
        );

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

    Test_Time_i* time = new Test_Time_i();

    PortableServer::ObjectId_var oid =
      PortableServer::string_to_ObjectId ("Server_A");
    poa_a->activate_object_with_id (oid.in (), time);
    CORBA::Object_var time_obj = poa_a->id_to_reference(oid.in());
    CORBA::String_var ior =
      orb->object_to_string (time_obj.in ());

    poa_manager->activate ();

    FILE *output_file = ACE_OS::fopen (pid_file, ACE_TEXT ("w"));
    if (output_file == 0)
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("Cannot open output file for writing IOR: %s\n"),
                         pid_file),
                        1);
    int pid = static_cast<int> (ACE_OS::getpid ());
    ACE_OS::fprintf (output_file, "%d\n", pid);
    ACE_OS::fclose (output_file);

    orb->run ();

    rootPOA->destroy (1, 1);
    orb->destroy ();
  }
  catch (const CORBA::Exception &ex)
  {
    ex._tao_print_exception (ACE_TEXT ("server:"));
    return 1;
  }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:92,代码来源:server.cpp


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