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


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

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


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

示例1: ACE_TMAIN

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

    const ACE_TCHAR *ecname = ACE_TEXT ("EventService");
    for (int i = 0; argv[i] != 0; i++) {
      if (ACE_OS::strcmp (argv[i], ACE_TEXT ("-ecname")) == 0) {
        if (argv[i+1] != 0) {
          ecname = argv[i+1];
        } else {
    ACE_ERROR ((LM_ERROR,
          "Missing Event channel name\n"));
        }
      }
    }

    // Find the Naming Service.
    CORBA::Object_var obj = orb->resolve_initial_references("NameService");
    CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(obj.in());

    // Find the EchoEventChannel.
    obj = root_context->resolve_str (ACE_TEXT_ALWAYS_CHAR (ecname));

    // Downcast the object reference to an EventChannel reference.
    RtecEventChannelAdmin::EventChannel_var ec =
      RtecEventChannelAdmin::EventChannel::_narrow(obj.in());
    if (CORBA::is_nil(ec.in())) {
      ACE_ERROR_RETURN ((LM_ERROR,
       "Could not narrow EchoEventChannel.\n"),
      1);
    }
    ACE_DEBUG ((LM_DEBUG,
    "EchoEventConsumerMain.cpp: Found the EchoEventChannel.\n"));

    // Obtain a reference to the consumer administration object.
    RtecEventChannelAdmin::ConsumerAdmin_var admin = ec->for_consumers();

    // Obtain a reference to the push supplier proxy.
    RtecEventChannelAdmin::ProxyPushSupplier_var supplier =
      admin->obtain_push_supplier();

    // Get the RootPOA.
    obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());

    // Instantiate an EchoEventConsumer_i servant.
    EchoEventConsumer_i servant(orb.in(), EVENT_LIMIT);

    // Register it with the RootPOA.
    PortableServer::ObjectId_var oid = poa->activate_object(&servant);
    CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in());
    RtecEventComm::PushConsumer_var consumer =
      RtecEventComm::PushConsumer::_narrow(consumer_obj.in());

    // Connect as a consumer.
    ACE_ConsumerQOS_Factory qos;
    qos.start_disjunction_group ();
    qos.insert (MY_SOURCE_ID,   // Source ID
                MY_EVENT_TYPE,  // Event Type
                0);             // handle to the rt_info
    supplier->connect_push_consumer (consumer.in (),
                                     qos.get_ConsumerQOS ());

    // Activate the POA via its POAManager.
    PortableServer::POAManager_var poa_manager = poa->the_POAManager();
    poa_manager->activate();

    ACE_DEBUG ((LM_DEBUG,
    "EchoEventConsumerMain.cpp: Ready to receive events...\n"));

    // Enter the ORB event loop.
    orb->run();

    // If we have reached this, we must be shutting down...
    // Disconnect the ProxyPushSupplier.
    //supplier->disconnect_push_supplier();
    //supplier = RtecEventChannelAdmin::ProxyPushSupplier::_nil();
    //admin = RtecEventChannelAdmin::ConsumerAdmin::_nil();

    orb->destroy();

    return 0;

  }
  catch (const CORBA::Exception& exc)
  {
    ACE_ERROR ((LM_ERROR,
    "Caught CORBA::Exception\n%C (%C)\n",
    exc._name (),
    exc._rep_id () ));
  }

  return 1;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:97,代码来源:EchoEventConsumerMain.cpp

示例2: main


//.........这里部分代码省略.........
//                                   0,0,0));

//     initial_qos[6].name = CORBA::string_dup("Timeout");
//     initial_qos[6].value <<= (TimeBase::TimeT)TIDorb::core::util::Time::currentTimeMillis();

//     initial_qos[7].name = CORBA::string_dup("StartTimeSupported");
//     initial_qos[7].value <<= (CORBA::Boolean) 0;

//     initial_qos[8].name = CORBA::string_dup("StopTimeSupported");
//     initial_qos[8].value <<= (CORBA::Boolean) 1;

    //
    // Politicas de QoS no soportadas
    //

    // initial_qos[0].name = CORBA::string_dup("DiscardPolicy");
    // initial_qos[0].value <<= CosNotification::AnyOrder; // Any Fifo Priority Deadline

    // initial_qos[7].name = CORBA::string_dup("MaximumBatchSize");
    // initial_qos[7].value <<= (CORBA::Long) 20;

    // initial_qos[0].name = CORBA::string_dup("PacingInterval");
    // initial_qos[0].value <<= (TimeBase::TimeT)TIDorb::core::util::Time::currentTimeMillis();

    // initial_qos[9].name = CORBA::string_dup("MaxEventsPerConsumer");
    // initial_qos[9].value <<= (CORBA::Long) 20;


    try { 
      // Crear el canal
      channel = factory->get_event_channel(0);

//       for(int i=0; i < 10; i++){
//         channelv[i] = factory->create_channel(initial_qos, initial_admin, idv[i]);
//       }
    } catch (CosNotifyChannelAdmin::ChannelNotFound &ex) { 
      cerr << "[server_consumer] CosNotifyChannelAdmin::ChannelNotFound: " << ex._name(); 
      return -1; 
    }
    /**************************************************************************/
    /*              OBTENEMOS EL CONSUMERADMIN POR DEFECTO                    */
    /**************************************************************************/
    CosNotifyChannelAdmin::ConsumerAdmin_ptr consumerAdmin;
    consumerAdmin = channel->default_consumer_admin();
   
    //Metemos los filtros en el consumer admin
    CosNotifyFilter::Filter* filter_II = create_filter(channel,"GSyC","test","$domain_name != 'GSyC'");
    //consumerAdmin->add_filter(filter_II);
    //CosNotifyFilter::Filter* filter_III = create_filter(channel,"GSyC","test","$.remainder_of_boy.campo_uno != 1");
    //consumerAdmin->add_filter(filter_III);
   /**************************************************************************/
   /*         OBTENEMOS EL PROXYSUPPLIER APARTIR DEL CONSUMERADMIN           */
   /**************************************************************************/
    //TODO_MORFEO: add new filters
    CosNotifyChannelAdmin::ProxySupplier_ptr proxySupplier;
    CosNotifyChannelAdmin::ProxyID proxySupplierID = 1;
    proxySupplier = 
      consumerAdmin->obtain_notification_push_supplier(CosNotifyChannelAdmin::ANY_EVENT,
                                                      proxySupplierID);

                                                      

   /**************************************************************************/
   /*       OBTENEMOS EL PROXYPUSHSUPPLIER APARTIR DEL CONSUMERADMIN         */
   /**************************************************************************/
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_ptr proxyPushSupplier;
    
    proxyPushSupplier = CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(proxySupplier);



    /**************************************************************************/
    /*            INSTANCIAMOS LOS PROXYS Y LOS ACTIVAMOS EN EL POA           */
    /**************************************************************************/
    my_push_consumer * my_consumer = new my_push_consumer(orb_ptr,proxyPushSupplier);
    PortableServer::ObjectId_ptr consumer_objectID = PortableServer::string_to_ObjectId("My_Consumer:1.0");
    consumerPOA->activate_object_with_id(*consumer_objectID,my_consumer);
    poa_manager->activate();
    CORBA::Object_ptr obj_consumer = consumerPOA->id_to_reference(*consumer_objectID);
    CosNotifyComm::StructuredPushConsumer_ptr my_pushConsumer = CosNotifyComm::StructuredPushConsumer::_narrow(obj_consumer);


    /***********************************************************************/
    /*                CONECTAMOS EL PUSHSUPPLIER Y EL PUSHCONSUMER         */
    /***********************************************************************/
    proxyPushSupplier->connect_structured_push_consumer(my_pushConsumer);


    orb_ptr->run();
 
    
  }
  catch (CORBA::Exception & e)
  {
    cerr<<"[Test_Filter] unknown error"<< typeid(e).name() << e._name();
   return -1;
   
  }

}
开发者ID:AlvaroVega,项目名称:TIDNotifC,代码行数:101,代码来源:server_consumer.C

示例3: supplierecname

int
Gateway::run (int argc, ACE_TCHAR* argv[])
{
    TAO_EC_Gateway_IIOP_Factory::init_svcs ();

    try
    {
        // First parse our command line options
        if (this->parse_args(argc, argv) != 0)
        {
            return -1;
        }

        // 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 ();

        // 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 supplierecname (1);
        supplierecname.length (1);
        supplierecname[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(supplierec));

        CORBA::Object_var supplierec_obj =
            naming_context->resolve (supplierecname);

        CosNaming::Name consumerecname (1);
        consumerecname.length (1);
        consumerecname[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(consumerec));

        CORBA::Object_var consumerec_obj =
            naming_context->resolve (consumerecname);

        RtecEventChannelAdmin::EventChannel_var supplier_event_channel =
            RtecEventChannelAdmin::EventChannel::_narrow (supplierec_obj.in ());

        if (CORBA::is_nil (supplier_event_channel.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to get the supplier event channel.\n"),
                              1);

        RtecEventChannelAdmin::EventChannel_var consumer_event_channel =
            RtecEventChannelAdmin::EventChannel::_narrow (consumerec_obj.in ());

        if (CORBA::is_nil (consumer_event_channel.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Unable to get the consumer event channel.\n"),
                              1);

        TAO_EC_Gateway_IIOP gateway;

        gateway.init(supplier_event_channel.in(), consumer_event_channel.in());

        PortableServer::ObjectId_var gateway_oid =
            poa->activate_object(&gateway);

        CORBA::Object_var gateway_obj =
            poa->id_to_reference(gateway_oid.in());

        RtecEventChannelAdmin::Observer_var obs =
            RtecEventChannelAdmin::Observer::_narrow(gateway_obj.in());

        RtecEventChannelAdmin::Observer_Handle local_ec_obs_handle =
            consumer_event_channel->append_observer (obs.in ());

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

        consumer_event_channel->remove_observer (local_ec_obs_handle);

        poa->deactivate_object (gateway_oid.in ());

        // Destroy the POA
        poa->destroy (1, 0);
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Gateway::run");
        return 1;
    }

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

示例4:

int
Collocation_Test::init (int argc, ACE_TCHAR *argv[])
{
  // Initialize the ORB.
  this->orb_ = CORBA::ORB_init (argc, argv);

  int result = this->parse_args (argc, argv);
  if (result != 0)
    return result;

  // Get an Object reference to RootPOA.
  CORBA::Object_var obj =
    this->orb_->resolve_initial_references ("RootPOA");

  // Narrow the Object reference to a POA reference
  this->root_poa_ =
    PortableServer::POA::_narrow (obj.in ());

  // Get the POAManager of RootPOA
  this->poa_manager_ =
    this->root_poa_->the_POAManager ();

  // Create our own child POA
  // Empty sequence means all default policies
  int nPolicies = 0;
  CORBA::PolicyList policies;

  policies.length(1);
  policies[nPolicies++] =
    this->root_poa_->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION);

  obj = this->root_poa_->create_POA("child", this->poa_manager_.in(), policies);
  PortableServer::POA_var childPOA = PortableServer::POA::_narrow (obj.in ());

  // Destroy the Policy objects (before we may exit as a result of failures)
  for (CORBA::ULong i = 0; i < policies.length(); ++i)
    {
      policies[i]->destroy();
    }

  // Activate the diamond servant and its base classes under childPOA.
  PortableServer::ObjectId_var id =
    childPOA->activate_object (&this->top_servant_);

//    // We only care about the most derived class here.
//    this->diamond_obj_ = this->diamond_servant_._this ();

  id =
    childPOA->activate_object (&this->diamond_servant_);

  // We only care about the most derived class here.
  this->diamond_obj_ = childPOA->id_to_reference (id.in ());

  id =
    childPOA->activate_object (&this->left_servant_);

  id =
    childPOA->activate_object (&this->right_servant_);


  CORBA::String_var str =
    this->orb_->object_to_string (this->diamond_obj_.in ());

  ACE_DEBUG ((LM_DEBUG, "Diamond Servant activated:\n %C\n",
              str.in()));

  return 0;


}
开发者ID:asdlei00,项目名称:ACE,代码行数:70,代码来源:Collocation_Tester.cpp

示例5: safe_servant

int
Task::svc (void)
{
    try
    {
        CORBA::Object_var object =
            this->orb_->resolve_initial_references ("RTORB");

        RTCORBA::RTORB_var rt_orb =
            RTCORBA::RTORB::_narrow (object.in ());

        object =
            this->orb_->resolve_initial_references ("RootPOA");

        PortableServer::POA_var root_poa =
            PortableServer::POA::_narrow (object.in ());

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

        CORBA::PolicyList policies;

        int result =
            get_priority_bands ("server",
                                bands_file,
                                rt_orb.in (),
                                policies,
                                debug);
        if (result != 0)
            return result;

        result =
            get_priority_lanes ("server",
                                lanes_file,
                                rt_orb.in (),
                                stacksize,
                                static_threads,
                                dynamic_threads,
                                allow_request_buffering,
                                max_buffered_requests,
                                max_request_buffer_size,
                                allow_borrowing,
                                policies,
                                debug);
        if (result != 0)
            return result;

        CORBA::Policy_var priority_model_policy =
            rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
                    0);

        // Implicit_activation policy.
        CORBA::Policy_var implicit_activation_policy =
            root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION);

        policies.length (policies.length () + 1);
        policies[policies.length () - 1] =
            priority_model_policy;

        policies.length (policies.length () + 1);
        policies[policies.length () - 1] =
            implicit_activation_policy;

        PortableServer::POA_var poa =
            root_poa->create_POA ("child",
                                  poa_manager.in (),
                                  policies);

        test_i *servant = 0;
        ACE_NEW_THROW_EX (servant,
                          test_i (this->orb_.in (),
                                  poa.in ()),
                          CORBA::NO_MEMORY ());

        PortableServer::ServantBase_var safe_servant (servant);

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

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

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

        write_iors_to_file (test.in (),
                            this->orb_.in (),
                            ior);

        poa_manager->activate ();

        this->orb_->run ();

        this->orb_->destroy ();
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception caught");
        return -1;
    }

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

示例6: StructuredEventSupplier_i

Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
{

  CORBA::Object_var naming_obj =
    orb_->resolve_initial_references ("NameService");

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

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

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

  CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
    CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj.in ());

  CosNotifyChannelAdmin::ChannelID id;
  CosNotification::QoSProperties initial_qos;
  CosNotification::AdminProperties initial_admin;

  CosNotifyChannelAdmin::EventChannel_var ec =
    notify_factory->create_channel (initial_qos,
                                    initial_admin,
                                    id);

  name[0].id = CORBA::string_dup ("MyEventChannel");

  naming_context->rebind (name, ec.in());

  CosNotifyChannelAdmin::AdminID adminid;
  CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
    CosNotifyChannelAdmin::OR_OP;

  CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
    ec->new_for_suppliers (ifgop, adminid);

  CosNotifyChannelAdmin::ProxyID supplieradmin_proxy_id;

  CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
    supplier_admin->obtain_notification_push_consumer(
                                 CosNotifyChannelAdmin::STRUCTURED_EVENT,
                                 supplieradmin_proxy_id);

  StructuredEventSupplier_i *servant =
    new StructuredEventSupplier_i(orb_.in());

  CORBA::Object_var poa_obj = orb_->resolve_initial_references ("RootPOA");
  PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_obj.in ());
  PortableServer::POAManager_var mgr = poa->the_POAManager ();

  mgr->activate ();
  PortableServer::ObjectId_var objectId = poa->activate_object (servant);

  CORBA::Object_var supplier_obj = poa->id_to_reference (objectId.in ());

  CosNotifyComm::StructuredPushSupplier_var supplier =
    CosNotifyComm::StructuredPushSupplier::_narrow (supplier_obj.in ());

  consumer_proxy_ =
    CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxy_consumer.in());

  consumer_proxy_->
    connect_structured_push_supplier (supplier.in());
}
开发者ID:asdlei00,项目名称:ACE,代码行数:67,代码来源:Messenger_i.cpp

示例7: name

Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate(orb))

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

    CORBA::Object_var naming_obj =
      orb_->resolve_initial_references ("NameService");

    if (CORBA::is_nil(naming_obj.in())) {
      std::cerr << "Unable to find naming service" << std::endl;
    }

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


    //
    //  Create an instance of TAO's notification event channel
    //

    CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
      TAO_Notify_EventChannelFactory_i::create(poa.in());

    if (CORBA::is_nil (notify_factory.in ())) {
      std::cerr << "Unable to create the notify event channel" << std::endl;
      return;
    }

    CosNotifyChannelAdmin::ChannelID id;
    CosNotification::QoSProperties initial_qos;
    CosNotification::AdminProperties initial_admin;

    CosNotifyChannelAdmin::EventChannel_var ec =
      notify_factory->create_channel (initial_qos,
      initial_admin,
      id);

    if (CORBA::is_nil (ec.in())) {
      std::cerr << "Unable to create event channel" << std::endl;
      return;
    }


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

    naming_context->rebind(name, ec.in());

    CosNotifyChannelAdmin::AdminID adminid;
    CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
      CosNotifyChannelAdmin::AND_OP;

    CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
      ec->new_for_suppliers (ifgop, adminid);

    if (CORBA::is_nil (supplier_admin.in())) {
      std::cerr << "Unable to find supplier admin" << std::endl;
    }

    CosNotifyChannelAdmin::ProxyID supplieradmin_proxy_id;

    CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
      supplier_admin->obtain_notification_push_consumer(
      CosNotifyChannelAdmin::STRUCTURED_EVENT,
      supplieradmin_proxy_id);

    StructuredEventSupplier_i *servant =
      new StructuredEventSupplier_i(orb_.in());

    PortableServer::ObjectId_var oid = poa->activate_object(servant);
    CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in());
    CosNotifyComm::StructuredPushSupplier_var supplier =
      CosNotifyComm::StructuredPushSupplier::_narrow(supplier_obj.in());

    consumer_proxy_ =
      CosNotifyChannelAdmin::StructuredProxyPushConsumer::
      _narrow(proxy_consumer.in());

    if (CORBA::is_nil (consumer_proxy_.in())) {
      std::cerr << "Unable to find structured proxy push consumer" << std::endl;
    }

    consumer_proxy_->connect_structured_push_supplier(supplier.in());

  }
  catch(const CORBA::Exception& ex) {
    std::cerr << ex << std::endl;
  }

}
开发者ID:asdlei00,项目名称:ACE,代码行数:95,代码来源:Messenger_i.cpp

示例8: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    // Initialize the EC Factory so we can customize the EC
    TAO_EC_Default_Factory::init_svcs ();

    // Initialize the ORB.
    CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

    const ACE_TCHAR *ecname = ACE_TEXT ("EventService");
    const ACE_TCHAR *address = ACE_TEXT ("localhost");
    const ACE_TCHAR *iorfile = 0;
    u_short port = 12345;
    u_short listenport = 12345;

    int mcast = 1;

    for (int i = 0; argv[i] != 0; i++)
      {
        if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-ecname")) == 0)
          {
            if (argv[i+1] != 0)
                ecname = argv[++i];
            else
              ACE_ERROR_RETURN ((LM_ERROR,  "Missing Event channel name\n"),0);
          }
        else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-address")) == 0)
          {
            if (argv[i+1] != 0)
              address = argv[++i];
            else
              ACE_ERROR_RETURN ((LM_ERROR, "Missing address\n"),0);
          }
        else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-port")) == 0)
          {
            if (argv[i+1] != 0)
              port = ACE_OS::atoi(argv[++i]);
            else
              ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"),0);
          }
        else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-listenport")) == 0)
          {
            if (argv[i+1] != 0)
              listenport = ACE_OS::atoi(argv[++i]);
            else
              ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"), 0);
          }
        else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-iorfile")) == 0)
          {
            if (argv[i+1] != 0)
              iorfile = argv[++i];
             else
              ACE_ERROR_RETURN ((LM_ERROR, "Missing ior file\n"), 0);
          }
        else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-udp")) == 0)
          mcast = 0;
      }

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

    // Create a local event channel and register it
    TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ());
    TAO_EC_Event_Channel ec_impl (attributes);
    ec_impl.activate ();
    PortableServer::ObjectId_var oid = poa->activate_object(&ec_impl);
    tmpobj = poa->id_to_reference(oid.in());
    RtecEventChannelAdmin::EventChannel_var ec =
      RtecEventChannelAdmin::EventChannel::_narrow(tmpobj.in());

    // Find the Naming Service.
    tmpobj = orb->resolve_initial_references("NameService");
    CosNaming::NamingContextExt_var root_context =
      CosNaming::NamingContextExt::_narrow(tmpobj.in());

    // Bind the Event Channel using Naming Services
    CosNaming::Name_var name =
      root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname));
    root_context->rebind(name.in(), ec.in());

    // Get a proxy push consumer from the EventChannel.
    RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers();
    RtecEventChannelAdmin::ProxyPushConsumer_var consumer =
      admin->obtain_push_consumer();

    // Instantiate an EchoEventSupplier_i servant.
    EchoEventSupplier_i servant(orb.in());

    // Register it with the RootPOA.
    oid = poa->activate_object(&servant);
    tmpobj = poa->id_to_reference(oid.in());
    RtecEventComm::PushSupplier_var supplier =
      RtecEventComm::PushSupplier::_narrow(tmpobj.in());

    // Connect to the EC.
    ACE_SupplierQOS_Factory qos;
//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:EchoEventSupplierMain.cpp


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