summaryrefslogtreecommitdiff
path: root/TAO/DevGuideExamples
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2008-10-28 16:21:15 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2008-10-28 16:21:15 +0000
commit758479e043209fd58d713591f070732e6933d1bb (patch)
treee14b2bb0891494fafd9bc04a358229f2fc041073 /TAO/DevGuideExamples
parent489563526140cfb95c5bfa16c4e19b2ce4f80005 (diff)
downloadATCD-758479e043209fd58d713591f070732e6933d1bb.tar.gz
Tue Oct 28 16:20:00 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/DevGuideExamples')
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/Event.idl15
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/Event_i.h66
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/Notify.mpc22
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/consumer.cpp177
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/notify.conf2
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/readme.txt4
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/run_test.pl81
-rw-r--r--TAO/DevGuideExamples/ValueTypes/Notify/supplier.cpp216
8 files changed, 0 insertions, 583 deletions
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/Event.idl b/TAO/DevGuideExamples/ValueTypes/Notify/Event.idl
deleted file mode 100644
index 128524db35d..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/Event.idl
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-#include "tao/LongSeq.pidl"
-
-valuetype MyEvent
-{
- public string name;
- public long kind;
- private CORBA::LongSeq payload;
-
- void dump();
- long size();
- void add_long(in long n);
-};
-
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/Event_i.h b/TAO/DevGuideExamples/ValueTypes/Notify/Event_i.h
deleted file mode 100644
index a767bd47a5b..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/Event_i.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// $Id$
-
-#ifndef EVENT_H_
-#define EVENT_H_
-
-#include "EventS.h"
-
-#include <iostream>
-#include "tao/Valuetype/ValueFactory.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-#pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-class MyEvent_i
- : public virtual OBV_MyEvent
- , public virtual CORBA::DefaultValueRefCountBase
-{
-public:
- MyEvent_i(const char* n, CORBA::Long k)
- {
- name(n);
- kind(k);
- }
-
- virtual void dump ()
- {
- CORBA::LongSeq& pl = payload();
- ACE_DEBUG((LM_DEBUG, "\nPayload contents.\n"));
- for (CORBA::ULong i = 0; i < pl.length(); ++i)
- {
- ACE_DEBUG((LM_DEBUG, "%d = %d\n", i, pl[i]));
- }
- ACE_DEBUG((LM_DEBUG, "\n"));
- }
-
- virtual CORBA::Long size ()
- {
- return payload().length();
- }
-
- virtual void add_long (CORBA::Long n)
- {
- CORBA::LongSeq& pl = payload();
- CORBA::ULong idx = pl.length();
- pl.length(idx + 1);
- pl[idx] = n;
- }
-};
-
-class MyEventFactory
- : public virtual CORBA::ValueFactoryBase
-{
-public:
-
- virtual CORBA::ValueBase * create_for_unmarshal ()
- {
- // It doesn't matter what values we construct it with
- // because they will be overwritten with the demarshaled values.
- return new MyEvent_i("", -1);
- }
-};
-
-
-#endif /* EVENT_H_ */
-
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/Notify.mpc b/TAO/DevGuideExamples/ValueTypes/Notify/Notify.mpc
deleted file mode 100644
index ac56f4b75f4..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/Notify.mpc
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id$
-
-project(*supplier) : taoexe, portableserver, valuetype, notify, portableserver, event_skel {
- exename = supplier
- source_files {
- supplier.cpp
- }
- header_files {
- Event_i.h
- }
-}
-
-project(*consumer) : taoexe, portableserver, valuetype, notify, portableserver, event_skel {
- exename = consumer
- source_files {
- consumer.cpp
- }
- header_files {
- Event_i.h
- }
-}
-
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/consumer.cpp b/TAO/DevGuideExamples/ValueTypes/Notify/consumer.cpp
deleted file mode 100644
index 099ad96ad48..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/consumer.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// $Id$
-
-// This supplier requires that the Notify_Service is started with
-// -IOROutput notify.ior -channel -nonamesvc
-// at minimum.
-const char* notify_ior = "corbaloc::localhost:8888/NotifyEventChannelFactory";
-
-#include "Event_i.h"
-
-#include "orbsvcs/CosEventCommS.h"
-
-#include "orbsvcs/CosNotifyChannelAdminC.h"
-
-#include "tao/corba.h"
-#include "tao/ORB_Core.h"
-
-#include <iostream>
-#include <stdexcept>
-
-const char* ec_ior_output_file = "ec.ior";
-
-class TestConsumer : public POA_CosEventComm::PushConsumer
-{
- int num_events_;
-
- CosEventChannelAdmin::ConsumerAdmin_var admin_;
- CosEventChannelAdmin::ProxyPushSupplier_var supplier_;
- PortableServer::ObjectId_var id_;
- int event_count_;
- bool connected_;
- PortableServer::POA_ptr poa_;
- CORBA::ORB_ptr orb_;
-public:
-
- TestConsumer(int evts,
- CosNotifyChannelAdmin::EventChannelFactory_ptr ecf,
- PortableServer::POA_ptr poa,
- CORBA::ORB_ptr orb)
- : num_events_(evts)
- , event_count_(0)
- , connected_(false)
- , poa_(poa)
- , orb_(orb)
- {
- if (CORBA::is_nil(ecf))
- throw std::invalid_argument("TestConsumer::CTOR: is_nil(ecf)");
-
- CosNotifyChannelAdmin::ChannelID id;
- CosNotification::QoSProperties initial_qos;
- CosNotification::AdminProperties initial_admin;
-
- CosEventChannelAdmin::EventChannel_var ec
- = ecf->create_channel (initial_qos,
- initial_admin,
- id);
-
- CORBA::String_var ior = orb_->object_to_string (ec.in());
-
- // If the ec_ior_output_file exists, output the ior to it
- if (ec_ior_output_file != 0)
- {
- FILE *output_file= ACE_OS::fopen (ec_ior_output_file, ACE_TEXT("w"));
- if (output_file == 0)
- throw std::invalid_argument("Cannot open channel ior output file");
-
- ACE_OS::fprintf (output_file, "%s", ior.in ());
- ACE_OS::fclose (output_file);
- }
-
- ACE_DEBUG((LM_DEBUG, "TestConsumer: write channel ior to file %s\n", ec_ior_output_file));
-
- admin_ = ec->for_consumers();
- CORBA::Object_var obj = admin_->obtain_push_supplier();
- supplier_ = CosEventChannelAdmin::ProxyPushSupplier::_unchecked_narrow(obj.in());
-
- id_ = poa->activate_object(this);
- obj = poa->id_to_reference(id_.in());
- CosEventComm::PushConsumer_var consumer = CosEventComm::PushConsumer::_narrow(obj.in());
-
- supplier_->connect_push_consumer(consumer.in());
- connected_ = true;
- }
-
- virtual ~TestConsumer() {
- }
-
- virtual void disconnect_push_consumer()
- {
- std::cout << "disconnect_push_consumer()." << std::endl;
- }
-
- virtual void push(const CORBA::Any& a)
- {
- MyEvent* vt;
- a >>= vt;
-
- std::cout << std::endl
- << "Received MyEvent name=" << vt->name()
- << ", kind=" << vt->kind()
- << ", size=" << vt->size()
- << std::endl;
-
- vt->dump();
-
- if ( ++ event_count_ >= num_events_ && num_events_ > 0) {
- std::cout << "Consumer disconnecting after receiving "
- << event_count_ << " events." << std::endl;
- disconnect();
- }
- }
-
- void disconnect() {
- try {
- if (connected_) {
- connected_ = false;
- poa_->deactivate_object(id_.in());
- supplier_->disconnect_push_supplier();
- orb_->shutdown(0);
- std::cout << "Consumer disconnected." << std::endl;
- }
- } catch(const CORBA::Exception& e) {
- std::cerr << "TestConsumer::disconnect() exception: " << e << std::endl;
- }
- }
-
- void disconnect_self() {
- }
-
-};
-
-int ACE_TMAIN (int ac, ACE_TCHAR* av[]) {
-
- int num_events = 0;
-
- try {
- CORBA::ORB_var orb = CORBA::ORB_init(ac, av);
-
- CORBA::ValueFactoryBase_var factory = new MyEventFactory;
- CORBA::String_var id = _tc_MyEvent->id();
- orb->register_value_factory(id.in(), factory.in());
-
- CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
- PortableServer::POA_var poa =
- PortableServer::POA::_unchecked_narrow(obj.in());
- PortableServer::POAManager_var mgr = poa->the_POAManager();
-
- obj = orb->string_to_object(notify_ior);
- CosNotifyChannelAdmin::EventChannelFactory_var ecf
- = CosNotifyChannelAdmin::EventChannelFactory::_unchecked_narrow(obj.in());
-
- if (ac > 1) {
- num_events = ACE_OS::atoi(av[1]);
- }
-
- mgr->activate();
-
- {
- TestConsumer consumer(num_events, ecf.in(), poa.in(), orb.in());
- ACE_Time_Value tvMaxRunTime(300);
- orb->run(tvMaxRunTime);
- }
-
- poa->destroy(1, 1);
- orb->destroy();
-
- return 0;
-
- } catch(const CORBA::Exception& e) {
- std::cerr << "Consumer: main() exception: " << e << std::endl;
- } catch(const std::invalid_argument& e) {
- std::cerr << "Consumer: main() exception: " << e.what () << std::endl;
- } catch(...) {
- std::cerr << "Consumer: main() unknown exception: " << std::endl;
- }
-
- return 1;
-}
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/notify.conf b/TAO/DevGuideExamples/ValueTypes/Notify/notify.conf
deleted file mode 100644
index 3d7c070a962..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/notify.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 1 -SourceThreads 0 "
-
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/readme.txt b/TAO/DevGuideExamples/ValueTypes/Notify/readme.txt
deleted file mode 100644
index 9b671360a80..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/readme.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-// $Id$
-
-This test uses valuetypes within simple CosEC::Any events passed through the
-notification service.
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/run_test.pl b/TAO/DevGuideExamples/ValueTypes/Notify/run_test.pl
deleted file mode 100644
index 2a7d6c95094..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/run_test.pl
+++ /dev/null
@@ -1,81 +0,0 @@
-# $Id$
-
-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
- & eval 'exec perl -S $0 $argv:q'
- if 0;
-
-# $Id$
-# -*- perl -*-
-use Env(ACE_ROOT);
-use Env (TAO_ROOT);
-use lib "$ACE_ROOT/bin";
-use PerlACE::Run_Test;
-
-my $ec_ior = PerlACE::LocalFile ("ec.ior");
-my $notifyior = PerlACE::LocalFile ("notify.ior");
-my $notify_conf = PerlACE::LocalFile ("notify$PerlACE::svcconf_ext");
-
-my $TS = new PerlACE::Process ("$TAO_ROOT/orbsvcs/Notify_Service/Notify_Service",
- "-boot -orbendpoint iiop://:8888 -NoNameSvc -IORoutput $notifyior -ORBSvcConf " .
- "$notify_conf");
-my $SUP = new PerlACE::Process ("supplier");
-my $CONS = new PerlACE::Process ("consumer");
-
-unlink $ec_ior;
-unlink $notifyior;
-
-$TS->Spawn ();
-
-if (PerlACE::waitforfile_timed ($notifyior, $PerlACE::wait_interval_for_process_creation) == -1) {
- $TS->Kill ();
- exit 1;
-}
-
-print "****** Running consumer ******\n";
-
-## The consumer takes one argument indicating
-## how many events to receive before disconnecting.
-
-$CONS->Arguments("5");
-my $client = $CONS->Spawn();
-if ($client != 0) {
- $TS->Kill ();
- exit 1;
-}
-
-## The supplier needs wait after the consumer creates the event channel.
-if (PerlACE::waitforfile_timed ($ec_ior, 20) == -1) {
- $TS->Kill ();
- $client->Kill ();
- exit 1;
-}
-
-## The supplier takes two arguments.
-## The first indicates how many events to push.
-## The second indicates the payload size. (The payload is sequence<int>)
-
-print "****** Running supplier ******\n";
-
-$SUP->Arguments("10 5");
-my $server = $SUP->Spawn();
-if ($server != 0) {
- $TS->Kill();
- $CONS->Kill();
- exit 1;
-}
-
-$CONS->WaitKill(30);
-
-
-$server = $SUP->WaitKill(30);
-if ($server != 0) {
- $TS->Kill();
- $CONS->Kill();
- exit 1;
-}
-
-$TS->Kill ();
-
-unlink $ec_ior;
-unlink $notifyior;
-exit 0;
diff --git a/TAO/DevGuideExamples/ValueTypes/Notify/supplier.cpp b/TAO/DevGuideExamples/ValueTypes/Notify/supplier.cpp
deleted file mode 100644
index 97bbb208c9a..00000000000
--- a/TAO/DevGuideExamples/ValueTypes/Notify/supplier.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-// $Id$
-
-// This supplier requires that the Notify_Service is started with
-// -IOROutput notify.ior -channel -nonamesvc
-// at minimum.
-const char* notify_ior = "corbaloc::localhost:8888/NotifyEventChannelFactory";
-
-#include "Event_i.h"
-
-#include "orbsvcs/CosEventCommS.h"
-
-#include "orbsvcs/CosNotifyChannelAdminC.h"
-
-#include "tao/corba.h"
-#include "tao/ORB_Core.h"
-
-#include "ace/Reactor.h"
-#include "ace/Event_Handler.h"
-#include <iostream>
-#include <stdexcept>
-
-const ACE_Time_Value EVENT_DELAY(0, 10 * 1000);
-
-static MyEvent_var event_;
-
-const char* ec_ior = "file://ec.ior";
-
-class TestSupplier
-: public POA_CosEventComm::PushSupplier
-, public ACE_Event_Handler
-{
- int num_events_;
-
- CosEventChannelAdmin::SupplierAdmin_var admin_;
- CosEventChannelAdmin::ProxyPushConsumer_var consumer_;
- PortableServer::ObjectId_var id_;
- int event_count_;
- bool connected_;
- ACE_Reactor* reactor_;
- PortableServer::POA_ptr poa_;
- CORBA::ORB_ptr orb_;
-
-public:
-
- TestSupplier(int evts, CosNotifyChannelAdmin::EventChannelFactory_ptr ecf,
- CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa)
- : num_events_(evts)
- , event_count_(0)
- , connected_(false)
- , reactor_(orb->orb_core()->reactor())
- , poa_(poa)
- , orb_(orb)
- {
- if (reactor_ == 0 || CORBA::is_nil (ecf))
- throw std::invalid_argument("TestSupplier::CTOR: reactor == 0 || CORBA::is_nil(ecf)");
-
- CORBA::Object_var obj =
- this->orb_->string_to_object (ec_ior);
-
- ACE_DEBUG((LM_DEBUG, "TestSupplier: string_to_object from %s\n", ec_ior));
-
- CosNotifyChannelAdmin::EventChannel_var ec
- = CosNotifyChannelAdmin::EventChannel::_unchecked_narrow (obj.in ());
-
- admin_ = ec->for_suppliers();
- obj = admin_->obtain_push_consumer();
- consumer_ = CosEventChannelAdmin::ProxyPushConsumer::_unchecked_narrow(obj.in());
- id_ = poa->activate_object(this);
- obj = poa->id_to_reference(id_.in());
- CosEventComm::PushSupplier_var supplier =
- CosEventComm::PushSupplier::_unchecked_narrow(obj.in());
-
- consumer_->connect_push_supplier(supplier.in());
- connected_ = true;
-
- schedule_next_event(ACE_Time_Value(0, 10 * 1000));
-
- std::cout << "Supplier initialized." << std::endl;
- }
-
- virtual ~TestSupplier() {
- std::cout << "~TestSupplier()" << std::endl;
- }
-
- void schedule_next_event(const ACE_Time_Value& tv) {
- reactor_->schedule_timer(this, 0, tv, ACE_Time_Value::zero);
- }
-
- virtual void disconnect_push_supplier() {
- // this should never be called. The notify service uses this to allow its
- // clients to disconnect gracefully.
- std::cout << "disconnect_push_supplier()." << std::endl;
- //ACE_ASSERT(false);
- }
-
- bool push_next_event() {
- try {
- if (! connected_) {
- std::cout << "Trying to push when disconnected." << std::endl;
- return false;
- }
- std::cout << "+" << std::flush;
-
- ++event_count_;
-
- CORBA::Any a;
- a <<= event_;
- consumer_->push(a);
-
- if (event_count_ >= num_events_ && num_events_ > 0) {
- std::cout << "Supplier stopping after sending "
- << event_count_ << " events." << std::endl;
- disconnect();
- } else {
- schedule_next_event(EVENT_DELAY);
- }
- return true;
- } catch(const CORBA::Exception& e) {
- std::cerr << "TestSupplier::push_next_event() exception: " << e << std::endl;
- }
- return false;
- }
-
- void disconnect() {
- try {
- std::cout << "Supplier Disconnecting..." << std::endl;
- consumer_->disconnect_push_consumer();
- disconnect_self();
- orb_->shutdown(0);
- std::cout << "Supplier Disconnected." << std::endl;
- } catch(const CORBA::Exception& e) {
- std::cerr << "TestSupplier::disconnect() exception: " << e << std::endl;
- }
- }
-
- void disconnect_self() {
- if (! connected_)
- return;
- connected_ = false;
- reactor_->cancel_timer(this);
- poa_->deactivate_object(id_.in());
- }
-
- virtual int handle_timeout (const ACE_Time_Value&, const void*) {
- if (! push_next_event()) {
- return -1;
- }
- return 0;
- }
-};
-
-int ACE_TMAIN (int ac, ACE_TCHAR* av[]) {
-
- int num_events = 0;
- int pay_size = 1;
-
- try {
-
- CORBA::ORB_var orb = CORBA::ORB_init(ac, av);
-
- CORBA::ValueFactoryBase_var vfb = new MyEventFactory;
- CORBA::String_var id = _tc_MyEvent->id();
- orb->register_value_factory(id.in(), vfb);
-
- CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-
- PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
- PortableServer::POAManager_var mgr = poa->the_POAManager();
-
- obj = orb->string_to_object(notify_ior);
- CosNotifyChannelAdmin::EventChannelFactory_var ecf
- = CosNotifyChannelAdmin::EventChannelFactory::_narrow(obj.in());
- if (CORBA::is_nil(ecf.in()))
- throw std::runtime_error("no event channel factory");
-
- if (ac > 1) {
- num_events = ACE_OS::atoi(av[1]);
- }
- if (ac > 2) {
- pay_size = ACE_OS::atoi(av[1]);
- }
-
- event_ = new MyEvent_i("TestName", 42);
-
- for (int i = 0; i < pay_size; ++i) {
- event_->add_long((i + 1) * 42);
- }
-
- // Activate the manager in case the notify service wants to call us
- // back when we register.
- mgr->activate();
-
- {
- TestSupplier supplier(num_events, ecf.in(), orb.in(), poa.in());
- orb->run();
- }
-
- event_ = 0;
-
- poa->destroy(1, 1);
- orb->destroy();
-
- return 0;
-
- } catch(CORBA::Exception& e) {
- std::cerr << "Supplier: main() exception: " << e << std::endl;
- } catch(std::invalid_argument& e) {
- std::cerr << "Supplier: main() exception: " << e.what () << std::endl;
- } catch(std::runtime_error& e) {
- std::cerr << "Supplier: main() exception: " << e.what () << std::endl;
- } catch(...) {
- std::cerr << "Supplier: main() unknown exception: " << std::endl;
- }
- return 1;
-}