Exemple #1
0
void
IdAssignment::destroy_supplier_admin (
    CosNotifyChannelAdmin::ChannelID channel_id,
    CosNotifyChannelAdmin::AdminID admin_id
  )
{
  CosNotifyChannelAdmin::EventChannel_var ec =
    this->notify_factory_->get_event_channel (channel_id);


  if (CORBA::is_nil (ec.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  " (%P|%t) Unable to find event channel\n"));
    }

  CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
    ec->get_supplieradmin (admin_id);

  if (CORBA::is_nil (supplier_admin.in ()))
    ACE_ERROR ((LM_ERROR,
                " (%P|%t) Unable to get supplier admin\n"));

  supplier_admin->destroy ();

  if (TAO_debug_level)
    ACE_DEBUG ((LM_DEBUG,
                "destroyed supplier admin\n"));
}
Exemple #2
0
CosNotifyChannelAdmin::AdminID
IdAssignment::create_consumer_admin (CosNotifyChannelAdmin::ChannelID channel_id)
{
  CosNotifyChannelAdmin::AdminID adminid;
  CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
    CosNotifyChannelAdmin::OR_OP;

  CosNotifyChannelAdmin::EventChannel_var ec =
    this->notify_factory_->get_event_channel (channel_id);

  if (CORBA::is_nil (ec.in ()))
    {
      ACE_ERROR((LM_ERROR,
                 " (%P|%t) Unable to find event channel\n"));
      return 0;
    }

  CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
    ec->new_for_consumers (ifgop,
                           adminid);

  if (CORBA::is_nil (consumer_admin.in ()))
    ACE_ERROR_RETURN ((LM_ERROR,
                       " (%P|%t) Unable to create consumer admin\n"),0);

  if (TAO_debug_level)
    ACE_DEBUG ((LM_DEBUG,
                "created consumer admin\n"));

  return adminid;
}
Exemple #3
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;
  try
    {
      Supplier_Client client;
      status = client.init (argc, argv);

      if (status == 0)
        {
          CosNotifyChannelAdmin::EventChannel_var ec =
            client.create_event_channel ("MyEventChannel", 1);

          CORBA::ORB_ptr orb = client.orb ();
          CORBA::Object_var object =
            orb->string_to_object (ior);

          MonitorTestInterface_var sig =
            MonitorTestInterface::_narrow (object.in ());

          if (CORBA::is_nil (sig.in ()))
            ACE_ERROR_RETURN ((LM_ERROR, "Error: Structured Supplier: Narrow to MonitorTestInterface failed.\n"),1);
          CosNotifyChannelAdmin::SupplierAdmin_var admin =
            create_supplieradmin (ec.in ());
          if (!CORBA::is_nil (admin.in ()))
            {
              create_suppliers (admin.in (), client.root_poa ());

              sig->running (MonitorTestInterface::Supplier);
              ACE_DEBUG ((LM_DEBUG,
                          "1 supplier sending %d events...\n", max_events));
              for (int i = 0; i < max_events; ++i)
              {
                ACE_DEBUG ((LM_DEBUG, "+"));
                SendEvent (i);
              }
              ACE_DEBUG ((LM_DEBUG,
                          "\nSupplier sent %d events.\n", max_events));
              sig->finished (MonitorTestInterface::Supplier);
              supplier_1->disconnect ();
            }
        }
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Supplier Error: ");
      status = 1;
    }

  return status;
}
B21BehavioursFactory::B21BehavioursFactory(Miro::Server& _server,
					   ACE_Reactor& _reactor)
{
  std::cout << "Constructing B21BehavioursFactory." << std::endl;

  // optain references
  CosNotifyChannelAdmin::EventChannel_var ec =
    _server.resolveName<CosNotifyChannelAdmin::EventChannel>("EventChannel");
  Miro::RangeSensor_var sonar =
    _server.resolveName<Miro::RangeSensor>("Sonar");
  Miro::RangeSensor_var laser =
    _server.resolveName<Miro::RangeSensor>("Laser");


  // initialize behaviours
  eventBehaviours_.push_back(new OnButton(ec.in(), 
					  _server.namingContextName));
  eventBehaviours_.push_back(new SonarAvoid(sonar.in(),
					    ec.in(),
					    _server.namingContextName));
  timedBehaviours_.push_back(new LaserAvoid(_reactor, 
					    laser.in()));
}
Exemple #5
0
void
IdAssignment::destroy_ec(CosNotifyChannelAdmin::ChannelID id)
{
  CosNotifyChannelAdmin::EventChannel_var ec =
    this->notify_factory_->get_event_channel (id);


  if (CORBA::is_nil (ec.in()))
    {
      ACE_ERROR((LM_ERROR,
                 " (%P|%t) Unable to find event channel\n"));
      return;
    }

   ec->destroy ();
}
Exemple #6
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;
  try
  {
    Consumer_Client client;

    status = client.init (argc, argv);
    ACE_UNUSED_ARG(status);
    ACE_ASSERT(status == 0);

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("MyEventChannel", 1);

    CORBA::ORB_ptr orb = client.orb ();
    CORBA::Object_var object =
      orb->string_to_object (ior);

    sig_var sig = sig::_narrow (object.in ());
    ACE_ASSERT(! CORBA::is_nil (sig.in ()));

    CosNotifyChannelAdmin::ConsumerAdmin_var admin =
      create_consumeradmin (ec.in ());
    ACE_ASSERT(!CORBA::is_nil (admin.in ()));

    create_consumers (admin.in (), &client);

    // Tell the supplier to go
    sig->go ();

    ACE_DEBUG((LM_DEBUG, "Consumer waiting for events...\n"));

    client.ORB_run( );

    ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));
    consumer_1->disconnect();

    sig->done ();
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: ");
    status = 1;
  }

  return status;
}
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;
  try
    {
      Consumer_Client client;

      status = client.init (argc, argv);
      if (status != 0)
        ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"),1);

      CosNotifyChannelAdmin::EventChannel_var ec =
        client.create_event_channel ("MyEventChannel", 1);

      CORBA::ORB_ptr orb = client.orb ();
      CORBA::Object_var object =
        orb->string_to_object (ior);

      sig_var sig = sig::_narrow (object.in ());

      CosNotifyChannelAdmin::ConsumerAdmin_var admin =
        create_consumeradmin (ec.in ());

      if (CORBA::is_nil (admin.in ()))
        ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"),1);

      create_consumers (admin.in (), &client);

      ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n"));

      sig->go ();
      ACE_Time_Value tv (5);
      orb->run (tv);

      ACE_DEBUG ((LM_DEBUG, "Consumer done.\n"));
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Consumer Error: ");
      status = 1;
    }

  return status;
}
Exemple #8
0
bool
IdAssignment::default_supplier_admin_test (CosNotifyChannelAdmin::ChannelID channel_id)
{
  CosNotifyChannelAdmin::EventChannel_var ec =
    this->notify_factory_->get_event_channel (channel_id);

  if (CORBA::is_nil (ec.in ()))
    {
      ACE_ERROR((LM_ERROR,
                 " (%P|%t) Unable to find event channel\n"));
      return false;
    }

  CosNotifyChannelAdmin::SupplierAdmin_var default_supplier_admin =
    ec->get_supplieradmin (0);

  if (CORBA::is_nil (default_supplier_admin.in()))
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                  " (%P|%t) Unable to create default supplier admin\n"),
                  false);
    }

  CosNotifyChannelAdmin::SupplierAdmin_var def = ec->default_supplier_admin ();
  if (CORBA::is_nil (default_supplier_admin.in()))
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                  " (%P|%t) Unable to get default supplier admin\n"),
                  false);
    }

  if (! default_supplier_admin->_is_equivalent(def.in ()))
    {
      ACE_ERROR_RETURN ((LM_ERROR,
        " (%P|%t) failed for default supplier admin checking\n"),
        false);
    }

  if (TAO_debug_level)
    ACE_DEBUG ((LM_DEBUG,
                "passed default supplier admin test.\n"));

  return true;
}
Exemple #9
0
void
TAO_CosNotify_Service::finalize_service (
                   CosNotifyChannelAdmin::EventChannelFactory_ptr factory)
{
  // Get out early if we can
  if (CORBA::is_nil (factory))
    return;

  // Make sure the factory doesn't go away while we're in here
  CosNotifyChannelAdmin::EventChannelFactory_var ecf =
    CosNotifyChannelAdmin::EventChannelFactory::_duplicate (factory);

  // Find all the consumer admin objects and shutdown the worker tasks
  CosNotifyChannelAdmin::ChannelIDSeq_var channels =
    ecf->get_all_channels ();
  CORBA::ULong length = channels->length ();
  for(CORBA::ULong i = 0; i < length; i++)
    {
      try
        {
          CosNotifyChannelAdmin::EventChannel_var ec =
            ecf->get_event_channel (channels[i]);
          if (!CORBA::is_nil (ec.in ()))
            {
              TAO_Notify_EventChannel* nec =
                dynamic_cast<TAO_Notify_EventChannel*> (ec->_servant ());
              if (nec != 0)
                nec->destroy ();
            }
        }
      catch (const CORBA::Exception&)
        {
          // We're shutting things down, so ignore exceptions
        }
    }

  TAO_Notify_EventChannelFactory* necf =
    dynamic_cast<TAO_Notify_EventChannelFactory*> (ecf->_servant ());

  if (necf != 0)
    necf->stop_validator();
}
Exemple #10
0
void
TAO_Notify_Tests_EventChannel_Command::handle_create (void)
{
  if (this->collocated_ == 1)
    {
      this->create_collocated_ecf ();
    }

  CosNotifyChannelAdmin::EventChannelFactory_var ec_factory;

  LOOKUP_MANAGER->resolve (ec_factory , TAO_Notify_Tests_Name::event_channel_factory);

  CosNotification::QoSProperties qos;
  CosNotification::AdminProperties admin;

  // Create an event channel
  CosNotifyChannelAdmin::EventChannel_var ec =
    ec_factory->create_channel (qos,
                                admin,
                                this->id_);

  LOOKUP_MANAGER->_register (ec.in(), this->name_.c_str ());
}
  /**
   * Processing of the configuration file parameters.
   */
  void
  BallDetectionEventChannel::init(Miro::Server& _server, Video::FilterParameters const * _params)
  {
    // Super class initialization.
    Super::init(_server, _params);

    // Set up the interface
    try {
      // Get reference to the event channel
      CosNotifyChannelAdmin::EventChannel_var ec =
	_server.resolveName<CosNotifyChannelAdmin::EventChannel>("EventChannel");
      supplier_ = new Miro::StructuredPushSupplier(ec.in(), _server.namingContextName.c_str());

      // Define the event type which is published
      Miro::StructuredPushSupplier::
	initStructuredEvent(event_, supplier_->domainName(), "BallResult");

      // Register the event at the event channel
      supplier_->addOffer(event_);
    }
    catch (const CORBA::Exception& e) {
      std::cerr << "Set up event publication failed: " << std::endl;
    }
  }
Exemple #12
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;
  try
    {
      Consumer_Client client;

      status = client.init (argc, argv);

      if (status == 0)
        {
          CosNotifyChannelAdmin::EventChannel_var ec =
            client.create_event_channel ("MyEventChannel", 1);

          CORBA::ORB_ptr orb = client.orb ();
          CORBA::Object_var object =
                              orb->string_to_object (ior);

          sig_var sig = sig::_narrow (object.in ());

          if (CORBA::is_nil (sig.in ()))
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Object reference <%s> is nil\n",
                                 ior),
                                1);
            }

          CosNotifyChannelAdmin::ConsumerAdmin_var admin =
            ec->default_consumer_admin();

          CosNotifyFilter::Filter_var filter =
            create_proxyFilter (ec.in());

          if (!CORBA::is_nil (admin.in ()))
            {
              create_consumers (admin.in (), &client, filter.in());

              // Tell the supplier to go
              sig->go ();

              ACE_Time_Value tv(10, 0);
              client.ORB_run(tv);
              ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));

              sig->done ();

              ACE_DEBUG((LM_DEBUG, "Expected %d message(s) and received %d message(s).\n",
                expect_fail == 1 ? 0 : 1, consumer_1->messages_received()));

              if (1 == expect_fail)
                status = consumer_1->messages_received() == 0 ? 0 : 1;
              else
                status = consumer_1->messages_received() == 1 ? 0 : 1;

              ACE_DEBUG((LM_DEBUG, "Test status is %s.\n", status == 1 ? "fail" : "pass"));

            }
        }
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Error: Consumer exception: ");
      status = 1;
    }

  return status;
}
int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
  try
  {
     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
     CORBA::Object_var rootObj = orb->resolve_initial_references("NameService");
     CosNaming::NamingContext_var rootNC =
       CosNaming::NamingContext::_narrow(rootObj.in());

     // 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 Event Channel factory.
     CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
       TAO_Notify_EventChannelFactory_i::create(poa.in());
     ACE_ASSERT (!CORBA::is_nil (notify_factory.in ()));

     // Create an Event Channel.
     CosNotifyChannelAdmin::ChannelID id;
     CosNotification::QoSProperties initial_qos;
     CosNotification::AdminProperties initial_admin;
     CosNotifyChannelAdmin::EventChannel_var ec =
       notify_factory->create_channel (initial_qos, initial_admin, id);

     // Bind it in the Naming Service.
     CosNaming::Name name(1);
     name.length(1);
     name[0].id = CORBA::string_dup("MyEventChannel");
     rootNC->rebind(name, ec.in());

     // Become a structured push supplier.
     CosNotifyChannelAdmin::AdminID adminid;
     CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
       CosNotifyChannelAdmin::AND_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());
     CosNotifyComm::StructuredPushSupplier_var supplier = servant->_this();

     CosNotifyChannelAdmin::StructuredProxyPushConsumer_var consumer_proxy =
       CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(
         proxy_consumer.in());
     consumer_proxy->connect_structured_push_supplier(supplier.in());

     // Set up events to push.
     CosNotification::StructuredEvent event;
     event.header.fixed_header.event_type.domain_name =
     CORBA::string_dup("OCI_TAO");

    event.header.fixed_header.event_type.type_name =
      CORBA::string_dup("examples");
    event.header.fixed_header.event_name = CORBA::string_dup("myevent");
    event.filterable_data.length (1);
    event.filterable_data[0].name = CORBA::string_dup("Message from:");
    event.filterable_data[0].value <<= (const char *)user_name;
    event.filterable_data.length (2);
    event.filterable_data[1].name = CORBA::string_dup("Subject:");
    event.filterable_data[1].value <<= (const char *)subject;
    event.filterable_data.length (3);
    event.filterable_data[2].name = CORBA::string_dup("Message:");
    event.filterable_data[2].value <<= (const char *)message;

    // Push events.
    while (1) {
      std::cout << "pushing " << std::endl;
      consumer_proxy->push_structured_event (event);
      ACE_OS::sleep (1);
    }
  }
  catch(const CORBA::Exception& ex) {
    return 1;
  }

  return 0;
}
Exemple #14
0
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());
}
Exemple #15
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Auto_Ptr< sig_i > sig_impl;
  try
  {
    Notify_Test_Client client;
    int status = client.init (argc, argv);
    ACE_UNUSED_ARG(status);
    ACE_ASSERT(status == 0);

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("MyEventChannel", 0);

    ACE_ASSERT(! CORBA::is_nil(ec.in()));

    CORBA::ORB_ptr orb = client.orb ();

    sig_impl.reset( new sig_i( orb ) );
    sig_var sig = sig_impl->_this ();

    CosNotifyChannelAdmin::SupplierAdmin_var admin =
      create_supplieradmin (ec.in ());
    ACE_ASSERT(! CORBA::is_nil (admin.in ()));

    create_supplier (admin.in (), client.root_poa ());

    if (ior_file != 0)
    {
      CORBA::String_var ior =
        client.orb ()->object_to_string (sig.in ());

      FILE *output_file= ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ior_file), "w");
      ACE_ASSERT (output_file != 0);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }

    ACE_DEBUG((LM_DEBUG, "Supplier ready...\n"));

    sig_impl->wait_for_startup();

    ACE_DEBUG((LM_DEBUG, "Supplier sending %d events...\n", num_events));
    for (int i = 0; i < num_events; ++i)
    {
      ACE_DEBUG((LM_DEBUG, "+"));
      send_event (i);
    }
    ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", num_events));

    sig_impl->wait_for_completion();

    ACE_OS::unlink (ior_file);

    ec->destroy();

    return 0;
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: Supplier: ");
  }

  return 1;
}
Exemple #16
0
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);

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

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

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

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

      stat = instance->get (stat_name);

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

      stat->update ();
      Monitor_Control_Types::NameList list = stat->get_list ();

      if (list.size () != 1)
        {
          error ("Invalid inactive event channel list");
        }

      ACE_CString full_ec_name (ecf_name + "/" + ec_name);

      if (list[0] != full_ec_name)
        {
          error ("Wrong event channel name");
        }

      CosNotifyChannelAdmin::AdminID aid;
      CosNotifyChannelAdmin::SupplierAdmin_var admin =
        mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
                                      aid,
                                      "TestSupplierAdmin");

      try
        {
          admin =
            mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
                                          aid,
                                          "TestSupplierAdmin");

          error ("Expected a SupplierAdmin "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          // This is expected.
        };

      // We should be able to create another one with the same name.
      admin->destroy ();
      admin =
        mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP,
                                      aid,
                                      "TestSupplierAdmin");

      NotifyMonitoringExt::SupplierAdmin_var madmin =
        NotifyMonitoringExt::SupplierAdmin::_narrow (admin.in ());

      if (CORBA::is_nil (madmin.in ()))
        {
          error ("Could not narrow the supplier admin");
        }

      CosNotifyChannelAdmin::ProxyID pid;
      CosNotifyChannelAdmin::ProxyConsumer_var conproxy =
        madmin->obtain_named_notification_push_consumer (
          CosNotifyChannelAdmin::STRUCTURED_EVENT,
          pid,
          "supplier");

      try
        {
          CosNotifyChannelAdmin::ProxyConsumer_var fake =
            madmin->obtain_named_notification_push_consumer
            (CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier");

          error ("Expected a ProxyConsumer "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          // This is expected.
        }

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

      stat = instance->get (stat_name);

      if (stat == 0)
        {
          error ("Could not find the event channel suppliers statistic");
        }

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

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

      CosNotifyChannelAdmin::StructuredProxyPushConsumer_var push_conproxy =
        CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (
          conproxy.in ());
      ACE_ASSERT (!CORBA::is_nil (push_conproxy.in ()));
      push_conproxy->disconnect_structured_push_consumer ();

      try
        {
          CosNotifyChannelAdmin::ProxyConsumer_var fake =
            madmin->obtain_named_notification_push_consumer (
              CosNotifyChannelAdmin::STRUCTURED_EVENT,
              pid,
              "supplier");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          error ("Unexpected ProxyConsumer "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }

      CosNotifyChannelAdmin::ConsumerAdmin_var cadmin =
        mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
                                      aid,
                                      "TestConsumerAdmin");

      try
        {
          cadmin =
            mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
                                          aid,
                                          "TestConsumerAdmin");

          error ("Expected a ConsumerAdmin "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          // This is expected.
        };

      // We should be able to create another one with the same name
      cadmin->destroy ();
      cadmin =
        mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP,
                                      aid,
                                      "TestConsumerAdmin");

      NotifyMonitoringExt::ConsumerAdmin_var mcadmin =
        NotifyMonitoringExt::ConsumerAdmin::_narrow (cadmin.in ());

      if (CORBA::is_nil (mcadmin.in ()))
        {
          error ("Could not narrow the consumer admin");
        }

      CosNotifyChannelAdmin::ProxySupplier_var supproxy =
        mcadmin->obtain_named_notification_push_supplier (
          CosNotifyChannelAdmin::STRUCTURED_EVENT,
          pid,
          "consumer");

      try
        {
          CosNotifyChannelAdmin::ProxySupplier_var fake =
            mcadmin->obtain_named_notification_push_supplier (
              CosNotifyChannelAdmin::STRUCTURED_EVENT,
              pid,
              "consumer");

          error ("Expected a ProxySupplier "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          // This is expected.
        }

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

      stat = instance->get (stat_name);

      if (stat == 0)
        {
          error ("Could not find the event channel consumers statistic");
        }

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

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

      CosNotifyChannelAdmin::StructuredProxyPushSupplier_var push_supproxy =
        CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow (
          supproxy.in());
      ACE_ASSERT (!CORBA::is_nil (push_supproxy.in ()));
      push_supproxy->disconnect_structured_push_supplier ();

      try
        {
          CosNotifyChannelAdmin::ProxySupplier_var fake =
            mcadmin->obtain_named_notification_push_supplier (
              CosNotifyChannelAdmin::STRUCTURED_EVENT,
              pid,
              "consumer");
        }
      catch (const NotifyMonitoringExt::NameAlreadyUsed&)
        {
          error ("Unexpected ProxySupplier "
                 "NotifyMonitoringExt::NameAlreadyUsed exception");
        }

      TAO_MonitorManager::shutdown ();
      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("MonitorControlExt: ");
    }
  catch (...)
    {
      error ("Caught an unexpected exception type");
    }
#else /* ACE_HAS_MONITOR_FRAMEWORK==1 */
  ACE_UNUSED_ARG (argc);
  ACE_UNUSED_ARG (argv);
#endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */

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

    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;
      return 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("NotifyEventChannelFactory");

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

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

    if (CORBA::is_nil(notify_factory.in())) {
      std::cerr << "Unable to find notify factory" << std::endl;
      return 1;
    }

    name.length (1);
    name[0].id = CORBA::string_dup("MyEventChannel");
    CORBA::Object_var ecObj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannel_var ec =
      CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

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

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

    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers(ifgop,
                            adminid);

    if (CORBA::is_nil (consumer_admin.in())) {
      std::cerr << "Unable to find consumer admin" << std::endl;
      return 1;
    }

    CosNotifyFilter::FilterFactory_var ffact =
      ec->default_filter_factory ();

    // setup a filter at the consumer admin
    CosNotifyFilter::Filter_var ca_filter =
      ffact->create_filter (TCL_GRAMMAR);

    if (CORBA::is_nil (ca_filter.in())) {
      std::cerr << "Unable to create filetr object" << std::endl;
      return 1;
    }

    CosNotifyFilter::ConstraintExpSeq constraint_list (1);
    constraint_list.length (1);
    constraint_list[0].event_types.length (0);
    constraint_list[0].constraint_expr = CORBA::string_dup (CA_FILTER);

    ca_filter->add_constraints (constraint_list);

    consumer_admin ->add_filter (ca_filter.in());

    CosNotification::EventTypeSeq added(1);
    CosNotification::EventTypeSeq removed (0);
    added.length (1);
    removed.length (0);

    added[0].domain_name =  CORBA::string_dup ("*");
    added[0].type_name = CORBA::string_dup ("*");

    consumer_admin->subscription_change (added, removed);

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

    if (CORBA::is_nil (poa_object.in())) {
      std::cerr << "Unable to initialize the POA." << std::endl;
      return 1;
    }

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

    PortableServer::Servant_var<StructuredEventConsumer_i> servant =
      new StructuredEventConsumer_i(orb.in());
    /*
    CosNotifyComm::StructuredPushConsumer_var consumer =
      servant->_this();
    */

    PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
    CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in());
    CosNotifyComm::StructuredPushConsumer_var consumer =
      CosNotifyComm::StructuredPushConsumer::_narrow(consumer_obj.in());


    CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

    CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
      consumer_admin->obtain_notification_push_supplier(
                                   CosNotifyChannelAdmin::STRUCTURED_EVENT,
                                   consumeradmin_proxy_id);


    // The proxy that we are connected to.
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
    supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
                             _narrow(proxy_supplier.in());

    if (CORBA::is_nil (supplier_proxy.in())) {
      std::cerr << "Unable to create structured push supplier proxy" << std::endl;
      return 1;
    }

    supplier_proxy->connect_structured_push_consumer(consumer.in());

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

    poa_manager->activate();

    orb->run();
    orb->destroy ();

   }
  catch(const CORBA::Exception& ex) {
    std::cerr << ex << std::endl;
    return 1;
  }
  return 0;
}
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    int status = 0;
    ACE_Auto_Ptr< sig_i > sig_impl;
    try
    {
        Supplier_Client client;
        status = client.init (argc, argv);

        if (status == 0)
        {
            static const char* ec_name = "MyEventChannel";
            CosNotifyChannelAdmin::EventChannel_var ec =
                client.create_event_channel (ec_name, 0);

            static const int max = 20;
            int count = 0;
            while(ACE_OS::access(ACE_TEXT_ALWAYS_CHAR(notify2ior), R_OK) == -1 && count < max)
            {
                ACE_OS::sleep (1);
                count++;
            }
            if (count >= max)
            {
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "ERROR: Timed out waiting for the "
                                   "second notify service\n"),
                                  1);
            }
            ACE_OS::sleep (2);

            // Due to the way that connections are handled, we need to
            // perform the new event channel creation twice to flush out
            // the connection to the first notification service
            try
            {
                ec = client.create_event_channel (ec_name, 0);
            }
            catch (const CORBA::TRANSIENT&)
            {
            }
            catch (const CORBA::COMM_FAILURE&)
            {
            }

            ec = client.create_event_channel (ec_name, 0);

            CORBA::ORB_ptr orb = client.orb ();

            // Activate the signaler with the POA
            sig_impl.reset( new sig_i( orb ) );
            sig_var sig = sig_impl->_this ();

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

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

            CosNotifyChannelAdmin::SupplierAdmin_var admin =
                create_supplieradmin (ec.in ());
            if (!CORBA::is_nil (admin.in ()))
            {
                create_suppliers (admin.in (), client.root_poa ());

                sig_impl->wait_for_startup();

                ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", max_events));
                for (int i = 0; i < max_events; ++i)
                {
                    ACE_DEBUG((LM_DEBUG, "+"));
                    SendEvent (i);
                }
                ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events));

                sig_impl->wait_for_completion();

                ACE_OS::unlink (ior_output_file);

                supplier_1->disconnect();

                ec->destroy();
            }
        }
    }
    catch (const CORBA::Exception& e)
    {
        e._tao_print_exception ("Error: ");
        status = 1;
    }

    return status;
}
Exemple #19
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Auto_Ptr< sig_i > sig_impl;
  try
  {
    Supplier_Client client;
    int status = client.init (argc, argv);
    ACE_UNUSED_ARG(status);
    ACE_ASSERT(status == 0);

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("MyEventChannel", 0);

    CosNotification::QoSProperties qos (1);
    qos.length (1);
    qos[0].name = CORBA::string_dup (CosNotification::OrderPolicy);
    qos[0].value <<= order_policy;
    ec->set_qos (qos);

    CORBA::ORB_ptr orb = client.orb ();

    sig_impl.reset( new sig_i( orb ) );
    sig_var sig = sig_impl->_this ();

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

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

    CosNotifyChannelAdmin::SupplierAdmin_var admin =
      create_supplieradmin (ec.in ());
    ACE_ASSERT(!CORBA::is_nil (admin.in ()));
    create_suppliers (admin.in (), client.root_poa ());

    sig_impl->wait_for_startup();

    ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", num_events));
    for (int i = 0; i < num_events / BATCH_SIZE; ++i)
    {
      ACE_DEBUG((LM_DEBUG, "+"));
      SendBatch (i);
    }
    ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", num_events));

    sig_impl->wait_for_completion();

    ACE_OS::unlink (ior_output_file);

    supplier_1->disconnect();

    ec->destroy();

    return 0;
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: ");
  }

  return 1;
}
Exemple #20
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    Consumer_Client client;

    int status = client.init (argc, argv);
    if (status != 0)
    {
      ACE_ERROR((LM_ERROR, "Error: Unable to init consumer.\n"));
      return 1;
    }

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("Struct_Multi_Filter", 1);

    CosNotifyChannelAdmin::AdminID adminid = 0;
    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers ((consumerFilter == OrOp
      ? CosNotifyChannelAdmin::OR_OP : CosNotifyChannelAdmin::AND_OP),
      adminid);

    ACE_ASSERT(! CORBA::is_nil (consumer_admin.in ()));

    if (consumerFilter != None)
    {
      CosNotifyFilter::FilterFactory_var ffact =
        ec->default_filter_factory ();

      CosNotifyFilter::Filter_var filter =
        ffact->create_filter (GRAMMAR);

      if (CORBA::is_nil (filter.in ()))
      {
        ACE_ERROR ((LM_ERROR,
          " (%P|%t) Consumer unable to initialize filter.\n"));
        return 1;
      }

      CosNotifyFilter::ConstraintExpSeq constraint_list (1);
      constraint_list.length (1);

      constraint_list[0].event_types.length (0);
      constraint_list[0].constraint_expr = CORBA::string_dup ("type != 1");

      filter->add_constraints (constraint_list);

      consumer_admin->add_filter (filter.in ());
    }

    CORBA::ORB_ptr orb = client.orb ();

    CORBA::Object_var object =
      orb->string_to_object (ior);

    sig_var sig = sig::_narrow (object.in ());

    ACE_ASSERT(! CORBA::is_nil (sig.in ()));

    create_consumer (consumer_admin.in (), ec.in (), &client);

    ACE_DEBUG((LM_DEBUG, "\nConsumer waiting for events...\n"));

    sig->go ();

    client.ORB_run( );

    ACE_DEBUG((LM_DEBUG, "\nConsumer done.\n"));

    sig->done();

    return 0;
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("\nError: Consumer:");
  }

  return 1;
}
Exemple #21
0
Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
              : orb_(CORBA::ORB::_duplicate(orb))
{
  CORBA::Object_var poa_object =
    orb_->resolve_initial_references("RootPOA");

  if (CORBA::is_nil (poa_object.in())) {
    std::cerr << "Unable to initialize the POA." << std::endl;
  }

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

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

  if (CORBA::is_nil(notify_factory.in())) {
    std::cerr << "Unable to find notify factory" << std::endl;
  }

  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 crete event channel" << std::endl;
  }

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

  CosNotifyComm::StructuredPushSupplier_var supplier =
    servant->_this();

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

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

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


  CosNotification::EventTypeSeq added (1);
  CosNotification::EventTypeSeq removed (1);
  added.length (1);
  removed.length (1);
  added[0].domain_name = CORBA::string_dup ("OCI_TAO");
  added[0].type_name = CORBA::string_dup ("examples");

  removed[0].domain_name = CORBA::string_dup ("*");
  removed[0].type_name = CORBA::string_dup ("*");

  s_proxy_consumer_->offer_change(added, removed);
}
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;
  try
    {
      Supplier_Client client;
      status = client.init (argc, argv);

      if (status == 0)
        {
          CosNotifyChannelAdmin::EventChannel_var ec =
            client.create_event_channel ("MyEventChannel", 0);

          CORBA::ORB_ptr orb = client.orb ();

          sig_i* sig_impl;
          ACE_NEW_RETURN (sig_impl, sig_i (orb), 1);
          PortableServer::ServantBase_var owner_transfer(sig_impl);

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

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

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

          sig_var sig = sig::_narrow (object.in ());

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

          // Output the IOR to the <ior_output_file>
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
          if (output_file != 0)
            {
              ACE_OS::fprintf (output_file, "%s", ior.in ());
              ACE_OS::fclose (output_file);
            }

          CosNotifyChannelAdmin::SupplierAdmin_var admin =
            create_supplieradmin (ec.in ());
          if (!CORBA::is_nil (admin.in ()))
            {
              create_suppliers (admin.in (), client.root_poa ());

              sig_impl->wait_for_startup();

              ACE_DEBUG ((LM_DEBUG,
                          "1 supplier sending %d events...\n", max_events));
              for (int i = 0; i < max_events; ++i)
              {
                ACE_DEBUG ((LM_DEBUG, "+"));
                SendEvent (i);
              }
              ACE_DEBUG ((LM_DEBUG,
                          "\nSupplier sent %d events.\n", max_events));

              ACE_OS::unlink (ior_output_file);
              supplier_1->disconnect ();

              ec->destroy ();
            }
        }
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Supplier Error: ");
      status = 1;
    }

  return status;
}
Exemple #23
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    Consumer_Client client;

    int status = client.init (argc, argv);
    ACE_ASSERT(status == 0);
    ACE_UNUSED_ARG(status);

    CosNotifyChannelAdmin::EventChannel_var ec =
      client.create_event_channel ("MyEventChannel", 1);

    CORBA::ORB_ptr orb = client.orb ();
    CORBA::Object_var object =
      orb->string_to_object (ior);

    sig_var sig = sig::_narrow (object.in ());

    ACE_ASSERT(! CORBA::is_nil (sig.in ()));

    CosNotifyChannelAdmin::ConsumerAdmin_var admin =
      create_consumeradmin (ec.in ());

    if (filter)
    {
      CosNotifyFilter::FilterFactory_var ffact =
        ec->default_filter_factory ();

      CosNotifyFilter::Filter_var filter =
        ffact->create_filter ("TCL");

      ACE_ASSERT(! CORBA::is_nil(filter.in()));

      CosNotifyFilter::ConstraintExpSeq constraint_list (1);
      constraint_list.length(1);

      constraint_list[0].event_types.length (0);
      constraint_list[0].constraint_expr = CORBA::string_dup(ACE_TEXT_ALWAYS_CHAR (constraintString));

      filter->add_constraints (constraint_list);

      admin->add_filter(filter.in());
    }

    ACE_ASSERT (!CORBA::is_nil (admin.in ()));
    create_consumers(admin.in (), &client);

    // Tell the supplier to go
    sig->go ();

    client.ORB_run( );
    ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));

    sig->done ();

    return 0;

  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: Consumer exception: ");
  }

  return 1;
}
Exemple #24
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;

  try
    {
      Consumer_Client client;
      status = client.init (argc, argv);

      if (status != 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Error: Client init failed.\n"),
                            1);
        }

      CosNotifyChannelAdmin::EventChannel_var ec =
        client.create_event_channel ("MyEventChannel", 0);

#ifdef TEST_QOS_MAX_QUEUE_LENGTH
      ACE_OS::printf ("%s: setting max queue length to 1000\n", argv[0]);
      CosNotification::AdminProperties properties(1);
      properties.length(1);
      properties[0].name = CORBA::string_dup (CosNotification::MaxQueueLength);
      properties[0].value <<= 1000;
      ec->set_admin(properties);
#endif //TEST_QOS_MAX_QUEUE_LENGTH

      CORBA::ORB_ptr orb = client.orb ();
      CORBA::Object_var object =
        orb->string_to_object (ior);

      MonitorTestInterface_var sig =
        MonitorTestInterface::_narrow (object.in ());

      if (CORBA::is_nil (sig.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Error: Narrow failed.\n"),
                            1);
        }

      CosNotifyChannelAdmin::ConsumerAdmin_var admin =
        create_consumeradmin (ec.in ());

      if (CORBA::is_nil (admin.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Error: nil ConsumerAdmin.\n"),
                            1);
        }

      create_consumers (admin.in (), &client);

      sig->running (MonitorTestInterface::Consumer);

      ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n"));

      FILE* ready_file = ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ready_output_file), "w");

      if (ready_file == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot open ready file for writing\n"),
                            1);
        }

      ACE_OS::fprintf (ready_file, "ready\n");
      ACE_OS::fclose (ready_file);

      client.ORB_run ();
#ifdef PAUSE_ON_EXIT
      _cputs( "All events received. Still connected.\n");
      _cputs( "Hit a key to exit consumer: " );
      _getch();
#endif // PAUSE_ON_EXIT
      ACE_DEBUG ((LM_DEBUG, "Consumer done.\n"));
      consumer_1->disconnect ();

      ec->destroy ();

      sig->finished (MonitorTestInterface::Consumer);
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception ("Consumer Error: ");
      status = 1;
    }

  return status;
}
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    int status = 0;
    ACE_Auto_Ptr< sig_i > sig_impl;
    try
    {
        Supplier_Client client;
        status = client.init (argc, argv);

        if (status == 0)
        {
            CosNotifyChannelAdmin::EventChannel_var ec =
                client.create_event_channel ("MyEventChannel", 0);

            if (use_deadline_ordering)
            {
                CosNotification::QoSProperties qos (1);
                qos.length (1);
                qos[0].name = CORBA::string_dup (CosNotification::OrderPolicy);
                qos[0].value <<= (CORBA::Short)CosNotification::DeadlineOrder;
                ec->set_qos (qos);
            }

            sig_impl.reset( new sig_i( client.orb() ) );
            sig_var sig = sig_impl->_this ();

            // If the ior_output_file exists, output the ior to it
            if (ior_output_file != 0)
            {
                CORBA::String_var ior =
                    client.orb ()->object_to_string (sig.in ());

                FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
                ACE_ASSERT (output_file != 0);
                ACE_OS::fprintf (output_file, "%s", ior.in ());
                ACE_OS::fclose (output_file);
            }

            CosNotifyChannelAdmin::SupplierAdmin_var admin =
                create_supplieradmin (ec.in ());
            ACE_ASSERT(!CORBA::is_nil (admin.in ()));

            create_suppliers (admin.in (), client.root_poa ());

            sig_impl->wait_for_startup();

            ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", num_events));
            for (int i = 0; i < num_events; ++i)
            {
                ACE_DEBUG((LM_DEBUG, "+"));
                SendEvent (i + 1);
            }
            ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", num_events));

            sig_impl->wait_for_completion();

            ACE_OS::unlink (ior_output_file);

            supplier_1->disconnect();

            ec->destroy();
        }
    }
    catch (const CORBA::Exception& e)
    {
        e._tao_print_exception ("Error: ");
        status = 1;
    }

    return status;
}
Exemple #26
0
int
TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[])
{
  // Check if -ORBDaemon is specified and if so, daemonize at this moment,
  // -ORBDaemon in the ORB core is faulty, see bugzilla 3335
  TAO_Daemon_Utility::check_for_daemon (argc, argv);

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

  // initalize the ORB.
  if (this->init_ORB (argc, argv) != 0)
    return -1;

  this->notify_service_ = TAO_Notify_Service::load_default ();

  if (this->notify_service_ == 0)
    {
      if (TAO_debug_level > 0)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("Service not found. Check service ")
                      ACE_TEXT ("configurator file.\n")));
        }
      return -1;
    }

  if (this->separate_dispatching_orb_)
    {
      if (this->init_dispatching_ORB (argc, argv) != 0)
        {
          return -1;
        }

      this->notify_service_->init_service2 (this->orb_.in (), this->dispatching_orb_.in());
    }
  else
    {
      this->notify_service_->init_service (this->orb_.in ());
    }

  this->logging_worker_.start();

  if (this->nthreads_ > 0) // we have chosen to run in a thread pool.
    {
      if (TAO_debug_level > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT("Running %d ORB threads\n"),
                      this->nthreads_));
        }
      worker_.orb (this->orb_.in ());

      // Task activation flags.
      long const flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        this->orb_->orb_core ()->orb_params ()->thread_creation_flags ();

      int const priority =
        ACE_Sched_Params::priority_min (ACE_Utils::truncate_cast<ACE_Sched_Params::Policy> (this->orb_->orb_core ()->orb_params ()->sched_policy ()),
                                        ACE_Utils::truncate_cast<int> (this->orb_->orb_core ()->orb_params ()->scope_policy ()));

      if (worker_.activate (flags,
                            this->nthreads_, 0, priority) != 0)
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "Cannot activate client threads\n"), -1);
        }
    }

  // Check first if the naming service
  if (this->use_name_svc_)
    {
      // Resolve the naming service.
      int const ns_ret = this->resolve_naming_service ();

      if (ns_ret != 0)
        return -1;
    }

  if (TAO_debug_level > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT("\nStarting up the Notification Service...\n")));
    }

  // Activate the factory
  this->notify_factory_ =
    notify_service_->create (this->poa_.in (),
                             this->notify_factory_name_.c_str ());

  ACE_ASSERT (!CORBA::is_nil (this->notify_factory_.in ()));

  if (this->bootstrap_) // Enable corbaloc usage
    {
      CORBA::Object_var table_object =
        this->orb_->resolve_initial_references ("IORTable");

      IORTable::Table_var adapter =
        IORTable::Table::_narrow (table_object.in ());

      if (CORBA::is_nil (adapter.in ()))
        {
          if (TAO_debug_level > 0)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          "Nil IORTable. corbaloc support not enabled.\n"));
            }
        }
      else
        {
          CORBA::String_var ior =
            this->orb_->object_to_string (this->notify_factory_.in ());
          adapter->bind (this->notify_factory_name_.c_str (), ior.in ());
        }
    }

  // Register with the Name service, if asked
  if (this->use_name_svc_ && !CORBA::is_nil (this->naming_.in ()))
    {
      CosNaming::Name_var name =
        this->naming_->to_name (this->notify_factory_name_.c_str ());

      this->naming_->rebind (name.in (),
                             this->notify_factory_.in ());

      if (TAO_debug_level > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      "Registered with the naming service as: %C\n",
                      this->notify_factory_name_.c_str()));
        }

      if (this->register_event_channel_)
        {
          // If we don't have any name configured, default to the standard name
          if (this->notify_channel_name_.is_empty ())
            {
              notify_channel_name_.insert (NOTIFY_CHANNEL_NAME);
            }

          for (ACE_Unbounded_Set<ACE_CString>::const_iterator ci (
                this->notify_channel_name_); !ci.done(); ci++)
            {
              // create an event channel
              CosNotifyChannelAdmin::ChannelID id;

              CosNotification::QoSProperties initial_qos;
              CosNotification::AdminProperties initial_admin;

              CosNotifyChannelAdmin::EventChannel_var ec;
              TAO_Notify_EventChannelFactory* factory_impl =
                dynamic_cast<TAO_Notify_EventChannelFactory*> (
                  this->notify_factory_->_servant ());
              if (factory_impl == 0)
                {
                  ec = this->notify_factory_->create_channel (initial_qos,
                                                              initial_admin,
                                                              id);
                }
              else
                {
                  ec = factory_impl->create_named_channel (
                                       initial_qos, initial_admin,id,
                                       (*ci).c_str ());
                }

              name = this->naming_->to_name ((*ci).c_str ());

              this->naming_->rebind (name.in (), ec.in ());

              if (TAO_debug_level > 0)
                {
                  ORBSVCS_DEBUG ((LM_DEBUG,
                              "Registered an Event Channel with the naming "
                              "service as: %C\n",
                              (*ci).c_str()));
                }
            }
        }
    }

  // Write IOR to a file, if asked.
  // Note: do this last to ensure that we're up and running before the file is written
  CORBA::String_var str =
    this->orb_->object_to_string (this->notify_factory_.in ());

  if (this->ior_output_file_name_)
    {
       FILE* ior_output_file = ACE_OS::fopen (ior_output_file_name_,
                                              ACE_TEXT("w"));
       if (ior_output_file == 0)
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "Unable to open %s for writing: %p\n",
                             this->ior_output_file_name_, "Notify_Service"),
                             -1);
        }

      ACE_OS::fprintf (ior_output_file, "%s", str.in ());
      ACE_OS::fclose (ior_output_file);
    }
  else if (TAO_debug_level > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("The Notification Event Channel Factory IOR is <%C>\n"),
                  str.in ()));
    }

  return 0;
}
Exemple #27
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Auto_Ptr< sig_i > sig_impl;
  int status = 0;
  try
  {
    Supplier_Client client;

    status = client.init (argc, argv);

    if (status == 0)
    {
      CosNotifyChannelAdmin::EventChannel_var ec =
        client.create_event_channel ("MyEventChannel", 0);

      CORBA::ORB_ptr orb = client.orb ();

      sig_impl.reset( new sig_i( orb ) );
      sig_var sig = sig_impl->_this ();

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

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

      CosNotifyChannelAdmin::SupplierAdmin_var admin =
        create_supplieradmin (ec.in ());
      if (!CORBA::is_nil (admin.in ()))
      {
        create_suppliers(admin.in (), client.root_poa ());

        sig_impl->wait_for_startup();

        ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d batches of %d events...\n", num_batches, PER_BATCH));
        for (int i = 0; i < num_batches; ++i)
        {
          ACE_DEBUG((LM_DEBUG, "+"));
          SendEvents (i);
        }
        ACE_DEBUG((LM_DEBUG, "\nSupplier waiting for consumer completion...\n"));

        sig_impl->wait_for_completion();

        ACE_DEBUG((LM_DEBUG, "\nSupplier finished.\n"));

        ACE_OS::unlink (ior_output_file);

        ec->destroy();
      }
    }
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: Supplier exception: ");
    status = 1;
  }

  return status;
}
Exemple #28
0
int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;
  ACE_Auto_Ptr<sig_i> sig_impl;
  try
    {
      Supplier_Client client;
      ACE_Argv_Type_Converter argcon (argc, argv);
      status = client.init (argcon.get_argc (), argcon.get_TCHAR_argv ());

      if (status == 0)
        {
          CosNotifyChannelAdmin::EventChannel_var ec =
            client.create_event_channel ("MyEventChannel", 0);

          sig_impl.reset (new sig_i (client.orb ()));
          sig_var sig = sig_impl->_this ();

          // If the ior_output_file exists, output the ior to it
          if (ior_output_file != 0)
            {
              CORBA::String_var ior =
                client.orb ()->object_to_string (sig.in ());

              FILE *output_file= ACE_OS::fopen (ior_output_file, ACE_TEXT ("w"));
              ACE_ASSERT (output_file != 0);
              ACE_OS::fprintf (output_file, "%s", ior.in ());
              ACE_OS::fclose (output_file);
            }

          CosNotifyChannelAdmin::SupplierAdmin_var admin =
            create_supplieradmin (ec.in ());
          ACE_ASSERT (!CORBA::is_nil (admin.in ()));

          create_suppliers (admin.in (), client.root_poa ());

          sig_impl->wait_for_startup ();

          // If this is changed, you should update max_events
          // found in Notify_Push_Consumer.cpp
          int batch_size = 4;
          int num_events = 80 / batch_size;
          ACE_DEBUG ((LM_DEBUG,
                      "1 supplier sending %d batches of %d events...\n",
                      num_events, batch_size));
          CosNotification::EventBatch events;
          events.length(batch_size);
          for (int i = 0; i < num_events; ++i)
            {
              supplier_1->send_events (events);
            }
          ACE_DEBUG ((LM_DEBUG, "\nSupplier sent %d events.\n", num_events));

          sig_impl->wait_for_completion ();

          ACE_OS::unlink (ior_output_file);

          supplier_1->disconnect ();

          ec->destroy ();
        }
    }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: ");
    status = 1;
  }

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

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

    if (CORBA::is_nil (poa_object.in())) {
      std::cerr << "Unable to initialize the POA." << std::endl;
      return 1;
    }

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

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

    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;
      return 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("MyEventChannel");
    CORBA::Object_var ecObj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannel_var ec =
      CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

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

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

    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers(ifgop,
      adminid);

    if (CORBA::is_nil (consumer_admin.in())) {
      std::cerr << "Unable to find consumer admin" << std::endl;
      return 1;
    }

    PortableServer::Servant_var<StructuredEventConsumer_i> servant =
      new StructuredEventConsumer_i(orb.in());

    CosNotifyComm::StructuredPushConsumer_var consumer = servant->_this();

    CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

    CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
      consumer_admin->obtain_notification_push_supplier(
          CosNotifyChannelAdmin::STRUCTURED_EVENT,
          consumeradmin_proxy_id);

    // The proxy that we are connected to.
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
    supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
      _narrow(proxy_supplier.in());

    if (CORBA::is_nil (supplier_proxy.in())) {
      std::cerr << "Unable to create structured push supplier proxy" << std::endl;
      return 1;
    }

    supplier_proxy->connect_structured_push_consumer(consumer.in());
    CosNotification::EventTypeSeq added (1);
    CosNotification::EventTypeSeq removed (1);
    added.length (1);
    removed.length (1);

    added[0].domain_name = CORBA::string_dup ("OCI_TAO");
    added[0].type_name = CORBA::string_dup ("examples");

    removed[0].domain_name = CORBA::string_dup ("*");
    removed[0].type_name = CORBA::string_dup ("*");

    supplier_proxy->subscription_change(added, removed);

    orb->run();
   }
   catch(const CORBA::Exception& ex)
    {
      std::cerr << "MessengerConsumer:: Caught exception: " << ex << std::endl;
      return 1;
    }
   std::cerr << "MessengerConsumer: success" << std::endl;
   return 0;
}
Exemple #30
0
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;
  }

}