diff options
Diffstat (limited to 'TAO/DevGuideExamples/NotifyService/OfferSubscriptions')
13 files changed, 728 insertions, 0 deletions
diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger.idl b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger.idl new file mode 100644 index 00000000000..df3027a9c49 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger.idl @@ -0,0 +1,8 @@ +// messenger.idl + +interface Messenger +{ + boolean send_message(in string user_name, + in string subject, + inout string message); +}; diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerClient.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerClient.cpp new file mode 100644 index 00000000000..f7e029ac598 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerClient.cpp @@ -0,0 +1,52 @@ +#include "MessengerC.h" +#include <orbsvcs/CosNamingC.h> +#include <iostream> + + +int ACE_TMAIN(int argc, ACE_TCHAR * argv[]) +{ + try + { + // Initialize orb + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + CORBA::Object_var rootObj = + orb->resolve_initial_references("NameService"); + + CosNaming::NamingContext_var rootContext = + CosNaming::NamingContext::_narrow(rootObj.in()); + + CosNaming::Name name; + name.length (1); + name[0].id = CORBA::string_dup ("MessengerService"); + + CORBA::Object_var messengerObj = rootContext->resolve(name); + + Messenger_var messenger = Messenger::_narrow(messengerObj.in()); + + if (CORBA::is_nil(messenger.in ())) { + std::cerr << "Argument is not a Messenger reference" << std::endl; + } + + CORBA::String_var message = CORBA::string_dup("Where can I get TAO?"); + + messenger->send_message ("person@company.com", + "OCI's Distribution of TAO", + message.inout()); + } + + catch(const CORBA::Exception& ex) + { + std::cerr << "Caught exception: " << ex << std::endl; + return 1; + } + + std::cout << "MessengerClient: success" << std::endl; + return 0; + +} + + + + + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerConsumer.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerConsumer.cpp new file mode 100644 index 00000000000..f5f9f0e6aa8 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerConsumer.cpp @@ -0,0 +1,116 @@ +#include <orbsvcs/CosNotifyChannelAdminC.h> +#include <orbsvcs/CosNotifyCommC.h> +#include <orbsvcs/CosNamingC.h> + +#include "StructuredEventConsumer_i.h" +#include <iostream> + +int +main(int argc, char *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::OR_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; + } + + StructuredEventConsumer_i servant(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; +} + + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerServer.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerServer.cpp new file mode 100644 index 00000000000..b3467a4e945 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/MessengerServer.cpp @@ -0,0 +1,63 @@ +#include <orbsvcs/CosNamingC.h> +#include "Messenger_i.h" +#include <iostream> +#include <fstream> +int +main(int argc, char * 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 object + Messenger_i messenger_servant(orb.in()); + + Messenger_var messenger = messenger_servant._this(); + + CosNaming::Name name; + name.length (1); + name[0].id = CORBA::string_dup("MessengerService"); + + rootNC->rebind(name, messenger.in()); + + CORBA::String_var str = orb->object_to_string (messenger.in()); + std::ofstream iorFile ("Messenger.ior"); + iorFile << str.in () << std::endl; + iorFile.close (); + std::cout << "IOR written to file Messenger.ior " << std::endl; + + // Accept requests + orb->run(); + } + catch(const CORBA::Exception& ex) + { + std::cerr << "MessengerServer::Caught exception: " << ex << std::endl; + return 1; + } + + return 0; +} + + + + + + + + + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.cpp new file mode 100644 index 00000000000..d41222adcdc --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.cpp @@ -0,0 +1,163 @@ +#include <orbsvcs/CosNotifyChannelAdminC.h> +#include <orbsvcs/CosNotifyCommC.h> +#include <orbsvcs/CosNamingC.h> + +#include "Messenger_i.h" +#include "StructuredEventSupplier_i.h" +#include <iostream> + +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::OR_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); + +} + + + +Messenger_i::~Messenger_i (void) +{ +} + + +CORBA::Boolean Messenger_i::send_message ( + const char * user_name, + const char * subject, + char *& message) + + throw (CORBA::SystemException) + +{ + + std::cout << "Message from: " << user_name << std::endl; + std::cout << "Subject: " << subject << std::endl; + std::cout << "Message: " << message << std::endl; + + + // Event Definition + CosNotification::StructuredEvent event; + + event.header.fixed_header.event_type.domain_name = + CORBA::string_dup("OCI_TAO"); + // string + event.header.fixed_header.event_type.type_name = + CORBA::string_dup("examples"); + // string + event.header.fixed_header.event_name = + CORBA::string_dup("myevent"); + + // OptionalHeaderFields + // PropertySeq + + // sequence<Property>: string name, any value + 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; + + s_proxy_consumer_->push_structured_event(event); + + return 1; + +} + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.h b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.h new file mode 100644 index 00000000000..2e6cabb4b3b --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/Messenger_i.h @@ -0,0 +1,30 @@ +#ifndef MESSENGER_H_ +#define MESSENGER_H_ + +#include <orbsvcs/CosNotifyChannelAdminC.h> +#include "MessengerS.h" + +class Messenger_i : public POA_Messenger +{ +public: + Messenger_i (CORBA::ORB_ptr orb); + virtual ~Messenger_i (void); + + CORBA::Boolean send_message ( + const char * user_name, + const char * subject, + char *& message) + + throw (CORBA::SystemException); + +private: + CORBA::ORB_var orb_; + CosNotifyChannelAdmin::StructuredProxyPushConsumer_var s_proxy_consumer_; +}; + +#endif + + + + + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/OfferSubscriptions.mpc b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/OfferSubscriptions.mpc new file mode 100644 index 00000000000..3329ee1c1ee --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/OfferSubscriptions.mpc @@ -0,0 +1,23 @@ +project(*Server): taoexe, portableserver, namingexe, notification_skel { + Source_Files { + StructuredEventSupplier_i.cpp + MessengerServer.cpp + Messenger_i.cpp + } +} + +project(*Client): taoexe, namingexe, notification { + Source_Files { + MessengerC.cpp + MessengerClient.cpp + } +} + +project(*Consumer): taoexe, portableserver, namingexe, notification_skel { + IDL_Files { + } + Source_Files { + MessengerConsumer.cpp + StructuredEventConsumer_i.cpp + } +} diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/README b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/README new file mode 100644 index 00000000000..a4e60f8ca9b --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/README @@ -0,0 +1,66 @@ +Event Notification Service + + +File: examples/NotifyService/OfferSubscriptions/README + + +This example extends the NotifyService/Messenger example by incorporating +"offers" and "subscriptions" into the utilization of the Notification +channel. + +The publication of "offers" by a supplier, informs consumers of the +Notification channel about the types of events it will be producing. This +is accomplished via the 'offer_change()' operation. + +Moreover, the example demonstrates how consumers can inform Notification +channel suppliers about the types of events in which they are interested. +The set of events in which a consumer is interested is called a "subscription" +and can be communicated via the 'subscription_change()' operation. + + + +The Client code is stored in: + +examples/NotifyService/OfferSubscriptions/MessengerClient.cpp + +The Server code is stored in: + +examples/NotifyService/OfferSubscriptions/MessengerServer.cpp + +The Consumer code is stored in: + +examples/NotifyService/OfferSubscriptions/MessengerConsumer.cpp + + +How to Run +---------- + +To start the Naming Service: +---------------------------- +$TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -o ns.ior& + +To start the Notification Service: +--------------------------------- +$TAO_ROOT/orbsvcs/Notify_Service/Notify_Service -ORBInitRef NameService=file://ns.ior& + +To start the server/supplier +---------------------------- +./MessengerServer -ORBInitRef NameService=file://ns.ior + +To start the consumer +--------------------- +./MessengerConsumer -ORBInitRef NameService=file://ns.ior + +To start the client +------------------- +./MessengerClient -ORBInitRef NameService=file://ns.ior + + + +Exeuction via Perl Script +------------------------- + +A Perl script has been created to automate the steps shown +above. This script can be run via the following command: + +./run_test.pl diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.cpp new file mode 100644 index 00000000000..61b436fbf8c --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.cpp @@ -0,0 +1,49 @@ +#include "StructuredEventConsumer_i.h" +#include <tao/PortableServer/PS_CurrentC.h> +#include <iostream> + +StructuredEventConsumer_i::StructuredEventConsumer_i(CORBA::ORB_ptr orb) + : orb_(CORBA::ORB::_duplicate(orb)) +{ +} + +void +StructuredEventConsumer_i::push_structured_event( + const CosNotification::StructuredEvent &event + ) + throw (CORBA::SystemException, CosEventComm::Disconnected) + +{ + + const char *value; + + for (unsigned int i=0; i<event.filterable_data.length(); i++) { + event.filterable_data[i].value >>= value; + std::cout << event.filterable_data[i].name << "\t" <<value<< std::endl; + } + +} + +void +StructuredEventConsumer_i::disconnect_structured_push_consumer( + ) + throw(CORBA::SystemException) +{ + + CORBA::Object_var obj = orb_->resolve_initial_references ("POACurrent"); + PortableServer::Current_var current = + PortableServer::Current::_narrow (obj.in()); + PortableServer::POA_var poa = current->get_POA (); + PortableServer::ObjectId_var objectId = current->get_object_id (); + poa->deactivate_object (objectId.in()); + +} + +void +StructuredEventConsumer_i::offer_change( + const CosNotification::EventTypeSeq &, + const CosNotification::EventTypeSeq & + ) + throw (CORBA::SystemException, CosNotifyComm::InvalidEventType) +{ +} diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.h b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.h new file mode 100644 index 00000000000..9fd15085011 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventConsumer_i.h @@ -0,0 +1,29 @@ +#ifndef _EVENTCONSUMER_I_H_ +#define _EVENTCONSUMER_I_H_ + +#include <orbsvcs/CosNotifyChannelAdminS.h> + +class StructuredEventConsumer_i : public POA_CosNotifyComm::StructuredPushConsumer +{ +public: + StructuredEventConsumer_i(CORBA::ORB_ptr orb); + + virtual void push_structured_event( + const CosNotification::StructuredEvent ¬ification + ) + throw (CORBA::SystemException, CosEventComm::Disconnected); + + virtual void offer_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ) + throw (CORBA::SystemException, CosNotifyComm::InvalidEventType); + + virtual void disconnect_structured_push_consumer( + ) + throw(CORBA::SystemException); +private: + CORBA::ORB_var orb_; +}; + +#endif diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.cpp b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.cpp new file mode 100644 index 00000000000..6160191438a --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.cpp @@ -0,0 +1,31 @@ +#include "StructuredEventSupplier_i.h" +#include <tao/PortableServer/PS_CurrentC.h> + +StructuredEventSupplier_i::StructuredEventSupplier_i(CORBA::ORB_ptr orb) + : orb_(CORBA::ORB::_duplicate(orb)) +{ +} + +void +StructuredEventSupplier_i::disconnect_structured_push_supplier () + throw (CORBA::SystemException) +{ + + CORBA::Object_var obj = orb_->resolve_initial_references ("POACurrent"); + PortableServer::Current_var current = + PortableServer::Current::_narrow (obj.in()); + PortableServer::POA_var poa = current->get_POA (); + PortableServer::ObjectId_var objectId = current->get_object_id (); + poa->deactivate_object (objectId.in()); + +} + +void +StructuredEventSupplier_i::subscription_change ( + const CosNotification::EventTypeSeq &, + const CosNotification::EventTypeSeq & + ) + throw (CORBA::SystemException, CosNotifyComm::InvalidEventType) +{ +} + diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.h b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.h new file mode 100644 index 00000000000..be820a45533 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/StructuredEventSupplier_i.h @@ -0,0 +1,23 @@ +#ifndef _EVENTSUPPLIER_I_H_ +#define _EVENTSUPPLIER_I_H_ + +#include <orbsvcs/CosNotifyChannelAdminS.h> + +class StructuredEventSupplier_i : public POA_CosNotifyComm::StructuredPushSupplier +{ +public: + // Constructor + StructuredEventSupplier_i(CORBA::ORB_ptr orb); + virtual void disconnect_structured_push_supplier () + throw (CORBA::SystemException); + + virtual void subscription_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ) + throw(CORBA::SystemException, CosNotifyComm::InvalidEventType); +private: + CORBA::ORB_var orb_; +}; + +#endif diff --git a/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/run_test.pl b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/run_test.pl new file mode 100644 index 00000000000..540c676a957 --- /dev/null +++ b/TAO/DevGuideExamples/NotifyService/OfferSubscriptions/run_test.pl @@ -0,0 +1,75 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +use Env (ACE_ROOT); +use lib "$ACE_ROOT/bin"; +use PerlACE::Run_Test; + +$nsiorfile = PerlACE::LocalFile("ns.ior"); +$messiorfile = PerlACE::LocalFile("Messenger.ior"); +$notify_ior = PerlACE::LocalFile("notify.ior"); +$arg_ns_ref = "-ORBInitRef NameService=file://$nsiorfile"; +unlink $nsiorfile; +unlink $messiorfile; +unlink $notify_ior; + +# start Naming Service +$NameService = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/Naming_Service"; +$NS = new PerlACE::Process($NameService, "-o $nsiorfile"); +$NS->Spawn(); +if (PerlACE::waitforfile_timed ($nsiorfile, 10) == -1) { + print STDERR "ERROR: cannot find file $nsiorfile\n"; + $NS->Kill(); + exit 1; +} + +# start Notification Service + +$NotifyService = "$ENV{TAO_ROOT}/orbsvcs/Notify_Service/Notify_Service"; +$NFS = new PerlACE::Process($NotifyService, "$arg_ns_ref -IORoutput $notify_ior"); +$NFS->Spawn(); +# the ior file is only used to wait for the service to start +if (PerlACE::waitforfile_timed ($notify_ior, 10) == -1) { + print STDERR "ERROR: Timed out waiting for $notify_ior\n"; + $NS->Kill (); + $NFS->Kill (); + exit 1; +} + +# start MessengerServer +$S = new PerlACE::Process("MessengerServer", $arg_ns_ref); +$S->Spawn(); + +# Wait for the MessengerServer +if (PerlACE::waitforfile_timed ($messiorfile, 10) == -1) { + print STDERR "ERROR: Timed out waiting for $messiorfile\n"; + $S->Kill(); + $NS->Kill (); + $NFS->Kill (); + exit 1; +} +# start MessengerConsumer +$MC = new PerlACE::Process("MessengerConsumer", $arg_ns_ref); +$MC->Spawn(); + +# start MessengerClient +$C = new PerlACE::Process("MessengerClient", $arg_ns_ref); +if ($C->SpawnWaitKill(10) != 0) { + $MC->Kill(); + $S->Kill(); + $NFS->Kill(); + $NS->Kill(); + exit (1); +} + +$MC->Kill(); +$S->Kill(); +$NFS->Kill(); +$NS->Kill(); + +unlink $nsiorfile; +unlink $messiorfile; +unlink $notify_ior; + +exit 0; |