diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
commit | 8008dd09ccf88d4edef237a184a698cac42f2952 (patch) | |
tree | da50d054f9c761c3f6a5923f6979e93306c56d68 /TAO/docs/tutorials/Quoter | |
parent | 13d6e89af439164c0ade48e6f5c3e9b3f971e8c9 (diff) | |
download | ATCD-8008dd09ccf88d4edef237a184a698cac42f2952.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/docs/tutorials/Quoter')
141 files changed, 0 insertions, 11032 deletions
diff --git a/TAO/docs/tutorials/Quoter/AMI/Handler_i.cpp b/TAO/docs/tutorials/Quoter/AMI/Handler_i.cpp deleted file mode 100644 index 1167c78c3e0..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Handler_i.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// $Id$ -// - -#include "Handler_i.h" -#include "ace/streams.h" - -Single_Query_Stock_Handler_i:: - Single_Query_Stock_Handler_i (int *response_count) - : response_count_ (response_count) -{ -} - -void -Single_Query_Stock_Handler_i::get_price_and_names (CORBA::Double ami_return_val, - const char *symbol, - const char *full_name) - throw (CORBA::SystemException) -{ - cout << "The price of one stock in \"" - << full_name << "\" (" << symbol << ") is " - << ami_return_val << endl; - (*this->response_count_)++; -} - -void -Single_Query_Stock_Handler_i:: - get_price_and_names_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - // We ignore the exception, but this counts as a reponse, otherwise - // the application would not finish. - cerr << "Exception raised while querying stock price" - << endl; - (*this->response_count_)++; -} - - -void -Single_Query_Stock_Handler_i::get_symbol (const char *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - get_symbol_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i::get_full_name (const char *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - get_full_name_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i::price (double) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - price_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} diff --git a/TAO/docs/tutorials/Quoter/AMI/Handler_i.h b/TAO/docs/tutorials/Quoter/AMI/Handler_i.h deleted file mode 100644 index fd3e78ec36e..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Handler_i.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIALS_QUOTER_AMI_CLIENT_HANDLER_I_H -#define TAO_TUTORIALS_QUOTER_AMI_CLIENT_HANDLER_I_H - -#include "QuoterS.h" - -class Single_Query_Stock_Handler_i : public POA_Quoter::AMI_Single_Query_StockHandler -{ -public: - Single_Query_Stock_Handler_i (int *response_count); - - void get_price_and_names (CORBA::Double ami_return_val, - const char *symbol, - const char *full_name) - throw (CORBA::SystemException); - - void get_price_and_names_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void get_symbol(const char *) - throw (CORBA::SystemException); - void get_symbol_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void get_full_name (const char *) - throw (CORBA::SystemException); - void get_full_name_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void price (double) - throw (CORBA::SystemException); - void price_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - -private: - - int *response_count_; -}; - -#endif /* TAO_TUTORIALS_QUOTER_AMI_CLIENT_HANDLER_I_H */ diff --git a/TAO/docs/tutorials/Quoter/AMI/Makefile.am b/TAO/docs/tutorials/Quoter/AMI/Makefile.am deleted file mode 100644 index 06b7f62661a..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Makefile.am +++ /dev/null @@ -1,134 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_AMI_Idl.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING - -BUILT_SOURCES = \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -CLEANFILES = \ - Quoter-stamp \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -QuoterC.cpp QuoterC.h QuoterC.inl QuoterS.cpp QuoterS.h QuoterS.inl: Quoter-stamp - -Quoter-stamp: $(srcdir)/Quoter.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) -GC $(srcdir)/Quoter.idl - @touch $@ - - -noinst_HEADERS = \ - Quoter.idl - -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Makefile.Quoter_AMI_Client.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) - -client_SOURCES = \ - Handler_i.cpp \ - QuoterC.cpp \ - QuoterS.cpp \ - client.cpp \ - Handler_i.h - -client_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Makefile.Quoter_AMI_Server.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) - -server_SOURCES = \ - QuoterC.cpp \ - QuoterS.cpp \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/AMI/Quoter.idl b/TAO/docs/tutorials/Quoter/AMI/Quoter.idl deleted file mode 100644 index 80cfa1661d1..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Quoter.idl +++ /dev/null @@ -1,49 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; - - interface Single_Query_Stock : Stock { - double get_price_and_names (out string symbol, - out string full_name); - }; -}; diff --git a/TAO/docs/tutorials/Quoter/AMI/Quoter_AMI.mpc b/TAO/docs/tutorials/Quoter/AMI/Quoter_AMI.mpc deleted file mode 100644 index b19033fbef3..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Quoter_AMI.mpc +++ /dev/null @@ -1,34 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*idl): taoidldefaults, ami { - IDL_Files { - Quoter.idl - } - custom_only = 1 -} - -project(*client) : taoexe, portableserver, ami, exceptions { - after += *idl - source_files { - client.cpp - Handler_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*server) : taoserver, ami, exceptions { - after += *idl - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} diff --git a/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.cpp deleted file mode 100644 index a2323a6be36..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () - : rhat_ ("RHAT", "RedHat, Inc.", 210), - msft_ ("MSFT", "Microsoft, Inc.", 91) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this (); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.h deleted file mode 100644 index c0e51d1b3ea..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Stock_Factory_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/AMI/Stock_i.cpp b/TAO/docs/tutorials/Quoter/AMI/Stock_i.cpp deleted file mode 100644 index 776ce01a806..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Stock_i.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} - -CORBA::Double -Quoter_Stock_i::get_price_and_names (CORBA::String_out symbol, - CORBA::String_out full_name) - throw (CORBA::SystemException) -{ - symbol = CORBA::string_dup (this->symbol_.c_str ()); - full_name = CORBA::string_dup (this->full_name_.c_str ()); - return this->price_; -} - diff --git a/TAO/docs/tutorials/Quoter/AMI/Stock_i.h b/TAO/docs/tutorials/Quoter/AMI/Stock_i.h deleted file mode 100644 index 27163f9d2a0..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/Stock_i.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Single_Query_Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - CORBA::Double get_price_and_names (CORBA::String_out symbol, - CORBA::String_out full_name) - throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/AMI/client.cpp b/TAO/docs/tutorials/Quoter/AMI/client.cpp deleted file mode 100644 index fcb8a8f26da..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/client.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// $Id$ -// - -#include "Handler_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 3) { - cerr << "Usage: " << argv[0] - << " Factory_IOR symbol symbol..." << endl; - return 1; - } - - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Use the first argument to create the factory object reference, - // in real applications we use the naming service, but let's do - // the easy part first! - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Create and activate the handler... - int response_count = 0; - Single_Query_Stock_Handler_i handler_i (&response_count); - Quoter::AMI_Single_Query_StockHandler_var handler = - handler_i._this (); - - // Send all the requests, careful with error handling - int request_count = 0; - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var tmp = - factory->get_stock (argv[i]); - Quoter::Single_Query_Stock_var stock = - Quoter::Single_Query_Stock::_narrow (tmp.in ()); - if (CORBA::is_nil (stock.in ())) { - cerr << "Cannot get single query interface for <" - << argv[i] << ">" << endl; - } - - stock->sendc_get_price_and_names (handler.in ()); - request_count++; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - while (response_count < request_count - && orb->work_pending ()) { - orb->perform_work (); - } - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/AMI/index.html b/TAO/docs/tutorials/Quoter/AMI/index.html deleted file mode 100644 index 359ede5a6fa..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/index.html +++ /dev/null @@ -1,233 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Asynchronous Method Invocation - CORBA for impatient clients</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Asynchronous Method Invocation - CORBA for impatient clients</h3> - - <P>Our <A HREF="../Simple/Client/index.html">simple client</A> - illustrated how to use the traditional CORBA synchronous method - invocation to query a number of stock prices. - Suppose that we had to query hundreds of stock prices, for - example, during the initialization of a complex market analysis - tool. - In that case sending the requests in sequence is going to yield - poor performance; we are not taking advantage of the natural - parallelism in distributed systems, since we are waiting for the - first response to come back before sending the next query. - Traditionally this problem has been attacked using either - <CODE>oneway</CODE> calls or multiple threads. Both approaches can - work, but they have some disadvantages: - multi-threading programming can be hard and error-prone, - oneways are unreliable and require callback interfaces to return - the stock value. - Recently the OMG approved the CORBA Messaging specification - that extends the basic invocation model to include asynchronous - calls. - Unlike the old deferred synchronous model, the new model uses - the IDL compiler and the SII to achieve type safety and improved - performance, but the application does not block waiting for a - response. Instead, it gives the ORB a reference to a reply - handler that will receive the response asynchronously. - The specification also defines a polling interface that we will - not discuss as TAO does not implement it. - </P> - - <P>For this problem we will extend the IDL interface to include a - new operation: - </P> -<PRE> - interface Single_Query_Stock : Stock { - double get_price_and_names (out string symbol, - out string full_name); - }; -</PRE> - <P>This will simplify some of the examples. - </P> - - <P>The first step is to generate the stubs and skeletons with - support for the callback AMI. We do this with the <CODE>-GC</CODE> - flag: - </P> -<PRE> -$ $ACE_ROOT/TAO/TAO_IDL/tao_idl -GC Quoter.idl -</PRE> - <P>You may want to take a brief look at the generated client side - interface. - The IDL compiler adds new methods to the <CODE>Quoter::Stock</CODE> - interface. In particular pay attention to this operation: - </P> -<PRE> - virtual void sendc_get_price_and_names ( - AMI_Single_Query_StockHandler_ptr ami_handler - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); -</PRE> - <P>This is the operation used to send a request asynchronously. The - response is received in the handler object. This is a regular - CORBA object with the following IDL interface: - </P> -<PRE> -interface AMI_Single_Query_StockHandler { - void get_price_and_names (in double ami_return_val, - in string symbol, - in string full_name); -}; -</PRE> - <P>You don't have to write this IDL interface. The IDL compiler - automatically generates the so-called <EM>implied IDL</EM> - constructs from your original IDL. - Notice how the arguments are generated. The first argument is - simply the return value, then the output arguments show up, but - as <EM>input</EM> only since the handler has to receive the - reply. - </P> - - <H3>Implementing the reply handler</H3> - - <P>We will have to implement a servant for this new IDL interface - so we can receive the reply, - exactly as we do for servers: - </P> -<PRE> -class Single_Query_Stock_Handler_i : public POA_Quoter::AMI_Single_Query_StockHandler -{ -public: - Single_Query_Stock_Handler_i (int *response_count) - : response_count_ (response_count) {} - - void get_price_and_names (CORBA::Double ami_return_val, - const char *symbol, - const char *full_name) - throw (CORBA::SystemException) - { - std::cout << "The price of one stock in \"" - << full_name << "\" (" << symbol << ") is " - << ami_return_val << std::endl; - *this->response_count_++; - } - -private: - int *response_count_; -}; -</PRE> - <P>The <CODE>response_count_</CODE> field will be used to - terminate the client when all the responses are received. - </P> - - <H3>Sending asynchronous method invocations</H3> - - <P>The handler servant is activated as any other CORBA object: - </P> -<PRE> - int response_count = 0; - Single_Query_Stock_Handler_i handler_i (&response_count); - Quoter::AMI_Single_Query_StockHandler_var handler = - handler_i._this (); -</PRE> - <P>and now we change the loop to send all the requests at once: - </P> -<PRE> - int request_count = 0; - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var tmp = - factory->get_stock (argv[i]); - Quoter::Single_Query_Stock_var stock = - Quoter::Single_Query_Stock::_narrow (tmp.in ()); - - stock->sendc_get_price_and_names (handler.in ()); - request_count++; - } -</PRE> - <P>after the loop we wait until all the responses have arrived: - </P> -<PRE> - while (response_count < request_count - && orb->work_pending ()) { - orb->perform_work (); - } -</PRE> - - <H3>Exercise 1</H3> - - <P>Complete the <CODE>client.cpp</CODE> file. Does this client play - the server role too? If not, what is the role with respect to - the handler servant? If you think it is a server too, what - should you do about the POA? - </P> - <P>You can use the following files to complete your implementation: - the <A HREF="Quoter.idl">Quoter.idl</A>, - <A HREF="Handler_i.h">Handler_i.h</A>, - <A HREF="Handler_i.cpp">Handler_i.cpp</A>, - <A HREF="Makefile">Makefile</A>. - Remember that the simple client main program - (located - <A HREF="../Simple/Client/client.cpp">here</A>) - is a good start. - </P> - - <H4>Solution</H4> - <P>Look at - <A HREF="client.cpp">client.cpp</A> file. It should - not be much different from yours. - </P> - - <H3>Testing</H3> - - <P>A simple server is provided, based on the - <A HREF="../Simple/Server/index.html">simple server</A> - from the introduction. - As before, you need the following files: - <A HREF="Stock_i.h">Stock_i.h</A>, - <A HREF="Stock_i.cpp">Stock_i.cpp</A>, - <A HREF="Stock_Factory_i.h">Stock_Factory_i.h</A> - <A HREF="Stock_Factory_i.cpp">Stock_Factory_i.cpp</A> - and <A HREF="server.cpp">server.cpp</A>. - </P> - - <H2>Configuration</H2> - - <P>So far we have used the default configuration in TAO, - but AMI works better with some fine tuning. For example, - by default TAO uses a separate connection for each outstanding - request. With SMI this is a very good strategy, as separate - threads can send concurrent requests without any shared - resources, - but this approach does not scale well with AMI, as it would - create too many connections. - The solution is to change the strategy to share connections. - All we need to do is create a - <A HREF="svc.conf">svc.conf</A> file with the following - contents: - </P> -<PRE> -static Client_Strategy_Factory "-ORBTransportMuxStrategy MUXED" -</PRE> - <P>There are many other configuration options, all of them - documented in - <A HREF="http://ace.cs.wustl.edu/cvsweb/ace-latest.cgi/ACE_wrappers/TAO/docs/Options.html">Options.html</A>, - in - <A HREF="http://ace.cs.wustl.edu/cvsweb/ace-latest.cgi/ACE_wrappers/TAO/docs/configurations.html">configurations.html</A>, - and in the Developer's Guide available from - <A HREF="http://www.theaceorb.com/">OCI</A>. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Thu Mar 29 16:04:44 PST 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/AMI/server.cpp b/TAO/docs/tutorials/Quoter/AMI/server.cpp deleted file mode 100644 index 9d4c01d9a74..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/server.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i; - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Put the object reference as an IOR string - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - - // Print it out! - cout << ior.in () << endl; - - orb->run (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/AMI/svc.conf b/TAO/docs/tutorials/Quoter/AMI/svc.conf deleted file mode 100644 index 9fb75aeb0dd..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/svc.conf +++ /dev/null @@ -1,4 +0,0 @@ -# -# $Id$ -# -static Client_Strategy_Factory "-ORBTransportMuxStrategy MUXED" diff --git a/TAO/docs/tutorials/Quoter/AMI/svc.conf.xml b/TAO/docs/tutorials/Quoter/AMI/svc.conf.xml deleted file mode 100644 index b8377b00cda..00000000000 --- a/TAO/docs/tutorials/Quoter/AMI/svc.conf.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from ./docs/tutorials/Quoter/AMI/svc.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <!-- --> - <!-- $Id$ --> - <!-- --> - <static id="Client_Strategy_Factory" params="-ORBTransportMuxStrategy MUXED"/> -</ACE_Svc_Conf> diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Consumer_i.h b/TAO/docs/tutorials/Quoter/Event_Service/Consumer_i.h deleted file mode 100644 index 819c4ed0cb5..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Consumer_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIALS_QUOTER_EVENT_SERVICE_CONSUMER_I_H -#define TAO_TUTORIALS_QUOTER_EVENT_SERVICE_CONSUMER_I_H - -#include <orbsvcs/CosEventCommS.h> -#include <orbsvcs/CosEventChanneAdminC.h> - -class Stock_Consumer : public POA_CosEventComm::PushConsumer { -public: - Stock_Consumer (); - - void connect (CosEventChanneAdmin::ConsumerAdmin_ptr consumer_admin); - - void push (const CORBA::Any& data ACE_ENV_ARG_DECL_NOT_USED); - void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); - -private: -}; - -#endif /* TAO_TUTORIALS_QUOTER_EVENT_SERVICE_CONSUMER_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Makefile.am b/TAO/docs/tutorials/Quoter/Event_Service/Makefile.am deleted file mode 100644 index 6636df72e21..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Makefile.am +++ /dev/null @@ -1,127 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_Event_Service_Idl.am - -BUILT_SOURCES = \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -CLEANFILES = \ - Quoter-stamp \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -QuoterC.cpp QuoterC.h QuoterC.inl QuoterS.cpp QuoterS.h QuoterS.inl: Quoter-stamp - -Quoter-stamp: $(srcdir)/Quoter.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) $(srcdir)/Quoter.idl - @touch $@ - - -noinst_HEADERS = \ - Quoter.idl - -## Makefile.Quoter_Event_Service_Client.am - -if BUILD_EXCEPTIONS -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -DTAO_HAS_TYPED_EVENT_CHANNEL - -client_SOURCES = \ - QuoterC.cpp \ - Stock_Consumer.cpp \ - client.cpp \ - Stock_Consumer.h - -client_LDADD = \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Skel.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif BUILD_EXCEPTIONS - -## Makefile.Quoter_Event_Service_Server.am - -if BUILD_EXCEPTIONS -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -DTAO_HAS_TYPED_EVENT_CHANNEL - -server_SOURCES = \ - QuoterC.cpp \ - QuoterS.cpp \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent_Skel.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosEvent.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Quoter.idl b/TAO/docs/tutorials/Quoter/Event_Service/Quoter.idl deleted file mode 100644 index 34d81177658..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Quoter.idl +++ /dev/null @@ -1,54 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; - - struct Event { - double price; - string symbol; - string full_name; - }; - - interface Modify_Stock : Stock { - void set_price (in double new_price); - }; -}; diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Quoter_Event_Service.mpc b/TAO/docs/tutorials/Quoter/Event_Service/Quoter_Event_Service.mpc deleted file mode 100644 index a98f1720c63..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Quoter_Event_Service.mpc +++ /dev/null @@ -1,33 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*idl) : taoidldefaults, anytypecode { - IDL_Files { - Quoter.idl - } - custom_only = 1 -} - -project(*client) : orbsvcsexe, portableserver, event, event_skel, naming, minimum_corba, exceptions { - after += *idl - source_files { - client.cpp - Stock_Consumer.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*server) : orbsvcsexe, portableserver, event, event_skel, naming, minimum_corba, exceptions { - after += *idl - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.cpp b/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.cpp deleted file mode 100644 index 2e156b24642..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Consumer.h" -#include "QuoterC.h" -#include "ace/streams.h" - -Stock_Consumer::Stock_Consumer () -{ -} - -void -Stock_Consumer::connect (CosEventChannelAdmin::EventChannel_ptr event_channel) -{ - CosEventChannelAdmin::ConsumerAdmin_var consumer_admin = - event_channel->for_consumers (); - - this->supplier_proxy_ = - consumer_admin->obtain_push_supplier (); - - CosEventComm::PushConsumer_var myself = this->_this (); - this->supplier_proxy_->connect_push_consumer (myself.in ()); -} - -void -Stock_Consumer::disconnect () -{ - // Do not receive any more events... - this->supplier_proxy_->disconnect_push_supplier (); -} - -void -Stock_Consumer::push (const CORBA::Any& data - ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - Quoter::Event *event; - if ((data >>= event) == 0) - return; // Invalid event - - cout << "The new price for one stock in \"" - << event->full_name.in () - << "\" (" << event->symbol.in () - << ") is " << event->price << endl; -} - -void -Stock_Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - this->supplier_proxy_ = CosEventChannelAdmin::ProxyPushSupplier::_nil (); -} diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.h b/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.h deleted file mode 100644 index d5de84958cd..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Consumer.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIALS_QUOTER_EVENT_SERVICE_STOCK_CONSUMER_H -#define TAO_TUTORIALS_QUOTER_EVENT_SERVICE_STOCK_CONSUMER_H - -#include <orbsvcs/CosEventCommS.h> -#include <orbsvcs/CosEventChannelAdminC.h> - -class Stock_Consumer : public POA_CosEventComm::PushConsumer { -public: - Stock_Consumer (); - - void connect (CosEventChannelAdmin::EventChannel_ptr event_channel); - // Connect to the event channel, using <consumer_admin> - - void disconnect (); - // Disconnect from the event channel. - - void push (const CORBA::Any& data ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - -private: - CosEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_; - // The supplier proxy. -}; - -#endif /* TAO_TUTORIALS_QUOTER_EVENT_SERVICE_STOCK_CONSUMER_H */ diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.cpp deleted file mode 100644 index a04c3ab1e3d..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "Stock_i.h" -#include "ace/streams.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - try { - CORBA::Object_var tmp = - this->stock_factory_poa_->id_to_reference (oid.in ()); - return Quoter::Stock::_narrow (tmp.in ()); - } - catch (PortableServer::POA::ObjectNotActive &) { - throw Quoter::Invalid_Stock_Symbol (); - } -} - -void -Quoter_Stock_Factory_i::destroy_stock_objects () -{ - if (!CORBA::is_nil (this->stock_factory_poa_.in ())) - return; - - this->stock_factory_poa_->destroy (1, 1); - this->stock_factory_poa_ = PortableServer::POA::_nil (); -} - -void -Quoter_Stock_Factory_i::load_stock_objects ( - PortableServer::POA_ptr poa, - PortableServer::POAManager_ptr poa_manager, - CosEventChannelAdmin::SupplierAdmin_ptr supplier_admin) -{ - if (!CORBA::is_nil (this->stock_factory_poa_.in ())) - return; - - CORBA::PolicyList policies (2); - policies.length (2); - - policies[0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - policies[1] = - poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION); - - this->stock_factory_poa_ = - poa->create_POA ("Stock_Factory_POA", - poa_manager, - policies); - - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - while (!cin.eof () && cin.peek () != EOF) { - const int max_symbol_length = 8; - char symbol[max_symbol_length]; - const int max_full_name_length = 64; - char full_name[max_full_name_length]; - double price; - - cin.getline (symbol, max_symbol_length, '\n'); - cin.getline (full_name, max_full_name_length, '\n'); - cin >> price; - cin.ignore (1, '\n'); - - Quoter_Stock_i *stock = - new Quoter_Stock_i (symbol, full_name, price); - - PortableServer::ServantBase_var servant = stock; - - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - this->stock_factory_poa_->activate_object_with_id (oid.in (), - servant.in ()); - stock->connect (supplier_admin); - } -} diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.h deleted file mode 100644 index 47ac82f0003..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_Factory_i.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_FACTORY_I_H - -#include "QuoterS.h" -#include <orbsvcs/CosEventChannelAdminS.h> - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - void load_stock_objects (PortableServer::POA_ptr poa, - PortableServer::POAManager_ptr poa_manager, - CosEventChannelAdmin::SupplierAdmin_ptr supplier_admin); - void destroy_stock_objects (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - PortableServer::POA_var stock_factory_poa_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_FACTORY_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.cpp deleted file mode 100644 index 37126ff41f2..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : supplier_personality_ (this) -{ - this->data_.symbol = symbol; - this->data_.full_name = full_name; - this->data_.price = price; -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->data_.symbol.in ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->data_.full_name.in ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->data_.price; -} - -void -Quoter_Stock_i::set_price (CORBA::Double new_price) - throw (CORBA::SystemException) -{ - this->data_.price = new_price; - if (CORBA::is_nil (this->consumer_proxy_.in ())) - return; - - CORBA::Any event; - event <<= this->data_; - this->consumer_proxy_->push (event); -} - -void -Quoter_Stock_i::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - // Forget about the consumer it is not there anymore - this->consumer_proxy_ = - CosEventChannelAdmin::ProxyPushConsumer::_nil (); -} - -void -Quoter_Stock_i::connect (CosEventChannelAdmin::SupplierAdmin_ptr supplier_admin) -{ - this->consumer_proxy_ = - supplier_admin->obtain_push_consumer (); - CosEventComm::PushSupplier_var supplier = - this->supplier_personality_._this (); - this->consumer_proxy_->connect_push_supplier (supplier.in ()); -} - diff --git a/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.h b/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.h deleted file mode 100644 index b4c619e1a6a..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/Stock_i.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_I_H - -#include "QuoterS.h" -#include <orbsvcs/CosEventCommS.h> -#include <orbsvcs/CosEventChannelAdminC.h> - -class Quoter_Stock_i - : public virtual POA_Quoter::Modify_Stock -{ -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - void set_price (CORBA::Double new_price) throw (CORBA::SystemException); - - void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - - void connect (CosEventChannelAdmin::SupplierAdmin_ptr supplier_admin); - -private: - Quoter::Event data_; - - CosEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_; - - POA_CosEventComm::PushSupplier_tie<Quoter_Stock_i> supplier_personality_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_EVENT_SERVICE_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Event_Service/client.cpp b/TAO/docs/tutorials/Quoter/Event_Service/client.cpp deleted file mode 100644 index 43abc2992c9..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/client.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Consumer.h" -#include <orbsvcs/CosNamingC.h> -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("CosEventService"); - - CORBA::Object_var ec_object = - naming_context->resolve (name); - - // Now downcast the object reference to the appropriate type - CosEventChannelAdmin::EventChannel_var ec = - CosEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); - - Stock_Consumer stock_consumer_i; - stock_consumer_i.connect (ec.in ()); - - orb->run (); - - stock_consumer_i.disconnect (); - - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Event_Service/ec.conf b/TAO/docs/tutorials/Quoter/Event_Service/ec.conf deleted file mode 100644 index 395b9a6c724..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/ec.conf +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ -# static EC_Factory "-ECfiltering null" -# -ECproxyconsumerlock thread " #-ECproxysupplierlock thread" # -ECsupplierfiltering per-supplier" diff --git a/TAO/docs/tutorials/Quoter/Event_Service/ec.conf.xml b/TAO/docs/tutorials/Quoter/Event_Service/ec.conf.xml deleted file mode 100644 index f6fed99198b..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/ec.conf.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from ./docs/tutorials/Quoter/Event_Service/ec.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <!-- $Id$ --> - <!-- static EC_Factory "-ECfiltering null" --> - <!-- -ECproxyconsumerlock thread " #-ECproxysupplierlock thread" # -ECsupplierfiltering per-supplier" --> -</ACE_Svc_Conf> diff --git a/TAO/docs/tutorials/Quoter/Event_Service/index.html b/TAO/docs/tutorials/Quoter/Event_Service/index.html deleted file mode 100644 index 8b60f5ec91c..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/index.html +++ /dev/null @@ -1,408 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>TAO's COS Event Service</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>TAO's COS Event Service</h3> - - <P>To poll the values of stocks constantly just to - check if they have changed is not an efficient or scalable - solution. - We want to be informed when the price changes so we can take - appropriate action. - We could devise our own call back mechanism, but this kind of - task is easier to achieve using the CORBA Event Service. - </P> - - <H3>Defining the Event Type</H3> - - <P>We need to define an IDL <CODE>struct</CODE> that will carry - our event data. - Of course we want to include the stock price, its symbol and - maybe its full name in the event: - </P> -<PRE> - struct Event { - double price; - string symbol; - string full_name; - }; -</PRE> - <P>We also extend the <CODE>Stock</CODE> interface so we can - modify the value: - </P> -<PRE> - interface Modify_Stock : Stock { - void set_price (in double new_price); - }; -</PRE> - - <H3>Getting the Price Changes</H3> - - <H3>Connecting as a consumer</H3> - - <P>Connecting as a consumer is a similar process, but we will use - the more traditional inheritance based approach instead of TIE. - First let us define the consumer object: - </P> -<PRE> -class Stock_Consumer : public POA_CosEventComm::PushConsumer { -public: - Stock_Consumer (); - - void push (const CORBA::Any& data TAO_ENV_ARG_DECL); - void disconnect_push_consumer (TAO_ENV_SINGLE_ARG_DECL); - - // details omitted -}; -</PRE> - <P>Let us ignore the strange <CODE>TAO_ENV_ARG_DECL</CODE> - arguments and concentrate on the implementation. - The <CODE>disconnect_push_consumer()</CODE> method is invoked by - the Events Service when it is disconnecting, - for example, because it was shut down before the Consumer got a - chance to disconnect itself. - The <CODE>push()</CODE> method is invoked by the Events Service - whenever some event is sent by a supplier. - Let's take a look at this method. - First we need to extract the event data from the any: - </P> -<PRE> -void -Stock_Consumer::push (const CORBA::Any& data - TAO_ENV_ARG_DECL_NOT_USED) -{ - Quoter::Event *event; - if ((data >>= event) == 0) - return; // Invalid event -</PRE> - <P>Notice that the extraction can fail: anys can store all IDL - data types, and only at extraction time are the types checked. - Also notice that we use a pointer to the event; - the CORBA rules are that variable sized structures, - i.e., structures that contain elements of variable size, - such as strings, - are extracted by reference. - We do <STRONG>not</STRONG> need to manage this memory, - the ORB will destroy it for us. - Now we can print out the new stock price: - </P> -<PRE> - std::cout << "The new price for one stock in \"" - << event->full_name.in () - << "\" (" << event->symbol.in () - << ") is " << event->price << std::endl; -} -</PRE> - - <P>So what was the <CODE>TAO_ENV_ARG_DECL</CODE> about? After - all it was not used. TAO services must support platforms - without support for native C++ exceptions. On those platforms - the CORBA specification defines an <EM>alternate mapping</EM> - where all the operations use an extra argument to return any - exceptions. - Notice that the TAO IDL compiler supports both mappings. We have - been using the standard one so far! It is only if your C++ - compiler does not support exceptions that you need to use - the alternative mapping. - </P> - <P>Notice that on platforms with native C++ exception support we - can safely ignore the extra argument, - and use the usual mechanisms to catch and throw exceptions. - For more information on how to use the alternative mapping and - how to write portable code for both environments check - <A HREF="../../../../../docs/exceptions.html">Using - ACE try macros for CORBA programming</A>. - </P> - - <P>Going back to our example, - when the event channel disconnects we receive a callback, too. - At that point we want to forget about the original connection: - </P> -<PRE> -void -Stock_Consumer::disconnect_push_consumer (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) -{ - this->supplier_proxy_ = CosEventChannelAdmin::ProxyPushSupplier::_nil (); -} -</PRE> - <P>But why do we need to have a connection to the event channel in - the first place? All we want is to receive events. The - connection to the event channel will let you disconnect - gracefully, so the event channel does not have to maintain - resources for old consumers. - For example, - we could implement a method such as: - </P> -<PRE> -void -Stock_Consumer::disconnect () -{ - // Do not receive any more events... - this->supplier_proxy_->disconnect_push_supplier (); -} -</PRE> - - <H4>How to connect to the event channel</H4> - - <P>Connecting to the event channel is a 3 step process. - First we obtain a factory used by all the consumers that want to - connect. - Next we obtain a supplier proxy, so we can report when - we do not want any more events. - Finally we connect to the proxy to start receiving events. - </P> - <P>We will assume that we are using the naming service or - something similar to obtain a reference to the event service: - </P> -<PRE> - CORBA::Object_var tmp = naming_context->resolve (name); - CosEventChannelAdmin::EventChannel_var event_channel = - CosEventChannelAdmin::EventChannel::_narrow (tmp); -</PRE> - <P>Now we use the event channel to obtain the factory used for - consumer connections: - </P> -<PRE> - CosEventChannelAdmin::ConsumerAdmin_var consumer_admin = - event_channel->for_consumers (); -</PRE> - <P>And use the factory to obtain a proxy: - </P> -<PRE> -void -Stock_Consumer::connect (CosEventChannelAdmin::ConsumerAdmin_ptr consumer_admin) -{ - this->supplier_proxy_ = - consumer_admin->obtain_push_supplier (); -</PRE> - <P>And finally we connect: - </P> -<PRE> - CosEventComm::PushConsumer_var myself = this->_this (); - this->supplier_proxy_->connect_push_consumer (myself.in ()); -} -</PRE> - - <H3>Notifying the Price Changes</H3> - - <P>We will now examine how the suppliers generate events. - Let us look at an implementation of the - <CODE>Modify_Stock</CODE> interface: - </P> -<PRE> -class Quoter_Modify_Stock_i : public POA_Quoter::Modify_Stock { -public: - Quoter_Modify_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - void set_price (CORBA::Double new_price) - throw (CORBA::SystemException); - -private: - Quoter::Event data_; - - CosEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_; -}; -</PRE> - <P>Notice how we use the IDL structure to maintain the data. This - is just to make the code a little shorter. - The <CODE>consumer_proxy_</CODE> object is just like - the <CODE>supplier_proxy_</CODE> discussed above, - except that we also use it to send the events. - The start of the <CODE>set_price()</CODE> method will look like - this: - </P> -<PRE> -void -Quoter_Stock_i::set_price (CORBA::Double new_price) - throw (CORBA::SystemException) -{ - this->data_.price = new_price; -</PRE> - <P>Next we prepare the event. The COS Events Service uses a CORBA - any to send all the data, like this: - </P> -<PRE> - CORBA::Any event; - event <<= this->data_; -</PRE> - <P>Finally we send the event to the consumer: - </P> -<PRE> - this->consumer_proxy_->push (event); -} -</PRE> - - <H3>Connecting to the Event Service as a Supplier</H3> - - <P>Sending the event was easy. Connecting to the Event Channel - as a supplier is very similar to the connection as a consumer. - We will need a <CODE>CosEventComm::PushSupplier</CODE> object. - This is a good application of the TIE objects: - </P> -<PRE> -class Quoter_Stock_i : public POA_Quoter::Modify_Stock { -public: - // some details removed... - - void disconnect_push_supplier (TAO_ENV_SINGLE_ARG_DECL_NOT_USED); - -private: - POA_CosEventComm::PushSupplier_tie < Quoter_Stock_i > supplier_personality_; -}; -</PRE> - <P>The <CODE>PushSupplier_tie</CODE> is a template generated by - the IDL compiler. It implements the - <CODE>CosEventComm::PushSupplier</CODE> interface, - but it actually just forwards all the calls to its single - template argument. - For example, in this case the - <CODE>disconnect_push_supplier</CODE> call is implemented as: - </P> -<PRE> -template<class T> void -POA_CosEventComm::PushSupplier_tie < T >::disconnect_push_supplier () -{ - this->ptr_->disconnect_push_supplier (); -} -</PRE> - <P>The <CODE>ptr_</CODE> field is actually a pointer to the - template argument, - so we don't have to implement a separate class just to receive a - disconnect callback, we can use the same - <CODE>Modify_Stock_i</CODE> class to do it. - </P> - - <P>Going back to the connection code, first we gain access to the - Event Service, for example using the naming service: - </P> -<PRE> - CORBA::Object_var tmp = naming_context->resolve (name); - CosEventChannelAdmin::EventChannel_var event_channel = - CosEventChannelAdmin::EventChannel::_narrow (tmp); -</PRE> - <P>Now we use the event channel to obtain the factory used for - supplier connections: - </P> -<PRE> - CosEventChannelAdmin::SupplierAdmin_var supplier_admin = - event_channel->for_suppliers (); -</PRE> - <P>And use the factory to obtain a proxy: - </P> -<PRE> - this->consumer_proxy_ = - supplier_admin->obtain_push_consumer (); -</PRE> - <P>And finally we use our supplier personality to connect to the - consumer proxy: - </P> -<PRE> - CosEventComm::PushSupplier_var supplier = - this->supplier_personality_._this (); - this->consumer_proxy_->connect_push_supplier (supplier); -</PRE> - - <P>Finally we implement the disconnect callback: - </P> -<PRE> -void -Quoter_Stock_i::disconnect_push_supplier (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - // Forget about the consumer. It is not there anymore - this->consumer_proxy_ = - CosEventChannelAdmin::ProxyPushConsumer::_nil (); -} -</PRE> - - <H3>Exercise 1</H3> - - <P>Implement a consumer that receives the price update events. - </P> - <P>The - <A HREF="Stock_Consumer.h">header file</A> - is already provided, - along with a sample - <A HREF="client.cpp">client.cpp</A>. - And other support files - <A HREF="Quoter.idl">Quoter.idl</A>, - <A HREF="GNUMakefile">Makefile</A>, - <A HREF="Stock_i.h">Stock_i.h</A>, - <A HREF="Stock_i.cpp">Stock_i.cpp</A>, - <A HREF="Stock_Factory_i.h">Stock_Factory_i.h</A>, - <A HREF="Stock_Factory_i.cpp">Stock_Factory_i.cpp</A>, - and <A HREF="server.cpp">server.cpp</A>. - </P> - - <H4>Solution</H4> - - <P>Compare your solution with - <A HREF="Stock_Consumer.cpp">Stock_Consumer.cpp</A>. - </P> - - <H4>Testing</H4> - - <P>To test your changes you need to run four programs, - first TAO's Naming Service: -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -m 1 -</PRE> - <P>The CORBA Event Service - </P> -<PRE> -$ $TAO_ROOT/orbsvcs/CosEvent_Service/CosEvent_Service -</PRE> - - <P>Now you can run your client: -<PRE> -$ client -</PRE> - <P>and finally the server: - </P> -<PRE> -$ server AAAA MSFT RHAT < stock_list.txt -</PRE> - <P>Here is the - <A HREF="stock_list.txt">stock_list.txt file</A>. - </P> - - <H3>Exercise 2</H3> - - <P>Run the same configuration as above, - but this time run multiple clients and servers: - </P> -<PRE> -$ client -$ client -$ server AAAA BBBB < stock_list1.txt -$ server ZZZZ YYYY < stock_list2.txt -</PRE> - <P>Do the clients receive all the events from both servers? What - if you don't want to receive all the events, for example, - because you are only interested in certain stocks? - </P> - <P>Here are the - <A HREF="stock_list.txt">stock_list1.txt</A> - and - <A HREF="stock_list.txt">stock_list2.txt</A> - files. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 13:59:59 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Event_Service/server.cpp b/TAO/docs/tutorials/Quoter/Event_Service/server.cpp deleted file mode 100644 index 56b0532a42c..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/server.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "orbsvcs/CosNamingC.h" -#include "ace/streams.h" -#include "ace/OS_NS_unistd.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i; - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Get the Naming Context reference - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - // Create and initialize the name. - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("Stock_Factory"); - - // Bind the object - naming_context->rebind (name, stock_factory.in ()); - - // Resolve the Event Service - name[0].id = CORBA::string_dup ("CosEventService"); - - CORBA::Object_var ec_object = - naming_context->resolve (name); - - // Now downcast the object reference to the appropriate type - CosEventChannelAdmin::EventChannel_var ec = - CosEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); - - CosEventChannelAdmin::SupplierAdmin_var supplier_admin = - ec->for_suppliers (); - - stock_factory_i.load_stock_objects (poa.in (), - poa_manager.in (), - supplier_admin.in ()); - - // **************************************************************** - - for (int j = 0; j != 1000; ++j) { - for (int i = 1; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - stock_factory->get_stock (argv[i]); - - CORBA::String_var full_name = stock->full_name (); - - // Get the price - CORBA::Double price = stock->price (); - - Quoter::Modify_Stock_var modify_stock = - Quoter::Modify_Stock::_narrow (stock.in ()); - modify_stock->set_price (price + 1); - - cout << "Set the price of " - << full_name.in () - << " to " << price + 1 << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - ACE_Time_Value tv (0, 500000); - ACE_OS::sleep (tv); - } - } - - stock_factory_i.destroy_stock_objects (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Event_Service/stock_list.txt b/TAO/docs/tutorials/Quoter/Event_Service/stock_list.txt deleted file mode 100644 index d30a0c0255a..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/stock_list.txt +++ /dev/null @@ -1,84 +0,0 @@ -MSFT -Microsoft Inc. -91 -RHAT -RedHat Inc. -210 -AAAA -The AAAA Company -100 -BBBB -The BBBB Company -101 -CCCC -The CCCC Company -102 -DDDD -The DDDD Company -103 -EEEE -The EEEE Company -104 -FFFF -The FFFF Company -105 -GGGG -The GGGG Company -106 -HHHH -The HHHH Company -107 -IIII -The IIII Company -108 -JJJJ -The JJJJ Company -109 -KKKK -The KKKK Company -110 -LLLL -The LLLL Company -111 -MMMM -The MMMM Company -112 -NNNN -The NNNN Company -113 -OOOO -The OOOO Company -114 -PPPP -The PPPP Company -115 -QQQQ -The QQQQ Company -116 -RRRR -The RRRR Company -117 -SSSS -The SSSS Company -118 -TTTT -The TTTT Company -119 -UUUU -The UUUU Company -120 -VVVV -The VVVV Company -121 -WWWW -The WWWW Company -122 -XXXX -The XXXX Company -123 -YYYY -The YYYY Company -124 -ZZZZ -The ZZZZ Company -125 diff --git a/TAO/docs/tutorials/Quoter/Event_Service/stock_list1.txt b/TAO/docs/tutorials/Quoter/Event_Service/stock_list1.txt deleted file mode 100644 index 183bd57af64..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/stock_list1.txt +++ /dev/null @@ -1,48 +0,0 @@ -RHAT -RedHat Inc. -210 -AAAA -The AAAA Company -100 -BBBB -The BBBB Company -101 -CCCC -The CCCC Company -102 -DDDD -The DDDD Company -103 -EEEE -The EEEE Company -104 -FFFF -The FFFF Company -105 -GGGG -The GGGG Company -106 -HHHH -The HHHH Company -107 -IIII -The IIII Company -108 -JJJJ -The JJJJ Company -109 -KKKK -The KKKK Company -110 -LLLL -The LLLL Company -111 -MMMM -The MMMM Company -112 -NNNN -The NNNN Company -113 -OOOO -The OOOO Company -114 diff --git a/TAO/docs/tutorials/Quoter/Event_Service/stock_list2.txt b/TAO/docs/tutorials/Quoter/Event_Service/stock_list2.txt deleted file mode 100644 index 2592fdbc073..00000000000 --- a/TAO/docs/tutorials/Quoter/Event_Service/stock_list2.txt +++ /dev/null @@ -1,36 +0,0 @@ -MSFT -Microsoft Inc. -91 -PPPP -The PPPP Company -115 -QQQQ -The QQQQ Company -116 -RRRR -The RRRR Company -117 -SSSS -The SSSS Company -118 -TTTT -The TTTT Company -119 -UUUU -The UUUU Company -120 -VVVV -The VVVV Company -121 -WWWW -The WWWW Company -122 -XXXX -The XXXX Company -123 -YYYY -The YYYY Company -124 -ZZZZ -The ZZZZ Company -125 diff --git a/TAO/docs/tutorials/Quoter/Makefile.am b/TAO/docs/tutorials/Quoter/Makefile.am deleted file mode 100644 index 9a0053b5806..00000000000 --- a/TAO/docs/tutorials/Quoter/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -SUBDIRS = \ - AMI \ - Event_Service \ - On_Demand_Activation \ - RT_Event_Service \ - idl \ - Simple \ - Naming_Service - diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Makefile.am b/TAO/docs/tutorials/Quoter/Naming_Service/Makefile.am deleted file mode 100644 index fd4e2356bae..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Makefile.am +++ /dev/null @@ -1,88 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_Naming_Service_Client.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -I$(srcdir)/../idl \ - -I../idl - -client_SOURCES = \ - client.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -client_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Makefile.Quoter_Naming_Service_Server.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -I$(srcdir)/../idl \ - -I../idl - -server_SOURCES = \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Quoter_Naming_Service.mpc b/TAO/docs/tutorials/Quoter/Naming_Service/Quoter_Naming_Service.mpc deleted file mode 100644 index 797e2569292..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Quoter_Naming_Service.mpc +++ /dev/null @@ -1,32 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*client) : orbsvcsexe, portableserver, naming, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../idl - } - includes += ../idl - - source_files { - client.cpp - } -} - -project(*server) : orbsvcsexe, portableserver, naming, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../idl - } - includes += ../idl - - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - } -} diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.cpp deleted file mode 100644 index a2323a6be36..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () - : rhat_ ("RHAT", "RedHat, Inc.", 210), - msft_ ("MSFT", "Microsoft, Inc.", 91) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this (); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.h deleted file mode 100644 index c0e51d1b3ea..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_Factory_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.cpp deleted file mode 100644 index 6149cb79c36..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.h b/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.h deleted file mode 100644 index 9c9607415a2..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/Stock_i.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/client.cpp b/TAO/docs/tutorials/Quoter/Naming_Service/client.cpp deleted file mode 100644 index c26cf41b26c..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/client.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// $Id$ -// - -#include "QuoterC.h" -#include <orbsvcs/CosNamingC.h> -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 2) { - cerr << "Usage: " << argv[0] - << "symbol symbol..." << endl; - return 1; - } - - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("Stock_Factory"); - - CORBA::Object_var factory_object = - naming_context->resolve (name); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Now get the full name and price of the other arguments: - for (int i = 1; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - factory->get_stock (argv[i]); - - // Get its name, put it on a _var so it is automatically - // released! - CORBA::String_var full_name = stock->full_name (); - - // Now get the price - CORBA::Double price = stock->price (); - - cout << "The price of a stock in \"" - << full_name.in () << "\" is $" - << price << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - // Finally destroy the ORB - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/index.html b/TAO/docs/tutorials/Quoter/Naming_Service/index.html deleted file mode 100644 index 345ba22be93..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/index.html +++ /dev/null @@ -1,260 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>TAO's Naming Service</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>TAO's Naming Service</h3> - - <P>So far we have used <CODE>string_to_object()</CODE> and - <CODE>object_to_string()</CODE> to bootstrap the client. - If the system is going to be used in a truly distributed - environment, we cannot count on having a shared file system or on - the user to type the IOR to initialize the client. - CORBA has several location services that can be used for that - purpose. The simplest of them is the CORBA Naming Service. - There are many good tutorials on how to use the Naming Service, - and Henning and Vinoski discuss the issue in detail in their - book. - </P> - <P>In this section we will cover very simple uses of the Naming - Service, but we will concentrate on how to configure and - bootstrap the Naming Service itself! Including TAO's support for - the Interoperable Naming Service. - </P> - - <H3>Registering an Object in the Naming Service</H3> - - <P>First we modify the server to register the stock factory with - the naming service. - We need to include the right header: - </P> -<PRE> -#include "orbsvcs/CosNamingC.h" -</PRE> - <P>We recall that we activate the stock factory using: - </P> -<PRE> - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); -</PRE> - <P>We need to obtain a reference to the Naming Service; this is - done using the <CODE>resolve_initial_references()</CODE> call: - </P> -<PRE> - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); -</PRE> - <P>Next we initialize the name that we will assign to the objects. - The naming service uses a sequence of structures for the name -- - think of it as a pathname decomposed into its directories. - In this case we will use a simple name. - In production environments some better organized hierarchy may - be imposed. - First create and initialize the sequence: - </P> -<PRE> - CosNaming::Name name (1); - name.length (1); -</PRE> - <P>Now we initialize the name: - </P> -<PRE> - name[0].id = CORBA::string_dup ("Stock_Factory"); -</PRE> - <P>Now we are ready to register the object reference in the naming - service: - </P> -<PRE> - naming_context->bind (name, stock_factory.in ()); -</PRE> - <P>Notice that <CODE>bind()</CODE> fails if the name is already in - the naming service. You may want to use <CODE>rebind()</CODE> to - override any values already there. - </P> - - <H3>Looking up the Object</H3> - - <P>Now the client can use the Naming Service to locate the object. - Instead of relying on the command line, - we have to perform the same calls to locate the naming service - and initialize the name of the object we want to look up: - </P> -<PRE> - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("Stock_Factory"); -</PRE> - <P>Now we can resolve the name:</P> -<PRE> - CORBA::Object_var factory_object = - naming_context->resolve (name); - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); -</PRE> - <P>And then we can use the object as before. - </P> - - <H3>Exercise 1</H3> - - <P>Complete the changes to the <CODE>server.cpp</CODE> file. - </P> - <P>You can use the following files to complete and test your - implementation: - <A HREF="../Simple/Quoter.idl">Quoter.idl</A>, - <A HREF="Makefile">Makefile</A>, - <A HREF="../Simple/Server/Stock_i.h">Stock_i.h</A>, - <A HREF="../Simple/Server/Stock_i.cpp">Stock_i.cpp</A>, - <A HREF="../Simple/Server/Stock_Factory_i.h">Stock_Factory_i.h</A> - <A HREF="../Simple/Server/Stock_Factory_i.cpp">Stock_Factory_i.cpp</A>. - - For more fun you can modify the original - <A HREF="../Simple/Client/client.cpp">client.cpp</A> file, too. - What about the first argument? Do we need the IOR now? - </P> - - <H4>Solution</H4> - - <P>Compare your solution with - <A HREF="client.cpp">client.cpp</A> - and <A HREF="server.cpp">server.cpp</A>. They should be very similar. - </P> - - <H4>Testing</H4> - - <P>To test your changes you need to run four programs. First - configure TAO's naming service lookup protocol to use a - unique port in your LAN. - Something based on your user id is a good idea, - for example: - </P> -<PRE> -$ setenv NameServicePort `expr 10000 + $uid` -</PRE> - <P>Now we can start the Naming Service provided with TAO: - </P> -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -</PRE> - <P>and your server: - </P> -<PRE> -$ server -</PRE> - <P>and finally the client: - </P> -<PRE> -$ client MSFT RHAT RHAT MSFT -</PRE> - - <H2>Finding the Naming Service</H2> - - <P>So how does TAO find the naming service? Until recently there - was no standard way to configure how the Naming Service was - bootstrapped. In TAO we decided to use IP multicast to locate - the server. The multicast protocol is very simple minded, but - works well in small LANs where there are not many naming - services running. - To avoid problems when multiple naming services run in the same - LAN, you must assign a different multicast port to each one, - as shown above. - </P> - <P>Unfortunately the protocol shown above does not work across - multiple LANs, and it is hard to ensure that there are no - conflicts in the assignment of multicast ports. - TAO supports the Interoperable Naming Service specification - that provides several mechanisms to control the behavior of the - <CODE>resolve_initial_references()</CODE> call. - For example, you can ask the Naming Service to dump its IOR to a - file, as in: - </P> -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -o ns.ior -</PRE> - <P>and then use the <CODE>-ORBInitRef</CODE> to that IOR - instead of the multicast protocol: - </P> -<PRE> -$ server -ORBInitRef NameService=`cat ns.ior` -</PRE> - <P>or even better use the <CODE>file:</CODE> scheme to read the - file directly: - </P> -<PRE> -$ server -ORBInitRef NameService=file://ns.ior -</PRE> - <P>but this still assumes that there is a shared filesystem - between the hosts, or that the user will copy the file across - the network. If we know what host and port the Naming Service - is using to accept IIOP requests, then we can use the - <CODE>corbaloc:</CODE> scheme: - </P> -<PRE> -$ server -ORBInitRef NameService=corbaloc:iiop:ace.cs.wustl.edu:12345/NameService -</PRE> - <P>In fact, controlling the host and port of any TAO program, - including the Naming Service, is easy. Just use the - <CODE>-ORBEndPoint</CODE> option: - </P> -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -ORBEndPoint iiop://ace.cs.wustl.edu:12345 -</PRE> - <P>Of course, this only works if you are running the program in - <CODE>ace.cs.wustl.edu</CODE> and the <CODE>12345</CODE> port is - free. You can use the magic port number <CODE>0</CODE> to let - the ORB find a free port. In fact, that is exactly what TAO does - by default. - Finally, you can use multiple <CODE>-ORBEndPoint</CODE> options - to listen on multiple endpoints. This is very useful for - multi-hosted machines. - </P> - - <H3>Exercise 2</H3> - - <P>Try using different approaches to find the Naming Service. Also - try to run the server with an invalid IOR for the naming - service. What happens if the server and client pick different - naming services through their multicast protocol? What happens - if they are not configured consistently with respect to their - Naming Service? - </P> - - <H3>Persistence</H3> - - <P>What happens if the naming service is killed between the object - registration and the lookup? By default TAO's Naming Service is - <STRONG>not</STRONG> persistent, but it is a matter of using a - flag to save its state on a file: -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -f name_service.dat -</PRE> - </P> - - <P>Notice that this is little use unless your services are - persistent too, or can be automatically restarted. That is the - role of the - <A HREF="http://ace.cs.wustl.edu/cvsweb/ace-latest.cgi/ACE_wrappers/TAO/docs/implrepo/index.html">Implementation Repository</A>. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 14:09:33 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Naming_Service/server.cpp b/TAO/docs/tutorials/Quoter/Naming_Service/server.cpp deleted file mode 100644 index 86d293611bc..00000000000 --- a/TAO/docs/tutorials/Quoter/Naming_Service/server.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "orbsvcs/CosNamingC.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i; - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Get the Naming Context reference - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - // Create and initialize the name. - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("Stock_Factory"); - - // Bind the object - naming_context->bind (name, stock_factory.in ()); - - orb->run (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.cpp deleted file mode 100644 index 1167c78c3e0..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// $Id$ -// - -#include "Handler_i.h" -#include "ace/streams.h" - -Single_Query_Stock_Handler_i:: - Single_Query_Stock_Handler_i (int *response_count) - : response_count_ (response_count) -{ -} - -void -Single_Query_Stock_Handler_i::get_price_and_names (CORBA::Double ami_return_val, - const char *symbol, - const char *full_name) - throw (CORBA::SystemException) -{ - cout << "The price of one stock in \"" - << full_name << "\" (" << symbol << ") is " - << ami_return_val << endl; - (*this->response_count_)++; -} - -void -Single_Query_Stock_Handler_i:: - get_price_and_names_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - // We ignore the exception, but this counts as a reponse, otherwise - // the application would not finish. - cerr << "Exception raised while querying stock price" - << endl; - (*this->response_count_)++; -} - - -void -Single_Query_Stock_Handler_i::get_symbol (const char *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - get_symbol_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i::get_full_name (const char *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - get_full_name_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i::price (double) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} - -void -Single_Query_Stock_Handler_i:: - price_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException) -{ - throw CORBA::NO_IMPLEMENT (); -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.h b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.h deleted file mode 100644 index b595d53be86..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Handler_i.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIALS_QUOTER_ONDEMAND_CLIENT_HANDLER_I_H -#define TAO_TUTORIALS_QUOTER_ONDEMAND_CLIENT_HANDLER_I_H - -#include "QuoterS.h" - -class Single_Query_Stock_Handler_i : public POA_Quoter::AMI_Single_Query_StockHandler -{ -public: - Single_Query_Stock_Handler_i (int *response_count); - - void get_price_and_names (CORBA::Double ami_return_val, - const char *symbol, - const char *full_name) - throw (CORBA::SystemException); - - void get_price_and_names_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void get_symbol(const char *) - throw (CORBA::SystemException); - void get_symbol_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void get_full_name (const char *) - throw (CORBA::SystemException); - void get_full_name_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - - void price (double) - throw (CORBA::SystemException); - void price_excep (::Messaging::ExceptionHolder *) - throw (CORBA::SystemException); - -private: - - int *response_count_; -}; - -#endif /* TAO_TUTORIALS_QUOTER_AMI_CLIENT_HANDLER_I_H */ diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Makefile.am b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Makefile.am deleted file mode 100644 index 29035de8f99..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Makefile.am +++ /dev/null @@ -1,146 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_On_Demand_Activation_Idl.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING - -BUILT_SOURCES = \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -CLEANFILES = \ - Quoter-stamp \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -QuoterC.cpp QuoterC.h QuoterC.inl QuoterS.cpp QuoterS.h QuoterS.inl: Quoter-stamp - -Quoter-stamp: $(srcdir)/Quoter.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) -GC $(srcdir)/Quoter.idl - @touch $@ - - -noinst_HEADERS = \ - Quoter.idl - -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Makefile.Quoter_On_Demand_Activation_Client.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -client_SOURCES = \ - Handler_i.cpp \ - QuoterC.cpp \ - QuoterS.cpp \ - client.cpp \ - Handler_i.h - -client_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Makefile.Quoter_On_Demand_Activation_Server.am - -if BUILD_AMI -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -server_SOURCES = \ - QuoterC.cpp \ - QuoterS.cpp \ - Stock_Factory_Locator_i.cpp \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_Locator_i.h \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING -endif BUILD_AMI - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter.idl b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter.idl deleted file mode 100644 index 80cfa1661d1..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter.idl +++ /dev/null @@ -1,49 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; - - interface Single_Query_Stock : Stock { - double get_price_and_names (out string symbol, - out string full_name); - }; -}; diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter_On_Demand_Activation.mpc b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter_On_Demand_Activation.mpc deleted file mode 100644 index 650bdc9d832..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Quoter_On_Demand_Activation.mpc +++ /dev/null @@ -1,35 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*idl): taoidldefaults, ami { - IDL_Files { - Quoter.idl - } - custom_only = 1 -} - -project(*client) : taoexe, portableserver, naming, ami, minimum_corba, exceptions { - after += *idl - source_files { - client.cpp - Handler_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*server) : taoserver, naming, ami, minimum_corba, exceptions { - after += *idl - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - Stock_Factory_Locator_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.cpp deleted file mode 100644 index ab075fcfcf7..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// $Id$ - -#include "Stock_Factory_Locator_i.h" -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_Locator_i:: -Quoter_Stock_Factory_Locator_i (CORBA::ORB_ptr orb) - : orb_ (CORBA::ORB::_duplicate (orb)) -{ -} - -PortableServer::Servant -Quoter_Stock_Factory_Locator_i::preinvoke (const PortableServer::ObjectId &oid, - PortableServer::POA_ptr, - const char *, - void * & cookie - ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException, PortableServer::ForwardRequest) -{ - - // Check to see if the object ID is valid - try { - - // Get the ObjectID in string format - CORBA::String_var oid_str = - PortableServer::ObjectId_to_string (oid); - - // Check if the ObjectId is valid - if (strcmp (oid_str.in (), "Quoter/Stock_Factory") != 0) { - // Create the required servant - PortableServer::Servant servant = - new Quoter_Stock_Factory_i (); - cookie = servant; - - return servant; - } - else { - throw CORBA::OBJECT_NOT_EXIST (); - } - - } catch (const CORBA::BAD_PARAM &) { - throw CORBA::OBJECT_NOT_EXIST (); - } -} - -void -Quoter_Stock_Factory_Locator_i::postinvoke (const PortableServer::ObjectId &, - PortableServer::POA_ptr, - const char *, - void * cookie, - PortableServer::Servant servant - ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - - // Delete the servant as it is no longer needed. - PortableServer::Servant my_servant = (PortableServer::Servant) cookie; - if (servant == my_servant) - delete servant; - -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.h b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.h deleted file mode 100644 index 4f3a9666ba2..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_Locator_i.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// $Id$ -// - -#ifndef STOCK_FACTORY_LOCATOR_I_H -#define STOCK_FACTORY_LOCATOR_I_H - -#include "tao/ORB.h" -#include "tao/PortableServer/PortableServer.h" -#include "tao/PortableServer/ServantLocatorC.h" - -class Quoter_Stock_Factory_Locator_i : public PortableServer::ServantLocator -{ - public: - Quoter_Stock_Factory_Locator_i (CORBA::ORB_ptr orb); - - // Preinvoke function - virtual PortableServer::Servant preinvoke (const PortableServer::ObjectId &oid, - PortableServer::POA_ptr poa, - const char * operation, - void * & cookie - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - throw (CORBA::SystemException, PortableServer::ForwardRequest); - - // Postinvoke function - virtual void postinvoke (const PortableServer::ObjectId & oid, - PortableServer::POA_ptr poa, - const char * operation, - void * cookie, - PortableServer::Servant servant - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - throw (CORBA::SystemException); - - private: - CORBA::ORB_var orb_; - -}; - -#endif /* STOCK_FACTORY_LOCATOR_I_H */ diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.cpp deleted file mode 100644 index b32249cb8fd..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// $Id$ - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - Quoter_Stock_i *rhat = new Quoter_Stock_i ("RHAT", "RedHat, Inc.", 210); - return rhat->_this (); - } else if (strcmp (symbol, "MSFT") == 0) { - Quoter_Stock_i *msft = new Quoter_Stock_i ("MSFT", "Microsoft, Inc.", 91); - return msft->_this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.h deleted file mode 100644 index 27103cce23b..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_Factory_i.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// $Id$ -// -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - - diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.cpp deleted file mode 100644 index 4e23bb6e618..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} - -CORBA::Double -Quoter_Stock_i::get_price_and_names (CORBA::String_out symbol, - CORBA::String_out full_name) - throw (CORBA::SystemException) -{ - symbol = CORBA::string_dup (this->symbol_.c_str ()); - full_name = CORBA::string_dup (this->full_name_.c_str ()); - - return this->price_; -} - - - diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.h b/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.h deleted file mode 100644 index 27163f9d2a0..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/Stock_i.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Single_Query_Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - CORBA::Double get_price_and_names (CORBA::String_out symbol, - CORBA::String_out full_name) - throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/client.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/client.cpp deleted file mode 100644 index fcb8a8f26da..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/client.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// $Id$ -// - -#include "Handler_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 3) { - cerr << "Usage: " << argv[0] - << " Factory_IOR symbol symbol..." << endl; - return 1; - } - - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Use the first argument to create the factory object reference, - // in real applications we use the naming service, but let's do - // the easy part first! - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Create and activate the handler... - int response_count = 0; - Single_Query_Stock_Handler_i handler_i (&response_count); - Quoter::AMI_Single_Query_StockHandler_var handler = - handler_i._this (); - - // Send all the requests, careful with error handling - int request_count = 0; - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var tmp = - factory->get_stock (argv[i]); - Quoter::Single_Query_Stock_var stock = - Quoter::Single_Query_Stock::_narrow (tmp.in ()); - if (CORBA::is_nil (stock.in ())) { - cerr << "Cannot get single query interface for <" - << argv[i] << ">" << endl; - } - - stock->sendc_get_price_and_names (handler.in ()); - request_count++; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - while (response_count < request_count - && orb->work_pending ()) { - orb->perform_work (); - } - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/index.html b/TAO/docs/tutorials/Quoter/On_Demand_Activation/index.html deleted file mode 100644 index 63e4fa14445..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/index.html +++ /dev/null @@ -1,280 +0,0 @@ - -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Servant Managers</title> - <!-- $Id$ --> - </head> - - <body text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h1>Servant Managers</h1> - <P>In our <a href=../AMI/index.html>previous example</a>, we - extended our <a href=../Simple/Client/client.cpp>simple client</a> - using synchronous method invocation to handle asynchronous - requests: Asynchronous Method Invocation by using - the reply handlers. - </P> - <P>In applications which have many objects, activating - all of them all the time would be unnecessary - and also might require too much memory or too many database - lookups. For such applications, the POA provides an option - for the application to supply servant managers that can - dynamically supply servants on a per-request basis. - </P> - <p> A servant manager is a call-back object that the application - registers with a POA. When the POA attempts to determine the - servant associated with a particular request, it calls back the - application's servant manager to obtain the servant. To be able - to register a servant manager with the POA, the - <CODE>RequestProcessingPolicyValue</CODE>, which controls the - matching of requests to servants, is to be set to - <CODE>USE_SERVANT_MANAGER</CODE>. - </P> - <P>There are two types of servant managers depending on whether the POA - retains the associations of objects to servants in its Active - Object Map or not. This is determined by the value of the - <CODE>ServantRetentionPolicy</CODE> set when the - POA is created. If the value of this policy is set as RETAIN, - the POA retains the associations, and if the policy value is set - to be NON_RETAIN, the POA doesn't retain any associations between - the object and the servant. - </P> - <P>For a POA with the RETAIN value, the servant manager must - activate the servant associated with the object. This would need - the servant manager object to support the ServantActivator - interface. In the case of a POA with the NON_RETAIN value set, - our servant manager object should be able to locate the servant - for the requested object and then invoke it. - </P> - <P>In this example, let's use a servant locator to locate the - servant associated with our Stock_Factory object when a request - is invoked on this object. - </P> - <H3>The Stock Factory Locator Implementation</H3> - <P>Our implementation of the Stock_Factory_Locator_i will help - us find the Quoter_Stock_Factory servant. - </P> - <P>A servant Locator interface provides two operations: preinvoke - and postinvoke. The preinvoke operation is invoked to obtain the - servant to dispatch the request to. The servant returned by - the preinvoke is used only for a single request. The postinvoke - operation is later invoked to destroy the servant created by the - preinvoke operation. - </P> - <PRE> - #include "tao/corba.h" - - class Quoter_Stock_Factory_Locator_i : public POA_PortableServer::ServantLocator - { - public: - Quoter_Stock_Factory_Locator_i (CORBA::ORB_ptr orb); - - // Preinvoke function - virtual PortableServer::Servant preinvoke (const PortableServer::ObjectId &oid, - PortableServer::POA_ptr poa, - const char * operation, - void * & cookie) - throw (CORBA::SystemException, PortableServer::ForwardRequest); - - // Postinvoke function - virtual void postinvoke (const PortableServer::ObjectId & oid, - PortableServer::POA_ptr poa, - const char * operation, - void * cookie, - PortableServer::Servant servant) - throw (CORBA::SystemException); - - private: - CORBA::ORB_var orb_; - }; - </PRE> - <P>In the implementation of the <CODE>preinvoke</CODE> operation, we check if - the object ID is valid and then check for the servant we want to - create and create and return the requested servant. - <PRE> - <PRE> - PortableServer::Servant - Quoter_Stock_Factory_Locator_i::preinvoke (const PortableServer::ObjectId &oid, - PortableServer::POA_ptr poa, - const char * operation, - void * & cookie) - throw (CORBA::SystemException, PortableServer::ForwardRequest) - { - - try { - - // Get the ObjectID in string format - CORBA::String_var oid_str = - PortableServer::ObjectId_to_string (oid); - - // Check if the ObjectId is valid - if (strcmp (oid_str.in (), "Quoter/Stock_Factory") != 0) { - // Create the requested servant. - PortableServer::Servant servant = - new Quoter_Stock_Factory_i (); - - cookie = servant; - - return servant; - } - else { - throw CORBA::OBJECT_NOT_EXIST (); - } - - }catch (const CORBA::BAD_PARAM &) { - throw CORBA::OBJECT_NOT_EXIST (); - } - </PRE> - <P>The implementation of the <CODE>postinvoke</CODE> operation is - simple. We just destroy the servant which we created by the - <CODE>preinvoke</CODE> operation. The <CODE>Cookie IDL - type</CODE> which is a parameter in both these operations - helps associate the invocation of <CODE>preinvoke</CODE> with - its <CODE>postinvoke</CODE> operation. - </P> - <PRE> - void - Quoter_Stock_Factory_Locator_i::postinvoke (const PortableServer::ObjectId &oid, - PortableServer::POA_ptr poa, - const char * operation, - void * cookie, - PortableServer::Servant servant) - throw (CORBA::SystemException) - { - - // Delete the servant as it is no longer needed. - PortableServer::Servant my_servant = (PortableServer::Servant) cookie; - if (servant == my_servant) - delete servant; - } - </PRE> - <H3> Server Implementation </H3> - <P>Our first steps would be to create a new POA from the RootPOA - with the <CODE>USE_SERVANT_MANAGER</CODE> value for the - <CODE>RequestProcessingPolicy</CODE> and <CODE>NON_RETAIN</CODE> - for the <CODE>ServantRetentionPolicy</CODE>. - </P> - <PRE> - CORBA::PolicyList policies (3); - policies.length (3); - - // Assign the polices - policies [0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - - policies [1] = - poa->create_request_processing_policy - (PortableServer::USE_SERVANT_MANAGER); - - policies [2] = - poa->create_servant_retention_policy (PortableServer::NON_RETAIN); - - // Create the POA with these policies - PortableServer::POA_var child_poa = - poa->create_POA ("childPOA", - poa_manager.in (), - policies); - - // Destroy the policy objects - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - </PRE> - <P> The policy values are assigned, the <CODE>childPOA</CODE> is - created with these policies, and later these policy objects can be - deleted, as a copy of these objects is made by the - <CODE>create_POA</CODE> and we would not need these objects any more. - </P> - <P> Now that we have the POA which can support servant managers, - the next step would be to create a servant for the servant - locator object, activate it to obtain its reference, and set it as - the servant manager with the childPOA. - </P> - <PRE> - // Create a Stock_Factory_Locator servant - Quoter_Stock_Factory_Locator_i servant_locator_i(orb.in ()); - - // Need to activate a servant_manager object in the Root POA - PortableServer::ServantLocator_var servant_locator = - servant_locator_i._this (); - - // Set the SM with the childPOA - child_poa->set_servant_manager (servant_locator.in ()); - </PRE> - <P>Now that we have set the servant manager with the childPOA, the - next step would be to create a reference with the user-created - ID in the childPOA which uses the Quoter_Stock_Factory_Locator_i. - The <CODE>create_reference_with_id</CODE> operation lets us - create the required object without actually creating its servant. - The application supplies the ObjectId which signifies the - identity of the object in the application domain. - </P> - <PRE> - // Get the Object Id - PortableServer::ObjectId_var child_oid = - PortableServer::string_to_ObjectId ("childFoo"); - - //Create the Object without creating the servants - CORBA::Object_var stock_factory = - child_poa->create_reference_with_id (child_oid.in (), - "IDL:Quoter/Stock_Factory:1.0"); - </PRE> - <P>After this, as before, let's put this object reference as an IOR - string and print it out. - </P> - <PRE> - // Put the object reference as an IOR string - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - - // Print it out! - std::cout << ior.in () << std::endl; - </PRE> - <H3>Excercise</H3> - <P>Modify the <a href="../Simple/Server/server.cpp">server.cpp</a> in - the simple server to use servant managers and locators. Use - these files to help complete the implementation. - <a href="Stock_Factory_Locator_i.h">Stock_Factory_locator_i.h</a> - <a href="Stock_Factory_Locator_i.cpp">Stock_Factory_locator_i.cpp</a> - <a href="Makefile">Makefile</a>. - </P> - <H3>Solution</H3> - <P>Look at the <a href="server.cpp">server.cpp</a> file. It should not - be much different from yours. - </P> - <H3>Testing</H3> - <P>A client which uses request handlers is provided: - <a href="../AMI/client.cpp">client.cpp</a>. As before the - following files are provided. - <a href="../AMI/Quoter.idl">Quoter.idl</a> - <a href="../On_Demand_Activation/Stock_i.h">Stock_i.h</a> - <a href="../On_Demand_Activation/Stock_i.cpp">Stock_i.cpp</a> - <a href="Stock_Factory_i.h">Stock_Factory_i.h</a> - <a href="Stock_Factory_i.cpp">Stock_Factory_i.cpp</a> - <a href="../AMI/Handler_i.h">Handler_i.h</a> and - <a href="../AMI/Handler_i.cpp">Handler_i.cpp</a>. - </P> - <H3>More Reading</H3> - <P>The - <P>The <A HREF="http://www.triodia.com/staff/michi-henning.html">Henning</A> and - <A HREF="http://www.iona.com/hyplan/vinoski/">Vinoski</A> - <A HREF="http://www.iona.com/hyplan/vinoski/#book">CORBA book</A> - discusses POA policies in detail. Likewise, the Schmidt and Vinoski - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">columns </A> - in C++ Report also include several articles about the POA. Finally, - the <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</a> - distribution includes - <A HREF="../../../../examples/POA">examples</A> that illustrate how to use the POA policies. - </P> - <hr> - <address><a href="mailto:pgontla@ece.uci.edu">Priyanka Gontla</a></address> - <!-- Created: Mon May 1 11:08:56 PDT 2000 --> - <!-- hhmts start --> -Last modified: Tue Apr 24 17:50:17 CDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/On_Demand_Activation/server.cpp b/TAO/docs/tutorials/Quoter/On_Demand_Activation/server.cpp deleted file mode 100644 index bf880a31793..00000000000 --- a/TAO/docs/tutorials/Quoter/On_Demand_Activation/server.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_Locator_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - CORBA::PolicyList policies (3); - policies.length (3); - - // Assign the polices - - policies[0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - - policies [1] = - poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER); - - policies [2] = - poa->create_servant_retention_policy (PortableServer::NON_RETAIN); - - // Create the POA with these policies - PortableServer::POA_var child_poa = - poa->create_POA ("childPOA", - poa_manager.in (), - policies); - - // Destroy the policy objects - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - // Create a Stock_Factory_Locator - PortableServer::ServantLocator_var servant_locator = - new Quoter_Stock_Factory_Locator_i (orb.in ()); - - // Set the SM with the childPOA - child_poa->set_servant_manager (servant_locator.in ()); - - PortableServer::ObjectId_var child_oid = - PortableServer::string_to_ObjectId ("childFoo"); - - CORBA::Object_var stock_factory = - child_poa->create_reference_with_id (child_oid.in (), - "IDL:Quoter/Stock_Factory:1.0"); - - - // Put the object reference as an IOR string - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - - // Print it out! - cout << ior.in () << endl; - - orb->run (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Admin.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Admin.cpp deleted file mode 100644 index 77bac1c8ab1..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Admin.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// $Id$ - -// ACE header files -#include "ace/Get_Opt.h" - -// local header files -#include "DistributorC.h" - -static const char *ior = "file://StockDistributor.ior"; -static const char *option = "start"; -static const char *rate = "1"; - -int parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "o:r:bs"); - int c; - - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'o': - ior = get_opts.opt_arg (); - break; - case 'r': - option = "rate"; - rate = get_opts.opt_arg (); - break; - case 'b': - option = "start"; - break; - case 's': - option = "stop"; - break; - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s\n" - "-o <Distributor IOR> (the ior file of stock distributor (default is file://StockDistributor.ior)) \n" - "-r <rate> (set the distribution rate to 'n' milliseconds (default is 1)) \n" - "-b (start the stock distributor) \n" - "-s (stop the stock distributor) \n" - "\n", - argv [0]), - -1); - } - } - - return 0; -} - -int main (int argc, char *argv[]) -{ - if (parse_args (argc, argv) != 0) - return 1; - - try - { - // Initialiaze the ORB. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Read and destringify the Stock_Distributor object's IOR. - CORBA::Object_var obj = orb->string_to_object (ior); - - // Narrow the IOR to a Stock_Distributor object reference. - Stock::StockDistributor_var stock_distributor = Stock::StockDistributor::_narrow(obj); - if (CORBA::is_nil (stock_distributor.in ())) - { - ACE_ERROR_RETURN ((LM_DEBUG, - "Nil StockDistributor object reference <%s>\n", - ior), - 1); - } - - if (ACE_OS::strcmp (option, "stop") == 0) - { - ACE_DEBUG ((LM_DEBUG, "Stop the stock distributor.\n")); - stock_distributor->stop (); - } - else if (ACE_OS::strcmp (option, "rate") == 0) - { - ACE_DEBUG ((LM_DEBUG, "Set the distribution notification rate to %d seconds.\n", atoi (rate))); - stock_distributor->notification_rate (atoi (rate)); - } - else - { - ACE_DEBUG ((LM_DEBUG, "Start the stock distributor.\n")); - stock_distributor->start (); - } - - orb->destroy (); - } - catch (CORBA::Exception &ex) - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception caught:"); - return 1; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Broker.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Broker.cpp deleted file mode 100644 index f8c39b0f9f0..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Broker.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// $Id$ - -// ACE header files -#include "ace/Get_Opt.h" - -// local header files -#include "Broker_i.h" -#include "Distributor_i.h" -#include "Stock_PriorityMapping.h" - -static const char *ior = "file://StockDistributor.ior"; -static const char *priority_level = "2"; -static const char *stock_name = "IBM"; - -int parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "o:p:n:"); - int c; - - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'o': - ior = get_opts.opt_arg (); - break; - case 'p': - priority_level = get_opts.opt_arg (); - break; - case 'n': - stock_name = get_opts.opt_arg (); - break; - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s\n" - "-o <Distributor IOR> (default is file://StockDistributor.ior) \n" - "-p <Priority> (default is 2) \n" - "-n <Stock name> (default is IBM) \n" - "\n", - argv [0]), - -1); - } - } - - return 0; -} - -int main (int argc, char *argv[]) -{ - if (parse_args (argc, argv) != 0) - return 1; - - try - { - // Initialiaze the ORB. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Get a reference to the RootPOA. - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = PortableServer::POA::_narrow (obj); - - // Activate the POAManager. - PortableServer::POAManager_var mgr = poa->the_POAManager (); - mgr->activate (); - - // Create an instance of the <StockBroker>. - static const RTCORBA::Priority priority = static_cast<RTCORBA::Priority> (atoi (priority_level)); - Stock_StockBrokerHome_i stock_broker_home (orb, stock_name, priority); - Stock::StockBroker_var stock_broker = stock_broker_home.create (); - if (CORBA::is_nil (stock_broker.in ())) - { - ACE_ERROR_RETURN ((LM_DEBUG, - "Nil StockBroker object reference <%s>\n", - ior), - 1); - } - - // Read and destringify the Stock_Distributor object's IOR. - obj = orb->string_to_object (ior); - - // Narrow the IOR to a Stock_Distributor object reference. - Stock::StockDistributor_var stock_distributor = Stock::StockDistributor::_narrow(obj); - if (CORBA::is_nil (stock_distributor.in ())) - { - ACE_ERROR_RETURN ((LM_DEBUG, - "Nil StockDistributor object reference <%s>\n", - ior), - 1); - } - - // Connect the <stock_quoter> to the <stock_broker>. - Stock::StockQuoter_var stock_quoter = stock_distributor->provide_quoter_info (); - stock_broker->connect_quoter_info (stock_quoter); - - // Create a new consumer; initialize it; subscribe to the notification service. - Stock::StockNameConsumer_var consumer = stock_broker->get_consumer_notifier (); - stock_distributor->subscribe_notifier (consumer, priority); - - // Run the event loop. - ACE_DEBUG ((LM_DEBUG, "*** message: ready to receieve stock information...\n")); - orb->run (); - orb->destroy (); - } - catch (CORBA::Exception &ex) - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception caught:"); - return 1; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Broker.idl b/TAO/docs/tutorials/Quoter/RTCORBA/Broker.idl deleted file mode 100644 index 63b7a6d1c99..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Broker.idl +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @file Broker.idl -* @author William Otte <wotte@dre.vanderbilt.edu> -* Shanshan Jiang <shanshan.jiang@vanderbilt.edu> -* $Id$ -* Contains IDL definitions for the Stock Broker in the Publish/Subscribe Real-time CORBA -* Stock Quoter Service. -*/ - -#ifndef QUOTER_BROKER_IDL -#define QUOTER_BROKER_IDL - -#include "Common.idl" - -module Stock -{ - /** - * @class StockBroker - * @brief Provides interfaces for stock broker clients. - */ - interface StockBroker - { - /// Factory operation to return StockNameConsumer object reference. - StockNameConsumer get_consumer_notifier (); - - /// Connects the broker to a supplied Quoter object reference. - void connect_quoter_info (in StockQuoter c); - - /// Disconnects a the quoter connection. - StockQuoter disconnect_quoter_info (); - - /// Gets the current quoter connection. - StockQuoter get_connection_quoter_info (); - }; - - /** - * @class StockBrokerHome - * @brief Interface that aids in managing StockBroker lifecycles. - */ - interface StockBrokerHome - { - /// Create a StockBroker object. - StockBroker create (); - }; -}; - -#endif diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.cpp deleted file mode 100644 index 1862e32a133..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// $Id$ - -// TAO headers -#include "tao/RTPortableServer/RTPortableServer.h" - -// local headers -#include "Broker_i.h" -#include "Stock_PriorityMapping.h" -#include "Stock_Database.h" - -// Implementation skeleton constructor -Stock_StockBroker_i::Stock_StockBroker_i (CORBA::ORB_ptr orb, - const char *stock_name, - RTCORBA::Priority priority) - : quoter_ (Stock::StockQuoter::_nil()), - consumer_ (0) -{ - // Get a reference to the <RTORB>. - CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); - RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ()); - - // Create a <CORBA::PolicyList> for the child POA. - CORBA::PolicyList consumer_policies (1); - consumer_policies.length (1); - - // Create a <SERVER_DECLARED> priority model policy. - consumer_policies[0] = rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED, - Stock_PriorityMapping::MEDIUM); - - // Create a child POA with SERVER_DECLARED policies. The name of the - // POA will be <Stock_StockDistributorHome>. Any instances of the - // Stock_StockDistributor_i created via the create() method will be - // activated under this POA. - PortableServer::POA_var poa = this->_default_POA()->create_POA ( - "StockNameConsumer_POA", PortableServer::POAManager::_nil (), consumer_policies); - - consumer_policies[0]->destroy (); - - // Narrow the POA to a <RTPortableServer::POA>. - RTPortableServer::POA_var rt_poa = RTPortableServer::POA::_narrow (poa); - - // Activate the <consumer_> with the specified <priority>. - this->consumer_ = new Stock_StockNameConsumer_i (this->_this (), stock_name); - PortableServer::ServantBase_var nameconsumer_owner_transfer = this->consumer_; - rt_poa->activate_object_with_priority (this->consumer_, priority); -} - -// Implementation skeleton destructor -Stock_StockBroker_i::~Stock_StockBroker_i (void) -{ -} - -::Stock::StockNameConsumer_ptr Stock_StockBroker_i::get_consumer_notifier () - throw (::CORBA::SystemException) -{ - Stock::StockNameConsumer_var consumer = this->consumer_->_this (); - return consumer._retn(); -} - -void Stock_StockBroker_i::connect_quoter_info (::Stock::StockQuoter_ptr c) - throw (::CORBA::SystemException) -{ - this->quoter_ = Stock::StockQuoter::_duplicate (c); -} - -::Stock::StockQuoter_ptr Stock_StockBroker_i::disconnect_quoter_info () - throw (::CORBA::SystemException) -{ - Stock::StockQuoter_var old_quoter = this->quoter_; - this->quoter_ = Stock::StockQuoter::_nil(); - return old_quoter._retn (); -} - -::Stock::StockQuoter_ptr Stock_StockBroker_i::get_connection_quoter_info () - throw (::CORBA::SystemException) -{ - return Stock::StockQuoter::_duplicate (this->quoter_); -} - -// Implementation skeleton constructor -Stock_StockBrokerHome_i::Stock_StockBrokerHome_i (CORBA::ORB_ptr orb, - const char *stock_name, - RTCORBA::Priority priority) - : broker_ (0) -{ - // Register the necessary factories and mappings with the specified - // <orb>. If we neglect to perform these registrations then the app - // will not execute. - Stock::StockName_init *stockname_factory = new Stock::StockName_init; - orb->register_value_factory (stockname_factory->tao_repository_id (), - stockname_factory); - - Stock::Cookie_init *cookie_factory = new Stock::Cookie_init; - orb->register_value_factory (cookie_factory->tao_repository_id (), - cookie_factory); - - Stock_PriorityMapping::register_mapping (orb); - - // Because the broker has nothing to do with any of the RTCORBA - // mechanisms, we can register it under the <default_POA>. - try - { - this->broker_ = new Stock_StockBroker_i (orb, stock_name, priority); - PortableServer::ServantBase_var broker_owner_transfer = this->broker_; - this->_default_POA ()->activate_object (this->broker_); - } - catch (PortableServer::POA::ServantAlreadyActive &) { - // we only catch this exception and let any other exception - // propogate to the upper level. - } -} - -// Implementation skeleton destructor -Stock_StockBrokerHome_i::~Stock_StockBrokerHome_i (void) -{ -} - -::Stock::StockBroker_ptr Stock_StockBrokerHome_i::create () - throw (::CORBA::SystemException) -{ - Stock::StockBroker_var broker = this->broker_->_this (); - return broker._retn(); -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.h b/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.h deleted file mode 100644 index d8fb12c8095..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Broker_i.h +++ /dev/null @@ -1,116 +0,0 @@ -// $Id$ - -/** - * @file Broker_i.h - * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> - */ - -#ifndef BROKERI_H_ -#define BROKERI_H_ - -// local headers -#include "Common_i.h" -#include "BrokerS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -/** - * @class Stock_StockBroker_i - * @brief This class defined the Stock Broker client. - */ -class Stock_StockBroker_i - : public virtual POA_Stock::StockBroker -{ -public: - /** - * Constructor. - * - * @param orb - * @param stock_name The name of the stock that the Stock Broker client is interested in. - * @param priority The priority of this Stock Broker client. - */ - Stock_StockBroker_i (CORBA::ORB_ptr orb, - const char *stock_name, - RTCORBA::Priority priority); - - /// Destructor - virtual ~Stock_StockBroker_i (void); - - /** - * Return the StockNameConsumer object created by the Constructor. - * - * @return Returns a StockNameConsumer object reference. - */ - virtual ::Stock::StockNameConsumer_ptr get_consumer_notifier () - throw (::CORBA::SystemException); - - /** - * Duplicate a StockQuoter object using the StockQuoter object reference "c" in the argument. - * - * @param c A StockQuoter object reference. - */ - virtual void connect_quoter_info (::Stock::StockQuoter_ptr c) - throw (::CORBA::SystemException); - - /** - * Destroy the StockQuoter object and return it. - * - * @return Returns the destroyed StockQuoter object reference. - */ - virtual ::Stock::StockQuoter_ptr disconnect_quoter_info () - throw (::CORBA::SystemException); - - /** - * Return the StockQuoter object. - * - * @return Returns the StockQuoter object reference that has been created by connect_quoter_info (). - */ - virtual ::Stock::StockQuoter_ptr get_connection_quoter_info () - throw (::CORBA::SystemException); - -private: - /// A StockQuoter object reference that is used to get detailed stock information. - Stock::StockQuoter_var quoter_; - - /// A StockNameConsumer object that is used to get notification of updates. - Stock_StockNameConsumer_i *consumer_; -}; - -/** - * @class Stock_StockBrokerHome_i - * @brief This class defined the Stock Broker home. - */ -class Stock_StockBrokerHome_i - : public virtual POA_Stock::StockBrokerHome -{ -public: - /** - * Constructor. - * Register the necessary factories and mappings with the specified orb and - * Create a new instance of the StockBroker object. - * - * @param orb - */ - Stock_StockBrokerHome_i (CORBA::ORB_ptr orb, - const char *stock_name, - RTCORBA::Priority priority); - - /// Destructor - virtual ~Stock_StockBrokerHome_i (void); - - /** - * Return the StockBroker object created by the Constructor. - * - * @return The StockBroker object created by the Constructor. - */ - virtual ::Stock::StockBroker_ptr create () - throw (::CORBA::SystemException); - -private: - /// The StockDistributor object created by its home. - Stock_StockBroker_i *broker_; -}; - -#endif /* BROKERI_H_ */ diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Common.idl b/TAO/docs/tutorials/Quoter/RTCORBA/Common.idl deleted file mode 100644 index 9ff78a5c611..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Common.idl +++ /dev/null @@ -1,67 +0,0 @@ -/** -* @file Common.idl -* @author William Otte <wotte@dre.vanderbilt.edu> -* Shanshan Jiang <shanshan.jiang@vanderbilt.edu> -* $Id$ -* Contains common IDL definitions in the Publish/Subscribe Real-time CORBA -* Stock Quoter Service. -*/ - -#ifndef QUOTER_COMMON_IDL -#define QUOTER_COMMON_IDL - -module Stock -{ - exception Invalid_Stock - { - }; - - /// Contains information about a single stock. - struct StockInfo - { - string name; - long high; - long low; - long last; - }; - - /// Used to communicate an available update. - valuetype StockName - { - public string name; - }; - - valuetype Cookie - { - public string cookie_id; - }; - - interface Trigger - { - void start (); - void stop (); - }; - - /** - * @class StockNameConsumer - * @brief Callback interface used by the distributor to notify brokers of updates. - */ - interface StockNameConsumer - { - void push_StockName (in StockName the_stockname); - }; - - /** - * @class StockQuoter - * @brief Provides an interface for brokers to get detailed stock information. - */ - interface StockQuoter - { - /// Returns detailed stock information to brokers. - /// @param stockname A valid name for a stock. - /// @returns Completed stockinfo struct. - StockInfo get_stock_info (in string stock_name) raises (Invalid_Stock); - }; -}; - -#endif diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.cpp deleted file mode 100644 index 51fc0b28fb2..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// $Id$ - -// local headers -#include "Common_i.h" -#include "Stock_Database.h" - -// Implementation skeleton constructor -Stock_StockNameConsumer_i::Stock_StockNameConsumer_i (Stock::StockBroker_ptr parent, - const char *stock_name) - : parent_ (Stock::StockBroker::_duplicate (parent)), - stock_name_ (CORBA::string_dup (stock_name)) -{ -} - -// Implementation skeleton destructor -Stock_StockNameConsumer_i::~Stock_StockNameConsumer_i (void) -{ -} - -void Stock_StockNameConsumer_i::push_StockName (::Stock::StockName *the_stockname) - throw (::CORBA::SystemException) -{ - // Verify the <parent_> is valid. There is no need to continue processing - // any information if there is not <parent_> attached to the object. The - // <parent_> is needed to retrieve the <quoter>. - if (CORBA::is_nil (this->parent_)) - return; - - // Verify this is the correct stock. If this is not the stock that we are - // interested in then we need to stop and return control to the client/ - // server. - if (ACE_OS::strcmp (this->stock_name_, the_stockname->name ()) != 0) - return; - - // Get the quoter for the connection. - ACE_DEBUG ((LM_DEBUG, "*** message: getting the quoter connection\n")); - Stock::StockQuoter_var quoter = this->parent_->get_connection_quoter_info (); - - try - { - // Request more information from the quoter. - ACE_DEBUG ((LM_DEBUG, "*** message: requesting the stock info from the quoter\n")); - Stock::StockInfo_var stock_info = quoter->get_stock_info (the_stockname->name()); - - // Display the current value of the stock. - ACE_DEBUG ((LM_DEBUG, "Current value of %s is $%d\n", - the_stockname->name (), stock_info->last)); - } - catch (Stock::Invalid_Stock &e) - { - ACE_PRINT_EXCEPTION (e, "Stock exception: invalid stock name: "); - } - catch (CORBA::Exception &ex) - { - ACE_PRINT_EXCEPTION (ex, "Stock_StockNameConsumer_i::push_StockName: "); - } -} - -// Implementation skeleton constructor -Stock_StockQuoter_i::Stock_StockQuoter_i (void) -{ -} - -// Implementation skeleton destructor -Stock_StockQuoter_i::~Stock_StockQuoter_i (void) -{ -} - -::Stock::StockInfo *Stock_StockQuoter_i::get_stock_info (const char * stock_name) - throw (::CORBA::SystemException, ::Stock::Invalid_Stock) -{ - ACE_DEBUG ((LM_DEBUG, "*** message: requesting stock_info from the database\n")); - - Stock::StockInfo *stock = STOCK_DATABASE->get_stock_info (stock_name); - - if (stock == 0) - throw Stock::Invalid_Stock(); - return stock; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.h b/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.h deleted file mode 100644 index 77e829366b1..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Common_i.h +++ /dev/null @@ -1,86 +0,0 @@ -// $Id$ - -/** - * @file Common_i.h - * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> - */ - -#ifndef COMMONI_H_ -#define COMMONI_H_ - -// local headers -#include "CommonS.h" -#include "BrokerS.h" - -// TAO headers -#include "tao/RTCORBA/RTCORBA.h" - -// STL headers -#include <string> - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -/** - * @class Stock_StockNameConsumer_i - * @brief This class is used as a callback interface used by the - * distributor to notify brokers of updates. - */ -class Stock_StockNameConsumer_i - : public virtual POA_Stock::StockNameConsumer -{ -public: - /** - * Constructor. - * - * @param parent The parent StockBroker object reference of the StockNameConsumer object. - * @param stock_name The name of the stock that the parent StockBroker object need to listen to. - */ - Stock_StockNameConsumer_i (Stock::StockBroker_ptr parent, - const char *stock_name); - - /// Destructor. - virtual ~Stock_StockNameConsumer_i (void); - - /** - * Push an event to the consumer. - * - * @param the_stockname The name of the stock that will be provided to the parent StockBroker object. - */ - virtual void push_StockName (::Stock::StockName *the_stockname) - throw (::CORBA::SystemException); - -private: - /// Parent of the StockNameConsumer object. - Stock::StockBroker_var parent_; - - /// Name of the stock to listen to. - CORBA::String_var stock_name_; -}; - -/** - * @class Stock_StockQuoter_i - * @brief This class is used by brokers to get detailed stock information. - */ -class Stock_StockQuoter_i - : public virtual POA_Stock::StockQuoter -{ -public: - /// Constructor. - Stock_StockQuoter_i (void); - - /// Destructor. - virtual ~Stock_StockQuoter_i (void); - - /** - * Get detailed stock information. - * - * @param stock_name The name of the stock whose detailed info is needed. - * @throw ::Stock::Invalid_Stock - */ - virtual ::Stock::StockInfo * get_stock_info (const char *stock_name) - throw (::CORBA::SystemException, ::Stock::Invalid_Stock); -}; - -#endif /* COMMONI_H_ */ diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.cpp deleted file mode 100644 index 0c941b50bcb..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// $Id$ - -// ACE header files -#include "ace/Get_Opt.h" - -// local header files -#include "Distributor_i.h" - -static const char *ior = "StockDistributor.ior"; -static const char *rate = "1"; - -int parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "o:r:"); - int c; - - while ((c = get_opts ()) != -1) - { - switch (c) - { - case 'o': - ior = get_opts.opt_arg (); - break; - case 'r': - rate = get_opts.opt_arg (); - break; - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s\n" - "-o <Distributor IOR> (default is file://StockDistributor.ior) \n" - "\n", - argv [0]), - -1); - } - } - - return 0; -} - -int main (int argc, char *argv[]) -{ - if (parse_args (argc, argv) != 0) - return 1; - - try - { - // Initalize the ORB. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Get the RootPOA. - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); - ACE_ASSERT (!CORBA::is_nil (obj)); - - // Activate the POAManager. - PortableServer::POAManager_var mgr = poa->the_POAManager (); - mgr->activate (); - - // Create the factory object. Create a <Stock::StockDistributor>. - Stock_StockDistributorHome_i stock_distributor_home (orb); - Stock::StockDistributor_var stock_distributor = stock_distributor_home.create (); - if (CORBA::is_nil (stock_distributor.in ())) - { - ACE_ERROR_RETURN ((LM_DEBUG, - "Nil StockDistributor object reference <%s>\n", - ior), - 1); - } - - // Write the object reference for the <stock_distributor> to a file - // so the <StockBroker> can read it when it's bootstrapping. - CORBA::String_var str = orb->object_to_string (stock_distributor.in ()); - FILE *output_file= ACE_OS::fopen (ior, "w"); - if (output_file == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot open output file for writing IOR: %s\n", - ior), - 1); - ACE_OS::fprintf (output_file, "%s", str.in ()); - ACE_OS::fclose (output_file); - - stock_distributor->notification_rate (atoi (rate)); - - // Enter into the event looping. - ACE_DEBUG ((LM_DEBUG, "*** message: ready for transmission...\n")); - orb->run (); - orb->destroy (); - } - catch (CORBA::Exception &ex) - { - ACE_PRINT_EXCEPTION (ex, "Admin: "); - - return 1; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.idl b/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.idl deleted file mode 100644 index e40be03854d..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor.idl +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @file Distributor.idl -* @author William Otte <wotte@dre.vanderbilt.edu> -* Shanshan Jiang <shanshan.jiang@vanderbilt.edu> -* $Id$ -* Contains IDL definitions for the Distributor in the Publish/Subscribe Real-time CORBA -* Stock Quoter Service. -*/ - -#ifndef QUOTER_DISTRIBUTOR_IDL -#define QUOTER_DISTRIBUTOR_IDL - -#include "Common.idl" -#include "tao/RTCORBA/RTCORBA_include.pidl" - -module Stock -{ - /** - * @class StockDistributor - * @brief Provides interfaces for stock distributor server. - */ - interface StockDistributor : Trigger - { - /// Event source operation to establish connectivity. - /// @param c An object reference to the consumer the distributor should notify - /// @returns A cookie used to identify the subscription. - Cookie subscribe_notifier (in Stock::StockNameConsumer c, in RTCORBA::Priority priority); - - /// Opteration to discontinue connectivity. - /// @param ck The cookie that identifies the connection to be terminated. - Stock::StockNameConsumer unsubscribe_notifier (in Cookie ck); - - /// Factory operation to return StockQuoter object reference. - StockQuoter provide_quoter_info (); - - /// Controls rate of updates. - attribute long notification_rate; - }; - - /** - * @class StockDistributorHome - * @brief Interface that aids in managing StockDistributor lifecycles. - */ - interface StockDistributorHome - { - /// Create a StockDistributor object. - StockDistributor create (); - }; -}; - -#endif diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.cpp deleted file mode 100644 index af66ceafd96..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.cpp +++ /dev/null @@ -1,249 +0,0 @@ -// $Id$ - -// ACE headers -#include "ace/OS_NS_unistd.h" - -// TAO headers -#include "tao/RTPortableServer/RTPortableServer.h" - -// local headers -#include "Distributor_i.h" -#include "Stock_PriorityMapping.h" -#include "Stock_Database.h" - -// STL headers -#include <strstream> - -// Implementation skeleton constructor -Stock_StockDistributor_i::Stock_StockDistributor_i (CORBA::PolicyList &policy_list) - : rate_(3000), - active_ (false), - quoter_ (0) -{ - // Create a child POA with CLIENT_PROPAGATED policies. The name of the - // POA will be <StockQuoter_POA>. Any instances of the - // Stock_StockQuoter_i created by this Stock_StockDistributor_i object - // will be activated under this POA. - PortableServer::POA_var poa = this->_default_POA()->create_POA ( - "StockQuoter_POA", PortableServer::POAManager::_nil (), policy_list); - - // _narrow () the POA to a RTPortableServer::POA. - RTPortableServer::POA_var rt_poa = RTPortableServer::POA::_narrow (poa); - - // Create a new instance of the <quoter_> under it's own personal - // POA. But the POA shares the <threadpool> with other POA's as well. - this->quoter_ = new Stock_StockQuoter_i; - PortableServer::ServantBase_var quoter_owner_transfer = this->quoter_; - rt_poa->activate_object (this->quoter_); - - // Seed the random number generator - ACE_OS::srand (time (0)); -} - -// Implementation skeleton destructor -Stock_StockDistributor_i::~Stock_StockDistributor_i (void) -{ - this->active_ = false; -} - -::Stock::Cookie * Stock_StockDistributor_i::subscribe_notifier (::Stock::StockNameConsumer_ptr c, - ::RTCORBA::Priority priority) - throw (::CORBA::SystemException) -{ - // Get mutual exclusion of the <subscribers_list_>. - ACE_GUARD_RETURN (ACE_RW_Thread_Mutex, g, lock_, 0); - - // Generate an unique id for the cookie. - std::ostrstream cookie_id; - cookie_id << "COOKIE:" << time (0) << "_" << ACE_OS::rand () << std::ends; - - // Create a new cookie object; initialize its value. - Stock::Cookie_var cookie = new OBV_Stock::Cookie (cookie_id.str ()); - - // Insert the cookie into the <subscribers_list_>. - std::pair <CookieMap::iterator, bool> result = - this->subscribers_list_.insert (std::make_pair (cookie->cookie_id (), - std::make_pair (Stock::StockNameConsumer::_duplicate (c), priority))); - - if (result.second == true) - { - return cookie._retn(); - } - - return 0; -} - -::Stock::StockNameConsumer_ptr Stock_StockDistributor_i::unsubscribe_notifier (::Stock::Cookie *ck) - throw (::CORBA::SystemException) -{ - // Get mutual exclusion of the <subscribers_list_>. - ACE_GUARD_RETURN (ACE_RW_Thread_Mutex, g, lock_, 0); - - // Search for the <cookie> in the <subscribers_list_>. - CookieMap::iterator iter = this->subscribers_list_.find (ck->cookie_id ()); - - // Verify we have located the <cookie>. - if (iter == this->subscribers_list_.end ()) - return Stock::StockNameConsumer::_nil (); - - // Erase the mapping from the <subscribers_list_>. - Stock::StockNameConsumer_var consumer = iter->second.first; - this->subscribers_list_.erase (iter); - - // Return the StockNameConsumer to the client. - return Stock::StockNameConsumer::_duplicate (consumer); -} - -::Stock::StockQuoter_ptr Stock_StockDistributor_i::provide_quoter_info () - throw (::CORBA::SystemException) -{ - Stock::StockQuoter_var quoter = this->quoter_->_this (); - return quoter._retn(); -} - -::CORBA::Long Stock_StockDistributor_i::notification_rate () - throw (::CORBA::SystemException) -{ - return this->rate_; -} - -void Stock_StockDistributor_i::notification_rate (::CORBA::Long notification_rate) - throw (::CORBA::SystemException) -{ - this->rate_ = notification_rate; -} - -void Stock_StockDistributor_i::start () - throw (::CORBA::SystemException) -{ - if (!this->active_) - { - this->active_ = true; - - this->activate (THR_NEW_LWP | THR_JOINABLE, 1); - } -} - -void Stock_StockDistributor_i::stop () - throw (::CORBA::SystemException) -{ - this->active_ = false; -} - -// Implementation skeleton constructor -Stock_StockDistributorHome_i::Stock_StockDistributorHome_i (CORBA::ORB_ptr orb) - : distributor_ (0) -{ - // Register the necessary factories and mappings with the specified - // <orb>. If we neglect to perform these registrations then the app - // will not execute. - Stock::StockName_init *stockname_factory = new Stock::StockName_init; - orb->register_value_factory (stockname_factory->tao_repository_id (), - stockname_factory); - - Stock::Cookie_init *cookie_factory = new Stock::Cookie_init; - orb->register_value_factory (cookie_factory->tao_repository_id (), - cookie_factory); - - Stock_PriorityMapping::register_mapping (orb); - - // Initialize the database - STOCK_DATABASE->activate (THR_NEW_LWP | THR_JOINABLE, 1); - - // Get a reference to the <RTORB>. - CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); - RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ()); - - // Create a <CORBA::PolicyList> for the child POA. - CORBA::PolicyList stock_distributor_policies (2); - stock_distributor_policies.length (2); - - // Create a <CLIENT_PROPOGATED> priority model policy. - stock_distributor_policies[0] = - rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, - Stock_PriorityMapping::MEDIUM); - - // Create a threadpool with lanes for the distributor. Since the brokers - // will have various priorities, create a lane for each priority. - RTCORBA::ThreadpoolLanes lanes (5); lanes.length (5); - for (CORBA::ULong i = 0; i < lanes.length (); ++i) { - lanes[i].lane_priority = static_cast<RTCORBA::Priority> (i); - lanes[i].static_threads = 5; - lanes[i].dynamic_threads = 2; - } - - RTCORBA::ThreadpoolId threadpool_id = - rt_orb->create_threadpool_with_lanes (1024 * 10, lanes, false, false, 0, 0); - stock_distributor_policies[1] = rt_orb->create_threadpool_policy (threadpool_id); - - // Create a child POA with CLIENT_PROPAGATED policies. The name of the - // POA will be <StockDistributor_POA>. Any instances of the - // Stock_StockDistributor_i created via the create() method will be - // activated under this POA. - PortableServer::POA_var poa = this->_default_POA()->create_POA ( - "StockDistributor_POA", PortableServer::POAManager::_nil (), stock_distributor_policies); - - // Create a new instance of the <Stock_StockDistributor_i>. Then activate - // the <distributor> under the located POA. This will cause the objec - // to have the CLIENT_PROPAGATED policies. - RTPortableServer::POA_var rt_poa = RTPortableServer::POA::_narrow (poa); - - try - { - this->distributor_ = new Stock_StockDistributor_i (stock_distributor_policies); - PortableServer::ServantBase_var distributor_owner_transfer = this->distributor_; - rt_poa->activate_object (this->distributor_); - } - catch (RTPortableServer::POA::ServantAlreadyActive &) - { - } - - stock_distributor_policies[0]->destroy (); - stock_distributor_policies[1]->destroy (); -} - -// Implementation skeleton destructor -Stock_StockDistributorHome_i::~Stock_StockDistributorHome_i (void) -{ -} - -::Stock::StockDistributor_ptr Stock_StockDistributorHome_i::create () - throw (::CORBA::SystemException) -{ - Stock::StockDistributor_var distributor = this->distributor_->_this (); - return distributor._retn(); -} - -int Stock_StockDistributor_i::svc (void) -{ - // Continue looping while the stock distributor is active. - while (this->active_) - { - ACE_DEBUG ((LM_DEBUG, "*** message: transmitting data to the StockNameConsumer...\n")); - - ACE_GUARD_RETURN (ACE_RW_Thread_Mutex, g, lock_, 0); - - // Push the information to all the consumers. - Stock_StockDistributor_i::CookieMap::iterator iter; - - for (iter = this->subscribers_list_.begin (); - iter != this->subscribers_list_.end (); - ++iter) - { - try - { - // Tell the database to push its information to the <consumer>. - STOCK_DATABASE->publish_stock_info (iter->second.first); - } - catch (CORBA::Exception &ex) - { - ACE_PRINT_EXCEPTION (ex, "Stock_StockDistributor_i::svc: "); - } - } - - // Sleep for the specified amount of seconds. The notification - // rate is in milliseconds. - ACE_OS::sleep(this->notification_rate ()); - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.h b/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.h deleted file mode 100644 index 89d0f20a882..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Distributor_i.h +++ /dev/null @@ -1,158 +0,0 @@ -// $Id$ - -/** - * @file Distributor_i.h - * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> - */ - -#ifndef DISTRIBUTORI_H_ -#define DISTRIBUTORI_H_ - -// ACE headers -#include "ace/Task.h" - -// local headers -#include "Common_i.h" -#include "DistributorS.h" - -// STL headers -#include <map> - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -/** - * @class Stock_StockDistributor_i - * @brief This class defined the Stock Distributor server. - */ -class Stock_StockDistributor_i - : public ACE_Task_Base, - public virtual POA_Stock::StockDistributor -{ -public: - /** - * Constructor. - * - * @param orb - * @param policy_list The policy list use to create StockQuoter_POA. - */ - Stock_StockDistributor_i (CORBA::PolicyList &policy_list); - - /// Destructor - virtual ~Stock_StockDistributor_i (void); - - /** - * Insert StockNameConsumer object and its priority into the StockDistributor - * object's subscribers' map. - * - * @param c The StockNameConsumer object to be inserted into the StockDistributor - object's subscribers' map. - * @param priority The priority of the StockNameConsumer object. - * @return A Cookie object that records this subscription. - */ - virtual ::Stock::Cookie * subscribe_notifier (::Stock::StockNameConsumer_ptr c, ::RTCORBA::Priority priority) - throw (::CORBA::SystemException); - - /** - * Erase the StockNameConsumer object from the StockDistributor object's subscribers' map. - * - * @param ck The Cookie object that records the subscription. - * @param The reference of the StockNameConsumer object that has been erased. - */ - virtual ::Stock::StockNameConsumer_ptr unsubscribe_notifier (::Stock::Cookie *ck) - throw (::CORBA::SystemException); - - /** - * Return the StockQuoter object created by the Constructor. - * - * @return A StockQuoter object created by this StockDistributor object. - */ - virtual ::Stock::StockQuoter_ptr provide_quoter_info () - throw (::CORBA::SystemException); - - /** - * Get the notification_rate attribute. - * - * @return The notification_rate attribute. - */ - virtual ::CORBA::Long notification_rate () - throw (::CORBA::SystemException); - - /** - * Set the notification_rate attribute. - * - * @param notification_rate The value of notification_rate attribute that need to be set. - */ - virtual void notification_rate (::CORBA::Long notification_rate) - throw (::CORBA::SystemException); - - /** - * Set the active state of the StockDistributor object to true and create a thread - * to publish the stock information to the Stock Broker clients. - */ - virtual void start () - throw (::CORBA::SystemException); - - /** - * Set the active state of StockDistributor object to false. - */ - virtual void stop () - throw (::CORBA::SystemException); - -private: - virtual int svc (void); - - /// Notification rate for distributor in milliseconds. - CORBA::Long rate_; - - /// The map that stores the subscribed StockNameConsumer object. - typedef std::map <const char *, - std::pair <Stock::StockNameConsumer_ptr, - RTCORBA::Priority> > CookieMap; - CookieMap subscribers_list_; - - /// The StockQuoter object created by this StockDistributor object. - Stock_StockQuoter_i *quoter_; - - /// ACE_RW_Thread_Mutex. - ACE_RW_Thread_Mutex lock_; - - /// The active state of the StockDistributor object. - bool active_; -}; - -/** - * @class Stock_StockDistributorHome_i - * @brief This class defined the Stock Distributor home. - */ -class Stock_StockDistributorHome_i - : public virtual POA_Stock::StockDistributorHome -{ -public: - /** - * Constructor. - * Register the necessary factories and mappings with the specified orb and - * Create a new instance of the StockDistributor object. - * - * @param orb - */ - Stock_StockDistributorHome_i (CORBA::ORB_ptr orb); - - /// Destructor - virtual ~Stock_StockDistributorHome_i (void); - - /** - * Return the StockDistributor object created by the Constructor. - * - * @return The StockDistributor object created by the Constructor. - */ - virtual ::Stock::StockDistributor_ptr create () - throw (::CORBA::SystemException); - -private: - /// The StockDistributor object created by its home. - Stock_StockDistributor_i *distributor_; -}; - -#endif /* DISTRIBUTORI_H_ */ diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/StockQuoter.mpc b/TAO/docs/tutorials/Quoter/RTCORBA/StockQuoter.mpc deleted file mode 100644 index 7f20a9b18d3..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/StockQuoter.mpc +++ /dev/null @@ -1,60 +0,0 @@ -// $Id$ - -// -*- MPC -*- -// $Id: StockQuoter.mpc -// $author: Shanshan Jiang <shanshan.jiang@vanderbilt.edu> -// Contains project definitions for the Publish/Subscribe Real-time CORBA -// Stock Quoter Service. - -project(*Admin): rt_client, stl { - libs += TAO_Valuetype - - Idl_Files { - } - - after = *Distributor *Broker - - Source_Files { - CommonC.cpp - DistributorC.cpp - Admin.cpp - } -} - -project(*Distributor): rt_server, stl { - libs += TAO_Valuetype - - Source_Files { - Common_i.cpp - Distributor.cpp - Distributor_i.cpp - Stock_Database.cpp - Stock_PriorityMapping.cpp - } - - Header_Files { - Common_i.h - Distributor_i.h - Stock_Database.h - Stock_PriorityMapping.h - } -} - -project(*Broker): rt_server, stl { - libs += TAO_Valuetype - - Source_Files { - Common_i.cpp - Broker.cpp - Broker_i.cpp - Stock_Database.cpp - Stock_PriorityMapping.cpp - } - - Header_Files { - Common_i.h - Broker_i.h - Stock_Database.h - Stock_PriorityMapping.h - } -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.cpp deleted file mode 100644 index a5b54378e49..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// $Id$ - -// ACE headers -#include <ace/OS_NS_unistd.h> - -// local headers -#include "Stock_Database.h" - -// -// Stock_Database -// -Stock_Database::Stock_Database (void) -{ - const char *stock_names [] = {"MSFT", "INTEL", "IBM"}; - - Stock::StockInfo_var stock_info; - - for (int i = 0; i < sizeof (stock_names) / sizeof (const char *); ++i) - { - stock_info = new Stock::StockInfo; - - stock_info->name = stock_names[i]; - stock_info->high = 70 + (ACE_OS::rand () % 30); - stock_info->last = 65 + (ACE_OS::rand () % 15); - stock_info->low = 60 + (ACE_OS::rand () % 20); - - this->stock_map_.insert (std::make_pair (std::string (stock_names[i]), stock_info)); - } -} - -// -// get_stock_info -// -Stock::StockInfo * Stock_Database::get_stock_info (const char *name) -{ - // Locate the <stock_name> in the database. - ACE_DEBUG ((LM_DEBUG, "*** message: searching the stock_map_ for the stock_name\n")); - StockMap::iterator iter = this->stock_map_.find (std::string (name)); - - if (iter == this->stock_map_.end()) - return 0; - - ACE_DEBUG ((LM_DEBUG, "*** message: returning stock_info to the client\n")); - - Stock::StockInfo_var stock_info = new Stock::StockInfo; - stock_info->name = std::string (iter->second->name).c_str (); - stock_info->high = iter->second->high; - stock_info->last = iter->second->last; - stock_info->low = iter->second->low; - - return stock_info._retn();; -} - -// -// publish_stock_info -// -void Stock_Database::publish_stock_info (Stock::StockNameConsumer_ptr consumer) -{ - Stock::StockName_var stock_name = new OBV_Stock::StockName; - - for (StockMap::iterator iter = this->stock_map_.begin (); - iter != this->stock_map_.end(); ++iter) - { - stock_name->name (iter->first.c_str()); - consumer->push_StockName (stock_name); - } -} - -int Stock_Database::svc (void) -{ - while (true) - { - for (Stock_Database::StockMap::iterator iter = this->stock_map_.begin (); - iter != this->stock_map_.end (); ++iter) - { - // Determine whether the stock has increased of decreased. - int mult = ACE_OS::rand (); - mult = mult % 2 == 0 ? 1 : -1; - - // Determine the amount of change of the stock. We will only permi - // a 5 point change at a time. - int delta = mult * (ACE_OS::rand () % 5); - - // Calculate the new values for the stock. - iter->second->last += delta; - if (iter->second->last < iter->second->low) - iter->second->low = iter->second->last; - else if (iter->second->last > iter->second->high) - iter->second->high = iter->second->last; - } - - // Sleep for one second. - ACE_OS::sleep (1); - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.h b/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.h deleted file mode 100644 index d952dfa4cde..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_Database.h +++ /dev/null @@ -1,65 +0,0 @@ -// $Id$ - -/** - * @file Stock_Database.h - * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> - */ - -#ifndef STOCK_DATABASE_H_ -#define STOCK_DATABASE_H_ - -// ACE headers -#include "ace/Task.h" - -// local headers -#include "Common_i.h" - -// STL headers -#include <map> - -/** - * @class Stock_Database - * @brief This class is used to install, update and publish the information of - * all the stocks. It uses the singleton design pattern. - */ -class Stock_Database: public ACE_Task_Base -{ -public: - /// Constructor. - Stock_Database (void); - - /// Destructor. - //Stock_Database (void); - - /** - * Create a StockInfo object stored in the database with the given name. - * - * @param name The name of the stock. - * @return A StockInfo object. - */ - Stock::StockInfo *get_stock_info (const char *name); - - /** - * This function is called by the Stock Distributor server's thread function - * to notify the Stock Broker client the state change of the stock it interested in. - * - * @param consumer The StockNameConsumer object reference. - */ - void publish_stock_info (Stock::StockNameConsumer_ptr consumer); - - /** - * This function is used to calculate the new high, low and last values - * for each stock in the stock database randomly. - */ - virtual int svc (void); - -private: - /// Stock map. - typedef std::map<std::string, Stock::StockInfo_var> StockMap; - StockMap stock_map_; -}; - -typedef ACE_Singleton<Stock_Database, ACE_Thread_Mutex> Stock_Database_Singleton; -#define STOCK_DATABASE Stock_Database_Singleton::instance() - -#endif // !defined STOCK_DATABASE_H_ diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.cpp deleted file mode 100644 index 023da22185a..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ - -// local headers -#include "Stock_PriorityMapping.h" - -// TAO headers -#include "tao/RTCORBA/Priority_Mapping_Manager.h" - -// -// Stock_PriorityMapping -// -Stock_PriorityMapping::Stock_PriorityMapping (void) - : TAO_Continuous_Priority_Mapping (5) -{ -} - -// -// ~Stock_PriorityMapping -// -Stock_PriorityMapping::~Stock_PriorityMapping (void) -{ -} - -// -// register_mapping -// -void Stock_PriorityMapping::register_mapping (CORBA::ORB_ptr orb) -{ - // Get the PriorityMappingManager. - CORBA::Object_var obj = orb->resolve_initial_references ("PriorityMappingManager"); - TAO_Priority_Mapping_Manager_var manager = TAO_Priority_Mapping_Manager::_narrow (obj); - - // Create an instance of my mapping and install it. - RTCORBA::PriorityMapping *my_mapping = new Stock_PriorityMapping; - manager->mapping (my_mapping); -} diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.h b/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.h deleted file mode 100644 index 7e5ee7b8bd1..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/Stock_PriorityMapping.h +++ /dev/null @@ -1,48 +0,0 @@ -// $Id$ - -/** - * @file Stock_PriorityMapping.h - * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> - */ - -#ifndef STOCK_PRIORITYMAPPING_ -#define STOCK_PRIORITYMAPPING_ - -// TAO headers -#include "tao/RTCORBA/Continuous_Priority_Mapping.h" - -/** - * @class Stock_PriorityMapping - * @brief Defines the runtime priority mappings used in this application. - * - * This class defines the priority mappings used by the stock objects. We - * are using the TAO_Continuous_Priority_Mapping class as a base class - * because it provides the necessary mappings of CORBA::Priority values - * to CORBA::NativePriority values when there is only a limited number - * of CORBA::Priority values. - */ -class Stock_PriorityMapping : - public TAO_Continuous_Priority_Mapping -{ -public: - /// Default constructor. - Stock_PriorityMapping (void); - - /// Default destructor. - virtual ~Stock_PriorityMapping (void); - - /// Stock priorities. - enum Priority - { - VERY_LOW = 0, - LOW = 1, - MEDIUM = 2, - HIGH = 3, - VERY_HIGH = 4 - }; - - /// Register mapping. - static void register_mapping (CORBA::ORB_ptr orb); -}; - -#endif // !defined STOCK_PRIORITYMAPPING_ diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/broker.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/broker.html deleted file mode 100644 index dc7e11fc538..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/broker.html +++ /dev/null @@ -1,150 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Stock Broker implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Stock Broker implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<h3>Implementation of StockBrokerHome interface</h3> - -This interface is used to create StockBroker objects. <P> -The Stock_StockBrokerHome_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockBrokerHome class. <P> - -<h4>Implementing the Constructor</h4> - -The main steps of this function are described as follows: <P> - -<li>Register the necessary factories and mappings with the specified orb.</li> - -<PRE> - Stock::StockName_init *stockname_factory = new Stock::StockName_init; - orb->register_value_factory (stockname_factory->tao_repository_id (), - stockname_factory - ACE_ENV_ARG_PARAMETER); - - Stock::Cookie_init *cookie_factory = new Stock::Cookie_init; - orb->register_value_factory (cookie_factory->tao_repository_id (), - cookie_factory - ACE_ENV_ARG_PARAMETER); - - Stock_PriorityMapping::register_mapping (orb); -</PRE> - -<li>Create a new instance of the StockBroker object. And because the broker has nothing to do with the RTCORBA -mechanisms, we can activate it under the default POA. The "stock_name" and "priority" are in the arguments of -the Constructor.</li> - -<PRE> - broker_ = new Stock_StockBroker_i (orb, stock_name, priority); - PortableServer::ServantBase_var broker_owner_transfer = broker_; - _default_POA ()->activate_object (broker_); -</PRE> - -<h4>Implementing the create () member function</h4> - -Return the StockBroker object created by the Constructor. - -<PRE> - return Stock::StockBroker::_duplicate (broker_->_this ()); -</PRE> - -<hr><h3>Implementation of StockBroker interface</h3> - -This interface is used for Stock Broker client. <P> -The Stock_StockBroker_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockBroker class. <P> - -<h4>Implementing the Constructor</h4> - -<PRE> - Stock_StockBroker_i (CORBA::ORB_ptr orb, const char *stock_name, RTCORBA::Priority priority) - : quoter_ (Stock::StockQuoter::_nil()), consumer_ (0) -</PRE> - -The "quoter_" and "consumer_" are two private members of the Stock_StockBroker_i class. They stand -for the StockQuoter object that is used to get detailed stock information and the StockNameConsumer -object that is used to get notification of updates. <P> - -The main steps of this function are described as follows: <P> - -<li>Get a reference to the RTORB.</li> - -<li>Initialize a CORBA::PolicyList object.</li> - -<li>Create a SERVER_DECLARED priority model policy and add it into the former CORBA::PolicyList object.</li> - -<li>Create a child POA using the former CORBA::PolicyList and narrow it to RTPOA.</li> - -<li>Create a new instance of the StockNameConsumer object with the specified name and activate it -under the former RTPOA with the specified priority.</li> - -<PRE> - CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); - RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ()); - - CORBA::PolicyList consumer_policies (1); - consumer_policies.length (1); - - consumer_policies[0] = rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED, - Stock_PriorityMapping::MEDIUM); - - PortableServer::POA_var poa = this->_default_POA()->create_POA ( - "StockNameConsumer_POA", PortableServer::POAManager::_nil (), consumer_policies); - - RTPortableServer::POA_var rt_poa = RTPortableServer::POA::_narrow (poa); - - consumer_ = new Stock_StockNameConsumer_i (_this (), stock_name); - PortableServer::ServantBase_var nameconsumer_owner_transfer = consumer_; - rt_poa->activate_object_with_priority (consumer_, priority); -</PRE> - -<h4>Implementing the get_consumer_notifier () member function</h4> - -Return the StockNameConsumer object created by the Constructor. - -<PRE> - return Stock::StockNameConsumer::_duplicate (consumer_->_this ()); -</PRE> - -<h4>Implementing the connect_quoter_info () member function</h4> - -Duplicate a StockQuoter object using the StockQuoter object reference "c" in the argument. - -<PRE> - quoter_ = Stock::StockQuoter::_duplicate (c); -</PRE> - -<h4>Implementing the disconnect_quoter_info () member function</h4> - -Destroy the StockQuoter object and return it. - -<PRE> - Stock::StockQuoter_var old_quoter = quoter_; - quoter_ = Stock::StockQuoter::_nil(); - return old_quoter._retn (); -</PRE> - -<h4>Implementing the get_connection_quoter_info () member function</h4> - -Return the StockQuoter object. - -<PRE> - return Stock::StockQuoter::_duplicate (quoter_); -</PRE> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/common.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/common.html deleted file mode 100644 index d6731600142..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/common.html +++ /dev/null @@ -1,76 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Common implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Common implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<h3>Implementation of StockNameConsumer interface</h3> - -This interface is used as a callback interface used by the Stock Distributor server to -notify Stock Broker clients of updates. <P> -The Stock_StockNameConsumer_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockNameConsumer class. <P> - -<h4>Implementing the Constructor</h4> - -<PRE> - Stock_StockNameConsumer_i (Stock::StockBroker_ptr parent, const char *stock_name) - : parent_ (Stock::StockBroker::_duplicate (parent)), - stock_name_ (CORBA::string_dup (stock_name)) -</PRE> - -The "parent_" and "stock_name_" are two private members of the Stock_StockNameConsumer_i class. They stand for the -parent broker of the StockNameConsumer object and the name of the stock to listen to respectively. <P> - -<h4>Implementing the push_StockName () member function</h4> - -The main steps of this function are described as follows: <P> - -<li>Verify the "parent_" private member is valid.</li> <P> - -<li>Verify this is the correct stock: Check if the StockName parameter in this function is equal to -the "stock_name_" private member. If this is not the stock that we are interested in then we need to stop -and return.</li> <P> - -<li>Get the quoter for the connection.</li> - -<PRE> - Stock::StockQuoter_var quoter = parent_->get_connection_quoter_info (); -</PRE> - -<li>Request more information from the quoter.</li> - -<PRE> - Stock::StockInfo_var stock_info = quoter->get_stock_info (the_stockname->name()); -</PRE> - -<hr><h3>Implementation of StockQuoter interface</h3> - -This interface is used by brokers to get detailed stock information. <P> -The Stock_StockQuoter_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockQuoter class. <P> - -<h4>Implementing the get_stock_info () member function</h4> - -<PRE> - Stock::StockInfo *stock = STOCK_DATABASE->get_stock_info (stock_name); -</PRE> - -Call the get_stock_info () function of Stock_Database instance. - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/database.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/database.html deleted file mode 100644 index a8727566a9b..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/database.html +++ /dev/null @@ -1,68 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Stock Database definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Stock Database definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> The Stock Database class is used to install, update and publish the information of all the stocks. It uses the -singleton design pattern.<P> - -<PRE> - typedef ACE_Singleton<Stock_Database, ACE_Thread_Mutex> Stock_Database_Singleton; - #define STOCK_DATABASE Stock_Database_Singleton::instance() -</PRE> - -ACE_Singleton simply ensures that we create one single instance of the Stock_Database class at runtime, -even if multiple threads all try to create one at the same time. - -<h3>Implementing the Constructor</h3> - -The main steps of this function are described as follows: <P> - -<li>Create an array of stock names.</li> <P> - -<li>Create a StockInfo object for each stock with the corresponding stock name and initialize -its high, low and last values randomly.</li> <P> - -<li>Insert the StockInfo objects into stock map, using the stock name as the key.</li> <P> - -<hr><h3>Implementing the get_stock_info () function</h3> - -The main steps of this function are described as follows: <P> - -<li>Locate the stock in the stock database with the same stock name given in the argument.</li> <P> - -<li>Create a StockInfo object of the former stock and return it.</li> <P> - -<hr><h3>Implementing the publish_stock_info () function</h3> - -This function is called by the Stock Distributor server's thread function to notify the Stock Broker client -the state change of the stock it interested in. <P> -For each stock in the stock database, do the following steps: <P> - -<li>Initialze the StockName object with the name of the stock.</li> <P> - -<li>Call the push_StockName () function of StockNameConsumer object (given in the argument), -using the former StockName object.</li> <P> - -<hr><h3>Implementing the svc () function</h3> - -This function will be run when the stock database is started. This function is used to -calculate the new high, low and last values of each stock in the stock database. <P> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/distributor.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/distributor.html deleted file mode 100644 index 510f7403f84..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/distributor.html +++ /dev/null @@ -1,186 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Stock Distributor implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Stock Distributor implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<h3>Implementation of StockDistributorHome interface</h3> - -This interface is used to create StockDistributor objects. <P> -The Stock_StockDistributorHome_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockDistributorHome class. <P> - -<h4>Implementing the Constructor</h4> - -The main steps of this function are described as follows: <P> - -<li>Register the necessary factories and mappings with the specified orb.</li> - -<PRE> - Stock::StockName_init *stockname_factory = new Stock::StockName_init; - orb->register_value_factory (stockname_factory->tao_repository_id (), - stockname_factory - ACE_ENV_ARG_PARAMETER); - - Stock::Cookie_init *cookie_factory = new Stock::Cookie_init; - orb->register_value_factory (cookie_factory->tao_repository_id (), - cookie_factory - ACE_ENV_ARG_PARAMETER); - - Stock_PriorityMapping::register_mapping (orb); -</PRE> - -<li>Initialize the Stock database.</li> - -<PRE> - STOCK_DATABASE->activate (THR_NEW_LWP | THR_JOINABLE, 1); -</PRE> - -<li>Create a CORBA::PolicyList for the child POA.</li> - -This step include several sub-stpes: -<OL> -<li> Get a reference to the RTORB.</li> -<li> Initialize a CORBA::PolicyList object.</li> -<li> Create a CLIENT_PROPOGATED priority model policy and add it into the former CORBA::PolicyList object.</li> -<li> Create a threadpool with lanes for the distributor. Since the brokers have various priorities, -create a lane for each priority.</li> -<li> Create a thread pool policy using the former threadpool and add it into the former CORBA::PolicyList object.</li> -<li> Create a child POA using the former CORBA::PolicyList and narrow it to RTPOA.</li> -</OL> - -<PRE> - CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); - RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ()); - - CORBA::PolicyList stock_distributor_policies (2); - stock_distributor_policies.length (2); - - stock_distributor_policies[0] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, - Stock_PriorityMapping::MEDIUM); - - RTCORBA::ThreadpoolLanes lanes (5); - lanes.length (5); - for (CORBA::ULong i = 0; i < lanes.length (); i ++) - { - lanes[i].lane_priority = i; - lanes[i].static_threads = 5; - lanes[i].dynamic_threads = 2; - } - RTCORBA::ThreadpoolId threadpool_id = rt_orb->create_threadpool_with_lanes (1024 * 10, lanes, false, false, 0, 0); - stock_distributor_policies[1] = rt_orb->create_threadpool_policy (threadpool_id); - - PortableServer::POA_var poa = _default_POA()->create_POA ("StockDistributor_POA", - PortableServer::POAManager::_nil (), - stock_distributor_policies); - - RTPortableServer::POA_var rt_poa = RTPortableServer::POA::_narrow (poa); -</PRE> - -<li>Create a new instance of the StockDistributor object using the former CORBA::PolicyList. -Then activate it under the former RTPOA. </li> - -<PRE> - distributor_ = new Stock_StockDistributor_i (orb, stock_distributor_policies); - PortableServer::ServantBase_var distributor_owner_transfer = distributor_; - rt_poa->activate_object (distributor_); -</PRE> - -<h4>Implementing the create () member function</h4> - -Return the StockDistributor object created by the Constructor. - -<PRE> - return Stock::StockDistributor::_duplicate (distributor_->_this ()); -</PRE> - -<hr><h3>Implementation of StockDistributor interface</h3> - -This interface is used for Stock Distributor server. <P> -The Stock_StockDistributor_i class is generated automatically by the IDL compiler (using the -GI flag), -which is a subclass of POA_Stock::StockDistributor class. <P> - -<h4>Implementing the Constructor</h4> - -<PRE> - Stock_StockDistributor_i (CORBA::ORB_ptr orb, CORBA::PolicyList &policy_list) - : rate_(3000), active_ (false), quoter_ (0) -</PRE> - -The "rate_", "active_" and "quoter_" are three private members of the Stock_StockDistributor_i class. They stand -for the notification rate and the active state of the StockDistributor object and the StockQuoter object created by -the StockDistributor object. <P> - -The main steps of this function are described as follows: <P> - -<li>Create a child POA with the policies in the argument and narrow it to RTPOA.</li> <P> - -<li>Create a new instance of the StockQuoter object and activate it under the former RTPOA.</li> <P> - -<li>Seed the random number generator.</li> <P> - -<h4>Implementing the subscribe_notifier () member function</h4> - -The main steps of this function are described as follows: <P> - -<li>Get the thread mutex of the subscriber map.</li> <P> - -<li>Generate an unique id and use it to create a new Cookie object.</li> <P> - -<li>Insert the Cookie object as well as the StockNameConsumer object and its priority into the -StockDistributor object's subscriber map.</li> <P> - -<li>Return the Cookie object.</li> <P> - -<h4>Implementing the unsubscribe_notifier () member function</h4> - -The main steps of this function are described as follows: <P> - -<li>Get the thread mutex of the subscriber map.</li> <P> - -<li>Search for the Cookie object in the argument in the StockDistributor object's subscriber map.</li> <P> - -<li>Erase the Cookie object from the StockDistributor object's subscribers' map.</li> <P> - -<li>Return the StockNameConsumer object related to the erased Cookie object.</li> <P> - -<h4>Implementing the provide_quoter_info () member function</h4> - -Return the StockQuoter object created by the Constructor. - -<PRE> - return Stock::StockQuoter::_duplicate (quoter_->_this ()); -</PRE> - -<h4>Implementing the start () member function</h4> - -Set the active state of the StockDistributor object to true and create a thread to publish the stock information -to the Stock Broker clients. <P> - -The main steps of this thread function are described as follows: <P> -While the state of the StockDistributor object is active, continue the following looping: -<OL> -<li> Publish the stock information to all the StockNameConsumer objects.</li> -<li> Sleep for the specified amount of seconds given in the notification rate.</li> -</OL> - -<h4>Implementing the stop () member function</h4> - -Set the active state of StockDistributor object to false. - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/idl.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/idl.html deleted file mode 100644 index d4ec3788432..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/idl.html +++ /dev/null @@ -1,216 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>IDL Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>IDL Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> Note: All the IDL definitions are included in the Stock module: -<PRE> -// IDL schema definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service. -module Stock -{ - ... -}; -</PRE> - -<h3>Common</h3> - -This IDL file (Common.idl) contains all the exception(s), struct(s), value type(s) and -common interface(s) used by the Stock Quoter Publisher/Subscriber Real-time CORBA Service. The -generated lib of this idl file will be linked by all the other projects in the system. <P> - -<li><h4>Defining the IDL exception</h4></li> - -<PRE> -exception Invalid_Stock {}; -</PRE> - -This exception is used when the needed stock does not exist in the stock database. <P> - -<li><h4>Defining the IDL struct</h4></li> - -<PRE> -struct StockInfo -{ - string name; - long high; - long low; - long last; -}; -</PRE> - -This struct contains the information about a stock. The items in this struct denote the -name, highest value, lowest value and last value of the stock respectively. <P> - -<li><h4>Defining the IDL value types</h4></li> - -Unlike CORBA Objects (which are passed by reference), instances of CORBA valuetype are -always passed by value. Like CORBA structs, they can contain state in the form of fields. -Unlike structs, however, they can have user-defined operations and support inheritance. <P> - -<PRE> -valuetype StockName -{ - // Name of the stock. - public string name; -}; -</PRE> - -This value type is used in the communication between stock distributor server and stock -broker client to handle the callback from distributor server whenever the value of a stock -the stock broker client interested in changes. <P> - -<PRE> -valuetype Cookie -{ - public string cookie_id; -}; -</PRE> - -This value type is used to record the subscription relationship between stock distributor -server and stock broker client. It can also be used to unsubscribe the stock broker clien -from the stock distributor server. <P> - -<li><h4>Defining the common IDL interfaces</h4></li> - -<PRE> -interface Trigger -{ - void start (); - void stop (); -} -</PRE> - -This interface is inherited by the stock distributor interface because it need to be run as -a daemon that can be started and stopped by a system administrator. <P> - -<PRE> -interface StockNameConsumer -{ - // Push an event to the consumer. - void push_StockName (in StockName the_stockname); -}; -</PRE> - -This interface is used as a callback interface used by the distributor to notify brokers of updates. <P> - -<PRE> -interface StockQuoter -{ - StockInfo get_stock_info (in string stock_name) raises Invalid_Stock; -}; -</PRE> - -This interface is used by brokers to get detailed stock information. <P> - -<hr><h3>Broker</h3> - -This IDL file (Broker.idl) contains IDL definitions for the Stock Broker in the -Publish/Subscribe Real-time CORBA Stock Quoter Service. <P> - -<li><h4>Defining the IDL interfaces</h4></li> - -<PRE> -interface StockBroker -{ - // Factory operation to return StockNameConsumer object reference. - StockNameConsumer get_consumer_notifier (); - - // Event sink operations to perform connectivity. - void connect_quoter_info (in StockQuoter c); - StockQuoter disconnect_quoter_info (); - StockQuoter get_connection_quoter_info (); -}; -</PRE> - -This is the interface definition for Stock Broker client. <P> -The get_consumer_notifier() operation returns an object reference to the StockNameConsumer interface -shown earlier. When the stock quoter system is initialized, this factory operation will be used to -return the StockNameConsumer object that belongs to the Stock Broker object. <P> -These connect_quoter_info(), disconnect_quoter_info(), and get_connection_quoter_info() operations -are used to connect the StockBroker with the StockQuoter object that's provided by the StockDistributor -interface describe next. <P> - -<PRE> -interface StockBrokerHome -{ - StockBroker create (); -}; -</PRE> - -This is the interface definition for Stock Broker Home. -This factory reduces the bookkeeping that CORBA applications must do to create and manage their objects. <P> - -<hr><h3>Distributor</h3> - -This IDL file (Distributor.idl) contains IDL definitions for the Stock Distributor in the -Publish/Subscribe Real-time CORBA Stock Quoter Service. <P> - -<li><h4>Defining the IDL interfaces</h4></li> - -<PRE> -interface StockDistributor : Trigger -{ - // Event source operations to establish connectivity. - Cookie subscribe_notifier (in Stock::StockNameConsumer c); - Stock::StockNameConsumer unsubscribe_notifier (in Cookie ck); - - // Factory operation to return StockQuoter object reference. - StockQuoter provide_quoter_info (); - - attribute long notification_rate; -}; -</PRE> - -This is the interface definition for Stock Distributor server. <P> -The subscribe_notifier() and unsubscribe_notifier() operations are to subscribe/unsubscribe StockBroker -objects that consume the StockName events published by the StockDistributor. <P> -The provide_quoter_info() factory operation returns object references that StockBroker consumers can -use to obtain more information about a particular stock. <P> -The notification_rate attribute stands for the notification frequency that the Stock Distributor server used -to communicate with the Stock Broker client. <P> - -<PRE> -interface StockBrokerHome -{ - StockBroker create (); -}; -</PRE> - -This is the interface definition for Stock Distributor Home. -This factory reduces the bookkeeping that CORBA applications must do to create and manage their objects. <P> - -<hr><h3>Compiling the IDL files and generating the stub, skeleton and implementation files</h3> - -To generate the helper files you need to invoke the IDL compiler, like this: <P> - -<PRE> -tao_idl Common.idl -tao_idl -GI Broker.idl -tao_idl -GI Distributor.idl -</PRE> - -The "-GI" flag is used to generate the frames for the implmentation files (*I.h and *I.cpp). You can -change the names of the files into *_i.h and *_i.cpp because the next time you run the IDL compiler, -these implemention files (*I.h and *I.cpp) will be overwritten by the newly generated implemention files -(with the same file names). <P> - -However, you don't need to do this often, in fact you rarely have to do it at all because this can be handled -by <A HREF="mpc.html">writing and using a mpc file</A>. <P> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/index.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/index.html deleted file mode 100644 index 54c74b9744c..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/index.html +++ /dev/null @@ -1,50 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> This tutorial introduces how to implement a Stock Quoter Publisher/Subscriber Real-time CORBA Service. <P> - -<OL> -<LI><A HREF="idl.html"> -IDL Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="mpc.html"> -MPC Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="run.html"> -Execution programs for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="database.html"> -Stock Database definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="prioritymapping.html"> -Stock Priority Mapping definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="common.html"> -Common implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="broker.html"> -Stock Broker implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> - -<LI><A HREF="distributor.html"> -Stock Distributor implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</A> -</OL> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/mpc.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/mpc.html deleted file mode 100644 index 1ab5e2fd99e..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/mpc.html +++ /dev/null @@ -1,104 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>MPC Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>MPC Definitions for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> Note: For more information about how to writing and using a mpc file, please refer to -<A HREF="http://download.ociweb.com/MPC/MakeProjectCreator.pdf">here</A>. <P> - -This MPC file (StockQuoter.mpc) contains all the projects used by the Stock Quoter Publisher/Subscriber -Real-time CORBA Service. <P> - -<li><h4>Defining the Distributor project</h4></li> - -<PRE> -project(*Distributor): rt_server, stl { - libs += TAO_Valuetype - - Source_Files { - Common_i.cpp - Distributor.cpp - Distributor_i.cpp - Stock_Database.cpp - Stock_PriorityMapping.cpp - } - - Header_Files { - Common_i.h - Distributor_i.h - Stock_Database.h - Stock_PriorityMapping.h - } -} -</PRE> - -This project is used as a Stock Distributor server which monitors a real-time stock feed database -and whenever the value of a stock changes, it publishes an event to interested stock brokers. It can -alse provide the detailed information about a stock required by a Stock Broker client.<P> - -<li><h4>Defining the Broker project</h4></li> - -<PRE> -project(*Broker): rt_server, stl { - libs += TAO_Valuetype - - Source_Files { - Common_i.cpp - Broker.cpp - Broker_i.cpp - Stock_Database.cpp - Stock_PriorityMapping.cpp - } - - Header_Files { - Common_i.h - Broker_i.h - Stock_Database.h - Stock_PriorityMapping.h - } -} -</PRE> - -This project is used as a Stock Broker client which subscribes with a Stock Distributor server -to receive notification events whenever a stock value of interest to them changes. It can -alse receive the detailed information about a stock by invoke a Stock Distributor server.<P> - -<li><h4>Defining the Admin project</h4></li> - -<PRE> -project(*Admin): rt_client, stl { - libs += TAO_Valuetype - - Idl_Files { - } - - after = *Distributor *Broker - - Source_Files { - CommonC.cpp - DistributorC.cpp - Admin.cpp - } -} -</PRE> - -This project is used as a system administrator to start, stop the Stock Distributor server -and change the notification rate of it. <P> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/prioritymapping.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/prioritymapping.html deleted file mode 100644 index b43a556f2ca..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/prioritymapping.html +++ /dev/null @@ -1,57 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Stock Priority Mapping definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Stock Priority Mapping definition for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> The Stock Database class defines the priority mappings used by the stock objects.<P> - -<h3>Defining the Priority enum</h3> - -We define five levels of prioriies as follows: <P> - -<PRE> - enum Priority - { - VERY_LOW = 0, - LOW = 1, - MEDIUM = 2, - HIGH = 3, - VERY_HIGH = 4 - }; -</PRE> - -<hr><h3>Implementing the register_mapping () function</h3> - -The main steps of this function are described as follows: <P> - -<li>Get the Priority Mapping Manager.</li> <P> - -<PRE> - CORBA::Object_var obj = orb->resolve_initial_references ("PriorityMappingManager"); - TAO_Priority_Mapping_Manager_var manager = TAO_Priority_Mapping_Manager::_narrow (obj); -</PRE> - -<li>Create an instance of Stock Priority Mapping object and install it.</li> <P> - -<PRE> - RTCORBA::PriorityMapping *my_mapping = new Stock_PriorityMapping; - manager->mapping (my_mapping); -</PRE> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/docs/run.html b/TAO/docs/tutorials/Quoter/RTCORBA/docs/run.html deleted file mode 100644 index 42b11f9adb4..00000000000 --- a/TAO/docs/tutorials/Quoter/RTCORBA/docs/run.html +++ /dev/null @@ -1,117 +0,0 @@ -<!-- $Id$ --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Execution programs for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title> -</head> - -<body - text = "#000000" - link = "#000fff" - vLink= "#ff0f0f" - aLink = "#0000ff" - bgColor = "#ffffff"> - -<hr><h2>Execution programs for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr> - -<P> There are three execution programs (*.cpp files that have the main () functions) in this system: -Distributor, Broker and Admin. Each of them belongs to the corresponding project defined in the -StockQuoter.mpc file. <P> - -<h3>Building the Distributor program</h3> - -The Distributor.cpp file is used for this purpose. It contains the main () function and is used to generated the -Distributor execution file. The main steps in this file are described as follows: <P> - -<li>Initalize the ORB.</li> <P> - -<li>Get the RootPOA.</li> <P> - -<li>Activate the POAManager.</li> <P> - -<li>Create a Distributor factory object, which will then create a Distributor object.</li> -<PRE> - Stock_StockDistributorHome_i stock_distributor_home (orb); - Stock::StockDistributor_var stock_distributor = stock_distributor_home.create (); -</PRE> - -<li>Write the object reference for the Distributor object to a file so other projects -can read it when they are bootstrapping.</li> <P> - -<li>Set the rate of the Distributor object.</li> <P> - -<li>Enter into the event looping.</li> <P> - -<hr><h3>Building the Broker program</h3> - -The Broker.cpp file is used for this purpose. It contains the main () function and is used to generated the -Broker execution file. The main steps in this file are described as follows: <P> - -<li>Initalize the ORB.</li> <P> - -<li>Get the RootPOA.</li> <P> - -<li>Activate the POAManager.</li> <P> - -<li>Extract the command-line arguments, which give the stock name and the priority of the Broker objec -(actually, the priority of the StockNameConsumer object that the Broker object contains).</li> <P> - -<li>Create a Broker factory object, which will then create a Broker object.</li> -<PRE> - Stock_StockBrokerHome_i stock_broker_home (orb, stock_name, priority); - Stock::StockBroker_var stock_broker = stock_broker_home.create (); -</PRE> - -<li>Read and destringify the Distributor object's IOR and narrow it to a Distributor object reference.</li> <P> - -<li>Connect the Quoter object to the Broker object.</li> -<PRE> - Stock::StockQuoter_var stock_quoter = stock_distributor->provide_quoter_info (); - stock_broker->connect_quoter_info (stock_quoter); -</PRE> - -<li>Create a new consumer; initialize it; subscribe it to the notification service.</li> -<PRE> - Stock::StockNameConsumer_var consumer = stock_broker->get_consumer_notifier (); - Stock::Cookie *cookie = stock_distributor->subscribe_notifier (consumer, priority); -</PRE> - -<li>Enter into the event looping.</li> <P> - -<hr><h3>Building the Admin program</h3> - -The Admin.cpp file is used for this purpose. It contains the main () function and is used to generated -Admin execution file. The main steps in this file are described as follows: <P> - -<li>Initalize the ORB.</li> <P> - -<li>Read and destringify the Distributor object's IOR and narrow it to a Distributor object reference.</li> <P> - -<li>Call the operations of StockDistributor interface:</li> -<PRE> - start: Start the distributor. - stop: Stop the distributor. - rate: Change the notification rate of the distributor. -</PRE> - -<hr><h3>Running the Stock Quoter Service</h3> - -When executing the programs, they should be executed in the following order: - -<PRE> - Distributor - Broker - Admin -</PRE> - -You can run more than one Broker program at the same time. Each of them should be given different stock name -that it is interested in. All the stock information is installed in the <A HREF="database.html">Stock Database</A>. -The number of stocks can easily be extended by adding items to the stock_names array of -the Stock Database constuctor. <P> - -<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS> - -</body> - -</html> diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Makefile.am b/TAO/docs/tutorials/Quoter/RT_Event_Service/Makefile.am deleted file mode 100644 index 5fcd5c51cc1..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Makefile.am +++ /dev/null @@ -1,145 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_RT_Event_Service_Idl.am - -BUILT_SOURCES = \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -CLEANFILES = \ - Quoter-stamp \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl - -QuoterC.cpp QuoterC.h QuoterC.inl QuoterS.cpp QuoterS.h QuoterS.inl: Quoter-stamp - -Quoter-stamp: $(srcdir)/Quoter.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) $(srcdir)/Quoter.idl - @touch $@ - - -noinst_HEADERS = \ - Quoter.idl - -## Makefile.Quoter_RT_Event_Service_Client.am - -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS -if !BUILD_ACE_FOR_TAO -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -client_SOURCES = \ - QuoterC.cpp \ - Stock_Consumer.cpp \ - client.cpp \ - Stock_Consumer.h - -client_LDADD = \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent_Serv.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent_Skel.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif !BUILD_ACE_FOR_TAO -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING - -## Makefile.Quoter_RT_Event_Service_Server.am - -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS -if !BUILD_ACE_FOR_TAO -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -server_SOURCES = \ - QuoterC.cpp \ - QuoterS.cpp \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent_Serv.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent_Skel.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif !BUILD_ACE_FOR_TAO -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter.idl b/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter.idl deleted file mode 100644 index 34d81177658..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter.idl +++ /dev/null @@ -1,54 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; - - struct Event { - double price; - string symbol; - string full_name; - }; - - interface Modify_Stock : Stock { - void set_price (in double new_price); - }; -}; diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter_RT_Event_Service.mpc b/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter_RT_Event_Service.mpc deleted file mode 100644 index 15cb6b2be5b..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Quoter_RT_Event_Service.mpc +++ /dev/null @@ -1,33 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*idl): taoidldefaults, anytypecode { - IDL_Files { - Quoter.idl - } - custom_only = 1 -} - -project(*client) : orbsvcsexe, portableserver, rtevent_serv, naming, minimum_corba, exceptions { - after += *idl - source_files { - client.cpp - Stock_Consumer.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*server) : orbsvcsexe, portableserver, rtevent_serv, naming, minimum_corba, exceptions { - after += *idl - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp deleted file mode 100644 index 395e31bf6b0..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Consumer.h" -#include "QuoterC.h" -#include "ace/streams.h" - -Stock_Consumer::Stock_Consumer () -{ -} - -void -Stock_Consumer::connect (RtecEventChannelAdmin::EventChannel_ptr event_channel, - const RtecEventChannelAdmin::ConsumerQOS &subscriptions) -{ - RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = - event_channel->for_consumers (); - - this->supplier_proxy_ = - consumer_admin->obtain_push_supplier (); - - RtecEventComm::PushConsumer_var myself = this->_this (); - this->supplier_proxy_->connect_push_consumer (myself.in (), - subscriptions); -} - -void -Stock_Consumer::disconnect () -{ - // Do not receive any more events... - this->supplier_proxy_->disconnect_push_supplier (); -} - -void -Stock_Consumer::push (const RtecEventComm::EventSet &data - ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - for (CORBA::ULong i = 0; i != data.length (); ++i) { - const RtecEventComm::Event &e = data[i]; - - Quoter::Event *event; - if ((e.data.any_value >>= event) == 0) - continue; // Invalid event - - cout << "The new price for one stock in \"" - << event->full_name.in () - << "\" (" << event->symbol.in () - << ") is " << event->price << endl; - } -} - -void -Stock_Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - this->supplier_proxy_ = - RtecEventChannelAdmin::ProxyPushSupplier::_nil (); -} diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.h b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.h deleted file mode 100644 index a82044836bc..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIALS_QUOTER_RT_EVENT_SERVICE_STOCK_CONSUMER_H -#define TAO_TUTORIALS_QUOTER_RT_EVENT_SERVICE_STOCK_CONSUMER_H - -#include <orbsvcs/RtecEventCommS.h> -#include <orbsvcs/RtecEventChannelAdminC.h> - -class Stock_Consumer : public POA_RtecEventComm::PushConsumer { -public: - Stock_Consumer (); - - void connect (RtecEventChannelAdmin::EventChannel_ptr event_channel, - const RtecEventChannelAdmin::ConsumerQOS &subscriptions); - // Connect to the event channel, using <consumer_admin> and - // <subscriptions> - - void disconnect (); - // Disconnect from the event channel. - - void push (const RtecEventComm::EventSet& data ACE_ENV_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - -private: - RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_; - // The supplier proxy. -}; - -#endif /* TAO_TUTORIALS_QUOTER_RT_EVENT_SERVICE_STOCK_CONSUMER_H */ diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.cpp deleted file mode 100644 index 206338a5159..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "Stock_i.h" -#include "ace/streams.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - try { - CORBA::Object_var tmp = - this->stock_factory_poa_->id_to_reference (oid.in ()); - return Quoter::Stock::_narrow (tmp.in ()); - } - catch (PortableServer::POA::ObjectNotActive &) { - throw Quoter::Invalid_Stock_Symbol (); - } -} - -void -Quoter_Stock_Factory_i::destroy_stock_objects () -{ - if (!CORBA::is_nil (this->stock_factory_poa_.in ())) - return; - - this->stock_factory_poa_->destroy (1, 1); - this->stock_factory_poa_ = PortableServer::POA::_nil (); -} - -void -Quoter_Stock_Factory_i::load_stock_objects ( - PortableServer::POA_ptr poa, - PortableServer::POAManager_ptr poa_manager, - RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin) -{ - if (!CORBA::is_nil (this->stock_factory_poa_.in ())) - return; - - CORBA::PolicyList policies (2); - policies.length (2); - - policies[0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - policies[1] = - poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION); - - this->stock_factory_poa_ = - poa->create_POA ("Stock_Factory_POA", - poa_manager, - policies); - - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - while (!cin.eof () && cin.peek () != EOF) { - const int max_symbol_length = 8; - char symbol[max_symbol_length]; - const int max_full_name_length = 64; - char full_name[max_full_name_length]; - double price; - - cin.getline (symbol, max_symbol_length, '\n'); - cin.getline (full_name, max_full_name_length, '\n'); - cin >> price; - cin.ignore (1, '\n'); - - Quoter_Stock_i *stock = - new Quoter_Stock_i (symbol, full_name, price); - - PortableServer::ServantBase_var servant = stock; - - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - this->stock_factory_poa_->activate_object_with_id (oid.in (), - servant.in ()); - stock->connect (supplier_admin); - } -} diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.h deleted file mode 100644 index c30c68e2a69..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Factory_i.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_FACTORY_I_H - -#include "QuoterS.h" -#include <orbsvcs/RtecEventChannelAdminS.h> - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - void load_stock_objects (PortableServer::POA_ptr poa, - PortableServer::POAManager_ptr poa_manager, - RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin); - void destroy_stock_objects (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - PortableServer::POA_var stock_factory_poa_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_FACTORY_I_H */ diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.cpp b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.cpp deleted file mode 100644 index a042bbcb1ac..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// $Id$ - -#include "Stock_i.h" -#include <orbsvcs/Event_Utilities.h> - -///derive a class from the tie template class to release itself by ref_count -class MyTieStock:public POA_RtecEventComm::PushSupplier_tie<Quoter_Stock_i> -{ - friend class Quoter_Stock_i; - ACE_Atomic_Op<TAO_SYNCH_MUTEX, long> ref_count_; - -protected: - MyTieStock (Quoter_Stock_i *tp, - CORBA::Boolean release) - : POA_RtecEventComm::PushSupplier_tie<Quoter_Stock_i> (tp,release), - ref_count_(0) {} - -public: - virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL) - { - ++this->ref_count_; - } - - virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL) - { - CORBA::ULong new_count = --this->ref_count_; - - if (new_count == 0) - delete this; - } -}; - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : supplier_personality_ (*new MyTieStock (this, 0)) -{ - this->data_.symbol = symbol; - this->data_.full_name = full_name; - this->data_.price = price; -} - -Quoter_Stock_i::~Quoter_Stock_i (void) -{ - if (consumer_proxy_.in ()) - consumer_proxy_->disconnect_push_consumer (); -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->data_.symbol.in ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->data_.full_name.in ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->data_.price; -} - -void -Quoter_Stock_i::set_price (CORBA::Double new_price) - throw (CORBA::SystemException) -{ - this->data_.price = new_price; - if (CORBA::is_nil (this->consumer_proxy_.in ())) - return; - - // Create the event - RtecEventComm::EventSet event (1); - event.length (1); - RtecEventComm::Event &e = event[0]; - - // Initialize the header - const char *symbol = this->data_.symbol; - e.header.type = int(symbol[0]) << 24; - e.header.type |= int(symbol[1]) << 16; - e.header.type |= int(symbol[2]) << 8; - e.header.type |= int(symbol[3]); - e.header.source = 1; - - // Initialize the payload - e.data.any_value <<= this->data_; - - // Push it - this->consumer_proxy_->push (event); -} - -void -Quoter_Stock_i::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - // Forget about the consumer it is not there anymore - this->consumer_proxy_ = - RtecEventChannelAdmin::ProxyPushConsumer::_nil (); -} - -void -Quoter_Stock_i::connect (RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin) -{ - this->consumer_proxy_ = - supplier_admin->obtain_push_consumer (); - RtecEventComm::PushSupplier_var supplier = - this->supplier_personality_._this (); - - const char *symbol = this->data_.symbol; - CORBA::ULong type = int(symbol[0]) << 24; - type |= int(symbol[1]) << 16; - type |= int(symbol[2]) << 8; - type |= int(symbol[3]); - - CORBA::ULong source = 1; - ACE_SupplierQOS_Factory publications; - publications.insert (source, type, 0, 1); - - this->consumer_proxy_->connect_push_supplier (supplier.in (), - publications.get_SupplierQOS ()); -} - diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.h b/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.h deleted file mode 100644 index 91b781df2ee..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_i.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_I_H - -#include "QuoterS.h" -#include <orbsvcs/RtecEventCommS.h> -#include <orbsvcs/RtecEventChannelAdminC.h> - -class Quoter_Stock_i - : public virtual POA_Quoter::Modify_Stock -{ -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - ~Quoter_Stock_i (void); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - void set_price (CORBA::Double new_price) throw (CORBA::SystemException); - - void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException); - - void connect (RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin); - -private: - Quoter::Event data_; - - RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_; - - POA_RtecEventComm::PushSupplier_tie<Quoter_Stock_i> &supplier_personality_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_RT_EVENT_SERVICE_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/client.cpp b/TAO/docs/tutorials/Quoter/RT_Event_Service/client.cpp deleted file mode 100644 index 8bdaab076a8..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/client.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Consumer.h" -#include <orbsvcs/CosNamingC.h> -#include <orbsvcs/Event_Utilities.h> -#include "ace/streams.h" -#include "ace/OS_NS_string.h" -#include "tao/Exception.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("EventService"); - - CORBA::Object_var ec_object = - naming_context->resolve (name); - - // Now downcast the object reference to the appropriate type - RtecEventChannelAdmin::EventChannel_var ec = - RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); - - ACE_ConsumerQOS_Factory qos; - qos.start_disjunction_group (); - - for (int i = 1; i != argc; ++i) { - if (ACE_OS::strlen (argv[i]) < 4) - continue; - - CORBA::ULong type = - ((int(argv[i][0]) << 24) - | (int(argv[i][1]) << 16) - | (int(argv[i][2]) << 8) - | int(argv[i][3])); - - qos.insert_type (type, 0); - } - - Stock_Consumer stock_consumer_i; - stock_consumer_i.connect (ec.in (), qos.get_ConsumerQOS ()); - - orb->run (); - - stock_consumer_i.disconnect (); - - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &ex) { - cerr << "CORBA exception raised!" << ex << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/index.html b/TAO/docs/tutorials/Quoter/RT_Event_Service/index.html deleted file mode 100644 index d664c603331..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/index.html +++ /dev/null @@ -1,385 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>TAO's RT Event Service</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>TAO's RT Event Service</h3> - - <P>We have already explored how to use - <A HREF="../Event_Service/index.html"> - TAO's COS Event Service - </A> - to receive updated stock prices, - but what if we are not interested in all the stocks? - One approach is to use multiple event channels, each one - carrying different traffic. - For example, - each event channel could carry only a subset of the stocks. - In this section we will explore another solution, - using TAO's real-time Event Service to perform filtering for us. - TAO's real-time Event Service can do many other things, - like preserving priority end-to-end, - using multicast to conserve network resources, - generating timeout and interval events, - and it can collaborate with TAO's Scheduling Service to - analyze the schedulability of your system. - </P> - - <H3>Getting the Price Changes</H3> - - <P>For this example we will use the same data structures that we - used in the previous example, - i.e., the events will be identical. - TAO's RT Event Service can be configured to carry your events in - a type-safe manner, - or you can use custom marshaling to send non-IDL structures in - the event, - but it is easier to use it like the COS Event Service first. - </P> - - <H3>Connecting as a consumer</H3> - - <P>Connecting as a consumer is very similar. Some of the base - classes and signatures change, but it is basically the same - idea: - First let us define the consumer object: - </P> -<PRE> -class Stock_Consumer : public POA_RtecEventComm::PushConsumer { -public: - Stock_Consumer (); - - void push (const RtecEventComm::EventSet& data TAO_ENV_ARG_DECL_NOT_USED); - void disconnect_push_consumer (TAO_ENV_SINGLE_ARG_DECL_NOT_USED); - - // details omitted -}; -</PRE> - <P>Notice that we receive an event set instead of a single event. - The event channel can use this feature to queue multiple events - and push them in a single operation. - First we need to extract the event data from the any: - </P> -<PRE> -void -Stock_Consumer::push (const RtecEventComm::EventSet &data - TAO_ENV_ARG_DECL_NOT_USED) -{ - for (CORBA::ULong i = 0; i != data.length (); ++i) { - RtecEventComm::Event &e = data[i]; - - Quoter::Event *event; - if ((e.data.any_value >>= event) == 0) - continue; // Invalid event -</PRE> - <P>Notice that the events have more structure, - they have a clearly separated header and data, - and the data has more than just an any. - The header is used to provide filtering, and - the event data field can be configured at compile time to carry - whatever IDL structures you want. - Now we can print out the new stock price: - </P> -<PRE> - std::cout << "The new price for one stock in \"" - << event->full_name.in () - << "\" (" << event->symbol.in () - << ") is " << event->price << std::endl; -} -</PRE> - - <P>We also need to implement the disconnect callback: - </P> -<PRE> -void -Stock_Consumer::disconnect_push_consumer (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) -{ - this->supplier_proxy_ = CosEventChannelAdmin::ProxyPushSupplier::_nil (); -} -</PRE> - <P>As with the COS Event Channel we can voluntarily disconnect, - too: - </P> -<PRE> -void -Stock_Consumer::disconnect () -{ - // Do not receive any more events... - this->supplier_proxy_->disconnect_push_supplier (); -} -</PRE> - - <H4>How to connect to the RT event channel</H4> - - <P>Connecting to the RT event channel is very similar to - connecting to the regular event channel. - The only difference is that we must specify the events that we - want to receive. This is described using a fairly complex IDL - structure, but TAO provides a helper class to generate it. - We will assume that we are using the naming service or - something similar to obtain a reference to the event service: - </P> -<PRE> - CORBA::Object_var tmp = naming_context->resolve (name); - RtecEventChannelAdmin::EventChannel_var event_channel = - RtecEventChannelAdmin::EventChannel::_narrow (tmp); -</PRE> - <P>Now we use the event channel to obtain the factory used for - consumer connections: - </P> -<PRE> - RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = - event_channel->for_consumers (); -</PRE> - <P>And use the factory to obtain a proxy: - </P> -<PRE> -void -Stock_Consumer::connect (RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin) -{ - this->supplier_proxy_ = - consumer_admin->obtain_push_supplier (); -</PRE> - <P>Now we list the events that we want to receive. - We use a simple algorithm to assign an event type to each stock - symbol: - </P> -<PRE> - CORBA::ULong rhat_event_type = - (int('R') << 24) | (int('H') << 16) | (int('A') << 8) | int('T'); - CORBA::ULong aaaa_event_type = - (int('A') << 24) | (int('A') << 16) | (int('A') << 8) | int('A'); -</PRE> - <P>Now we create the subscription: - </P> -<PRE> - ACE_ConsumerQOS_Factory subscriptions; - subscriptions.insert_type (rhat_event_type, 0); - subscriptions.insert_type (aaaa_event_type, 0); -</PRE> - <P>And connect to the proxy: - </P> -<PRE> - RtecEventComm::PushConsumer_var myself = this->_this (); - this->supplier_proxy_->connect_push_consumer ( - myself.in (), - subscriptions.get_ConsumerQOS ()); -} -</PRE> - - <H3>Notifying the Price Changes</H3> - - <P>As with the COS Event Channel example we will make our - implementation of the <CODE>Modify_Stock</CODE> interface - generate events whenever the price changes: - </P> -<PRE> -class Quoter_Modify_Stock_i : public POA_Quoter::Modify_Stock { -public: - Quoter_Modify_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - void set_price (CORBA::Double new_price) - throw (CORBA::SystemException); - - void disconnect_push_supplier (TAO_ENV_SINGLE_ARG_DECL_NOT_USED); - -private: - Quoter::Event data_; - - RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_; - - POA_RtecEventComm::PushSupplier_tie < Quoter_Stock_i > supplier_personality_; -}; -</PRE> - <P>The implementation of the <CODE>set_price()</CODE> method is - very similar. - First we store the new price: - </P> -<PRE> -void -Quoter_Stock_i::set_price (CORBA::Double new_price) - throw (CORBA::SystemException) -{ - this->data_.price = new_price; -</PRE> - <P>Next we prepare the event. - This time we must create a sequence, but we just have one - element in it: - </P> -<PRE> - RtecEventComm::EventSet event (1); - event.length (1); -</PRE> - <P>We set the event type based on the stock symbol: - </P> -<PRE> - RtecEventComm::Event &e = event[0]; - const char *symbol = this->data_.symbol; - e.header.type = - ((int(symbol[0]) << 24) - | (int(symbol[1]) << 16) - | (int(symbol[2]) << 8) - | int(symbol[3])); - e.header.source = 1; -</PRE> - <P>The event source is not used in this example, but it must be - non-zero. Now we can set the data: - </P> -<PRE> - e.data.any_value <<= this->data_; -</PRE> - <P>and send the event to the event channel: - </P> -<PRE> - this->consumer_proxy_->push (event); -} -</PRE> - - <H3>Connecting to the Event Service as a Supplier</H3> - - <P>As in the COS Event Channel case we need a supplier personality - to connect to it. - We gain access to the Event Service, for example using the - naming service: - </P> -<PRE> - CORBA::Object_var tmp = naming_context->resolve (name); - RtecEventChannelAdmin::EventChannel_var event_channel = - RtecEventChannelAdmin::EventChannel::_narrow (tmp); -</PRE> - <P>Now we use the event channel to obtain the factory used for - supplier connections: - </P> -<PRE> - RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = - event_channel->for_suppliers (); -</PRE> - <P>And use the factory to obtain a proxy: - </P> -<PRE> - this->consumer_proxy_ = - supplier_admin->obtain_push_consumer (); -</PRE> - <P>We build our publications so the event channel can match - consumers and suppliers based on their common events: - </P> -<PRE> - const char *symbol = this->data_.symbol; - CORBA::ULong type = - ((int(symbol[0]) << 24) - | (int(symbol[1]) << 16) - | (int(symbol[2]) << 8) - | int(symbol[3])); - CORBA::ULong source = 1; - ACE_SupplierQOS_Factory publications; - publications.insert_type (type, source, 0, 1); -</PRE> - <P>Finally we connect to the consumer proxy: - </P> -<PRE> - RtecEventComm::PushSupplier_var supplier = - this->supplier_personality_._this (); - this->consumer_proxy_->connect_push_supplier (supplier); -</PRE> - - <P>The implementation of the disconnect callback is as before: - </P> -<PRE> -void -Quoter_Stock_i::disconnect_push_supplier (TAO_ENV_SINGLE_ARG_DECL_NOT_USED) - throw (CORBA::SystemException) -{ - // Forget about the consumer it is not there anymore - this->consumer_proxy_ = - RtecEventChannelAdmin::ProxyPushConsumer::_nil (); -} -</PRE> - - <H3>Exercise 1</H3> - - <P>Implement a consumer that receives the price update events, - </P> - <P>The - <A HREF="Stock_Consumer.h">header file</A> - is already provided, - along with a sample - <A HREF="client.cpp">client.cpp</A>. - And other support files - <A HREF="../Event_Service/Quoter.idl">Quoter.idl</A>, - <A HREF="GNUMakefile">Makefile</A>, - <A HREF="Stock_i.h">Stock_i.h</A>, - <A HREF="Stock_i.cpp">Stock_i.cpp</A>, - <A HREF="Stock_Factory_i.h">Stock_Factory_i.h</A>, - <A HREF="Stock_Factory_i.cpp">Stock_Factory_i.cpp</A>, - and <A HREF="server.cpp">server.cpp</A>. - </P> - - <H4>Solution</H4> - - <P>Compare your solution with - <A HREF="Stock_Consumer.cpp">Stock_Consumer.cpp</A>. - </P> - - <H4>Testing</H4> - - <P>To test your changes you need to run three programs, - first TAO's Naming Service: -<PRE> -$ $TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -</PRE> - <P>then run TAO's Real-time Event Service - </P> -<PRE> -$ $TAO_ROOT/orbsvcs/Event_Service/Event_Service -</PRE> - - <P>Now you can run your client: -<PRE> -$ client AAAA CCCC -</PRE> - <P>and finally the server: - </P> -<PRE> -$ server MSFT BBBB CCCC < stock_list.txt -</PRE> - <P>Here is the - <A HREF="../Event_Service/stock_list.txt">stock_list.txt file</A>. - </P> - - <H3>Exercise 2</H3> - - <P>Run the same configuration as above, - but this time run multiple clients and servers: - </P> -<PRE> -$ client AAAA MSFT -$ client PPPP -$ server AAAA < stock_list1.txt -$ server QQQQ < stock_list2.txt -</PRE> - <P>Do the clients receive all the events from both servers? - </P> - <P>Here are the - <A HREF="../Event_Service/stock_list1.txt">stock_list1.txt</A> - and - <A HREF="../Event_Service/stock_list2.txt">stock_list2.txt</A> - files. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Wed May 16 10:13:34 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/RT_Event_Service/server.cpp b/TAO/docs/tutorials/Quoter/RT_Event_Service/server.cpp deleted file mode 100644 index 3660fc9b82d..00000000000 --- a/TAO/docs/tutorials/Quoter/RT_Event_Service/server.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "orbsvcs/CosNamingC.h" -#include "ace/streams.h" -#include "ace/OS_NS_unistd.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i; - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Get the Naming Context reference - CORBA::Object_var naming_context_object = - orb->resolve_initial_references ("NameService"); - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - // Create and initialize the name. - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup ("Stock_Factory"); - - // Bind the object - naming_context->rebind (name, stock_factory.in ()); - - // Resolve the Event Service - name[0].id = CORBA::string_dup ("EventService"); - - CORBA::Object_var ec_object = - naming_context->resolve (name); - - // Now downcast the object reference to the appropriate type - RtecEventChannelAdmin::EventChannel_var ec = - RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ()); - - RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = - ec->for_suppliers (); - - stock_factory_i.load_stock_objects (poa.in (), - poa_manager.in (), - supplier_admin.in ()); - - // **************************************************************** - - for (int j = 0; j != 1000; ++j) { - for (int i = 1; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - stock_factory->get_stock (argv[i]); - - CORBA::String_var full_name = stock->full_name (); - - // Get the price - CORBA::Double price = stock->price (); - - Quoter::Modify_Stock_var modify_stock = - Quoter::Modify_Stock::_narrow (stock.in ()); - modify_stock->set_price (price + 1); - - cout << "Set the price of " - << full_name.in () - << " to " << price + 1 << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - ACE_Time_Value tv (0, 500000); - ACE_OS::sleep (tv); - } - } - - stock_factory_i.destroy_stock_objects (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Client/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/Client/Makefile.am deleted file mode 100644 index dd3addbb2f3..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Client/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - - -## Makefile.Quoter_Simple_Client.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS = client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(srcdir)/../../idl \ - -I../../idl - -client_SOURCES = \ - client.cpp - -client_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Simple/Client/Quoter_Simple_Client.mpc b/TAO/docs/tutorials/Quoter/Simple/Client/Quoter_Simple_Client.mpc deleted file mode 100644 index d1f999594f1..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Client/Quoter_Simple_Client.mpc +++ /dev/null @@ -1,12 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : taoexe, portableserver, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific(automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Client/client.cpp b/TAO/docs/tutorials/Quoter/Simple/Client/client.cpp deleted file mode 100644 index 0715a3539fe..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Client/client.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// $Id$ -// - -// Include the generated names.... -#include "QuoterC.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 3) { - cerr << "Usage: " << argv[0] - << " Factory_IOR symbol symbol..." << endl; - return 1; - } - - // Use the first argument to create the factory object reference, - // in real applications we use the naming service, but let's do - // the easy part first! - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Now get the full name and price of the other arguments: - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - factory->get_stock (argv[i]); - - // Get its name, put it on a _var so it is automatically - // released! - CORBA::String_var full_name = stock->full_name (); - - // Now get the price - CORBA::Double price = stock->price (); - - cout << "The price of a stock in \"" - << full_name.in () << "\" is $" - << price << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - // Finally destroy the ORB - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Client/index.html b/TAO/docs/tutorials/Quoter/Simple/Client/index.html deleted file mode 100644 index 9aef82da78d..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Client/index.html +++ /dev/null @@ -1,316 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Introduction - A very simple client</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Introduction - A very simple client</h3> - - <P>We will start with a reasonably simple IDL interface: we want - to build a stock quoter server, some interface to query the - prices of stock. To make life interesting we will use a - different CORBA object for each stock. This may sound like - overkill, but it will motivate a number of elements that are - interesting to learn at the start. - </P> - - <H3>Defining the IDL interfaces</H3> - - <P>At the very least we want an operation to query the stock - price, as in: - </P> -<PRE> - interface Stock { - double price (); - }; -</PRE> - <P>but stocks usually have symbols and full names, so why not add - a couple of attributes to query them: - </P> -<PRE> - interface Stock { - double price (); - - readonly attribute string symbol; - readonly attribute string full_name; - }; -</PRE> - <P>We also need some interface to gain access to the - <CODE>Stock</CODE> object references from their symbols. - Usually we call this kind of interface a <EM>Factory</EM>, - and it looks like this: - </P> -<PRE> - interface Stock_Factory { - Stock get_stock (in string stock_symbol); - }; -</PRE> - <P>Notice how arguments have a <EM>direction</EM>: they are - qualified as <EM>input only (<CODE>in</CODE>)</EM>, - <EM>output only (<CODE>out</CODE>)</EM>, - or <EM>input-output (<CODE>inout</CODE>)</EM> arguments. - There is a problem, though: what happens if the stock symbol is - invalid? The CORBA way is to raise an exception: - </P> -<PRE> - exception Invalid_Stock_Symbol {}; -</PRE> - <P>and then make the exception part of the - <CODE>Stock_Factory</CODE> interface: - </P> -<PRE> - interface Stock_Factory { - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; -</PRE> - - <P>Finally we put all these IDL constructs in a module to avoid - namespace pollution to obtain the - <A HREF="../Quoter.idl">Quoter.idl</A> file. - </P> - - <H3>The Generated Files</H3> - - <P>Let's take a minute to look at the generated code. - You don't need to do this often, in fact you rarely have to do - it at all. But doing it once is educative and can demystify the - role of the IDL compiler. - </P> - <P>To generate the code you must - invoke the IDL compiler, like - this: - </P> -<PRE> -$ $ACE_ROOT/TAO/TAO_IDL/tao_idl Quoter.idl -</PRE> - <P>The complete documentation of the IDL compiler and its options - are included in - <A HREF="../../../../compiler.html">compiler.html</A>. - Naturally this file is included in the distribution. - </P> - - <P>TAO generates 9 files for each IDL file. - <CODE>QuoterC.h</CODE>, <CODE>QuoterC.i</CODE> - and <CODE>QuoterC.cpp</CODE> contain the client-side interfaces. - Notice that the inline functions are in a separate file so you - can optionally compile them out-of-line for smaller code. - Pure clients only need to link the object file - generated from <CODE>QuoterC.cpp</CODE>. - </P> - <P> - Similarly, <CODE>QuoterS.h</CODE>, <CODE>QuoterS.i</CODE> - and <CODE>QuoterS.cpp</CODE> contain the server-side - <EM>skeletons</EM>. Servers must link the object files generated - from <CODE>QuoterS.cpp</CODE> <STRONG>and</STRONG> <CODE>QuoterC.cpp</CODE>. - </P> - <P> - Finally, <CODE>QuoterS_T.h</CODE>, <CODE>QuoterS_T.i</CODE> - and <CODE>QuoterS_T.cpp</CODE> contain the <EM>TIE</EM> classes. - These are the standard (after the CORBA 2.2 spec) skeletons based - on composition instead of inheritance. - They are in separate files only because some compilers cannot - handle mixed template and non-template code in the same source - file. You <STRONG>do not</STRONG> need to compile these files on any - platform. - However, the files are required to compile - <CODE>QuoterS.cpp</CODE>. - Also notice that if your platform does not support namespaces, - then you may be unable to use the TIE approach for some IDL - interfaces. - </P> - - <P>All the extensions and suffixes discussed above can be modified - using options of the IDL compiler; check the documentation for - more details. Notice, though, that you should use consistent - extensions across your project, otherwise you may have problems - with some <CODE>#include</CODE> directives in your IDL source. - </P> - - <H3>Building a simple client</H3> - - <P>With our simple IDL interface ready, we want to start with a - simple client. The first thing to do in any CORBA client or - server is initialize the ORB: - </P> -<PRE> -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); -</PRE> - <P>IDL supports variable-length types whose sizes are not known - at compile time, hence they must be dynamically allocated at run - time. <CODE>_var</CODE> types relieve us of the explicit memory - management of the variable-length types and thus hide the - differences between fixed and variable-length structured types. - </P> - <P>Since the ORB initialization can fail, and in fact, any CORBA - operation can raise a <CODE>CORBA::SystemException</CODE> we use - a <CODE>try/catch</CODE> block to check for any failures. - Needless to say, this is very naive; some failures can be - temporary, and we should have a better way to recover from - errors, but this is enough for our example. - In consequence, at the end of <CODE>main()</CODE> we catch all - kinds of CORBA exceptions: - </P> -<PRE> - } - catch (CORBA::Exception &ex) { - std::cerr << "CORBA exception raised!" << std::endl; - } - return 0; -} -</PRE> - <P>We must not forget that the ORB is a resource that must be - released by the application. Until CORBA 2.3 there was no - standard way to do this. TAO has adopted the new specification, - so our client should really look like this: - </P> -<PRE> -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // the real code goes here! - - orb->destroy (); - } - catch (CORBA::Exception &ex) { - std::cerr << "CORBA exception raised!" << std::endl; - } - return 0; -} -</PRE> - - <P>Just a few words about the ORB name: The spec requires the ORB - to return the same ORB pointer if the same ORB id is used in - <CODE>CORBA::init</CODE>, and - the implementation is free to return the same pointer even if - different ids are used. - Usually this is not a problem, as most applications instantiate a - single ORB. TAO is one of the few CORBA implementations that - actually supports multiple ORB pointers. This can be important - for real-time applications where each ORB executes at a different - priority. - </P> - - <P>Now that we have the ORB pointer, we can start bootstrapping the - application. Normally we would use the Naming Service, - Trading Service, or the Interoperable Naming Service to locate - the stock factory, but for simplicity, let us use just an IOR - string passed in the first argument. - </P> - <P>The easiest way is to use the first argument to get the string, - and then use <CODE>string_to_object()</CODE> to convert it into an - object reference: - </P> -<PRE> - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); -</PRE> - <P>The <CODE>_narrow()</CODE> is used to test if a reference - is of the specified type. If the reference is of the specified - type, it returns a non-nil reference, else it returns a nil. - </P> - <P>There are a few interesting things about TAO: First, it supports - the <CODE>file:</CODE> scheme for object references, so the first - argument could be <CODE>file://a_file_name</CODE>. In that case, - the ORB will open the file named <CODE>"a_file_name"</CODE> and - read the IOR from that file. - TAO also supports the <CODE>corbaloc:</CODE> scheme, for example - <CODE>corbaloc:iiop:1.1@ace.cs.wustl.edu:12345/Stock_Factory</CODE>. - So using a string can be a very powerful bootstrapping protocol. - </P> - <P>Before we go any further, at this point we are using interfaces - generated by the IDL compiler, so we must include the correct - header file! - </P> -<PRE> -#include "QuoterC.h" -</PRE> - Notice that this is all you need to include; the IDL compiler - generates code that includes all the required internal header - files. - When you use TAO services, don't forget to include their - corresponding header files too. - </P> - - <P>Another interesting TAO feature is the support for - <CODE>_unchecked_narrow()</CODE>. - This is part of the CORBA Messaging specification and - essentially performs the same work as <CODE>_narrow()</CODE>, - but it does not check the types remotely. - If you have compile time knowledge that ensures the correctness - of the narrow operation, it is more efficient to use the - unchecked version. - </P> - - <P>Now we can use the rest of the arguments to obtain the stock - objects: - </P> -<PRE> - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - factory->get_stock (argv[i]); -</PRE> - - <H3>Exercise 1</H3> - - <P>Complete the client implementation. It should be easy at this - point, but it will give you a chance to set up your environment - and become familiar with the basics of building a TAO - application. - </P> - <P>You don't need to do everything. - The <A HREF="../Quoter.idl">Quoter.idl</A> file and - a <A HREF="GNUmakefile.Quoter_Simple_Client">Makefile</A> - are provided. Just - implement the <CODE>client.cpp</CODE> file. - Cut & paste the ORB initialization code, and anything you find - useful from above (you can even cheat and look at the solution, - but it is going to be some really boring 30 minutes if you do!). - </P> - - <H4>Solution</H4> - - <P>Look at the - <A HREF="client.cpp">client.cpp</A> file; it should - not be much different from yours. Count the number of lines in - your client, the idl file and the <CODE>QuoterC.*</CODE> files. Do - you want to write all that code over again? - </P> - - <H3>Testing</H3> - - <P>To test this application we need a server working, a - good excuse to go to the next - <A HREF="../Server/index.html">lesson</A> in the tutorial. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 14:55:08 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Makefile.am deleted file mode 100644 index be1c8727300..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_Simple_Impl_Repo_Client.am - -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -I$(srcdir)/../../idl \ - -I../../idl - -client_SOURCES = \ - client.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -client_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING - -## Makefile.Quoter_Simple_Impl_Repo_Server.am - -if BUILD_CORBA_MESSAGING -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs \ - -I$(srcdir)/../../idl \ - -I../../idl - -server_SOURCES = \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_IORTable.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_RTEvent.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS -endif BUILD_CORBA_MESSAGING - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Quoter_Simple_Impl_Repo.mpc b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Quoter_Simple_Impl_Repo.mpc deleted file mode 100644 index e15b2b37572..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Quoter_Simple_Impl_Repo.mpc +++ /dev/null @@ -1,32 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*client) : taoexe, portableserver, rtevent, naming, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl - - source_files { - client.cpp - } -} - -project(*server) : taoserver, rtevent, naming, iortable, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl - - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - } -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.cpp deleted file mode 100644 index a2323a6be36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () - : rhat_ ("RHAT", "RedHat, Inc.", 210), - msft_ ("MSFT", "Microsoft, Inc.", 91) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this (); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.h deleted file mode 100644 index c0e51d1b3ea..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_Factory_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.cpp deleted file mode 100644 index 6149cb79c36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.h b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.h deleted file mode 100644 index 9c41dff6ee0..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/Stock_i.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/client.cpp b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/client.cpp deleted file mode 100644 index 0715a3539fe..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/client.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// $Id$ -// - -// Include the generated names.... -#include "QuoterC.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 3) { - cerr << "Usage: " << argv[0] - << " Factory_IOR symbol symbol..." << endl; - return 1; - } - - // Use the first argument to create the factory object reference, - // in real applications we use the naming service, but let's do - // the easy part first! - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Now get the full name and price of the other arguments: - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - factory->get_stock (argv[i]); - - // Get its name, put it on a _var so it is automatically - // released! - CORBA::String_var full_name = stock->full_name (); - - // Now get the price - CORBA::Double price = stock->price (); - - cout << "The price of a stock in \"" - << full_name.in () << "\" is $" - << price << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - // Finally destroy the ORB - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/index.html b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/index.html deleted file mode 100644 index df534fe1a6e..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/index.html +++ /dev/null @@ -1,177 +0,0 @@ -<!Doctype HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Implementation Repository</title> - <!-- $Id$ --> - </head> - - <body text = "#000000" - link="#000fff" - vlink="#ffofof" - bgcolor="#ffffff"> - - <h3>Implementation Repository</h3> - <P> In the previous example, the client must contact the server - at least once. If the server has been moved to a different host or - port, or if the server is down, binding between the client and - the server fails. Indirect binding through an external location - broker like the Implementation Repository solves this problem. - </P> - <P>An implementation repository maintains a data structure known - as a server table to keep track of the servers. It maintains a - registry of known servers, records which server is currently - running on which host and at which port number, and starts - servers on demand if they are registered to do so. - </P> - <P> When a server - creates a persistent reference, it sets the address and port - number in the profile body of the IOR to point at the - implementation repository that is responsible for the server. - When a client uses this IOR, it gets connected to the - implementation repository, provided the implementation - repository is not down. The repository decodes this IOR and uses - the POA name from the object key to index into its server - table. The repository replies with the current addressing - information of the actual server. The client now sends the - request to the actual server. - </P> - <P>In this example, let's proceed to modify our previous stock - factory example to support indirect binding through an - implementation repository. - </P> - <P>The only thing we have to do for this is to register our - childPOA with the implementation repository. - </P> - <PRE> - orb->_tao_add_to_IOR_table ("childPOA", stock_factory.in ()); - </PRE> - <P> Then, we stringify all the object references as usual and - print them out. - </P> - <PRE> - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - </PRE> - <H3>Exercise</H3> - Modify the <a href=../Server/server.cpp>server.cpp</a> in the simple - server to create the persistent child POA. - You can use the same - <a href=../Quoter.idl>Quoter.idl</a> - <a href=../Server/Stock_i.h>Stock_i.h</a> - <a href=../Server/Stock_i.cpp>Stock_i.cpp</a> - <a href=../Server/Stock_Factory_i.h>Stock_Factory_i.h</a> - <a href=../Server/Stock_Factory_i.cpp>Stock_Factory_i.cpp</a> - <a href=../Client/client.cpp>Client.cpp</a> - You can use this <a href=GNUmakefile.Quoter_Simple_Impl_Repo_Server>Makefile</a>. - <H3>Solution</H3> - Compare your server.cpp with <a href = server.cpp>server.cpp</a> file. - - <H3>Testing</H3> - <P>To test your changes, you need to run four programs. The first - step is to start up the Implementation Repository provided - with TAO. The Implementation Repository is split into one locator at least - one activator. The locator provides the interface visible - to the application intending to use the repository (in our case, - the client), while the activators do the real work of activating - and maintaining servers. - </P> - - <P>First, we start the locator. We need to dump the IOR of the ImplRepo_Service to a file, - so that both the activator and the client can find the locator. - </P> - <PRE> - $ $TAO_ROOT/orbsvcs/ImplRepo_Service/ImplRepo_Service -o implrepo.ior -d 0 -ORBobjrefstyle URL & - </PRE> - - <P>Second, we start the activator, pointing it to the locator's IOR file. - </P> - <PRE> - $ $TAO_ROOT/orbsvcs/ImplRepo_Service/ImR_Activator -ORBInitRef ImplRepoService=file://implrepo.ior - - ImR Activator: Starting doc.ece.uci.edu - ImR Activator: Registered with ImR. - </PRE> - - <P> Next, we need to register our server with the implementation - repository. We can use the - <CODE>$TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr</CODE> - application provided with TAO to add our server to the server - database in the implementation repository. - </P> - <PRE> - $ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr -ORBInitRef - ImplRepoService=file://implrepo.ior add childPOA -c - "./server -ORBUseIMR 1 -ORBobjrefstyle URL -ORBInitRef - ImplRepoService=file://implrepo.ior" - - Successfully registered server <childPOA> - </PRE> - <p> On Windows platforms, use this command instead to register the server - in the implementation repository - </p> - <PRE> - $ACE_ROOT/bin/tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior - add childPOA -c "./server -ORBUseIMR 1 -ORBobjrefstyle URL - -ORBInitRef ImplRepoService=file://implrepo.ior" - </PRE> - <P> We specify the <CODE>-ORBInitRef</CODE> option to use the IOR in - the <CODE>implrepo.ior</CODE> file and the <CODE>-ORBUseIMR</CODE> - option to tell the server to use the IMR for notification of its - startup and shutdown. - </P> - <P>The next step is to generate a simple IOR for our server - to be used with the IMR, using the - <CODE>ior</CODE> option, and write it to <CODE>stock_factory.ior</CODE>. - - </P> - <PRE> - $tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior ior - childPOA -f stock_factory.ior - - corbaloc:iiop:1.1@doc.ece.uci.edu:2690/childPOA - </PRE> - <P> From now, the implementation repository is all set to keep - track of our server and do the needful on a method invocation - on our server. - </P> - <P> Now, execute the client as usual. - </P> - <PRE> - ./client file://stock_factory.ior MSFT RHAT - - The price of a stock in "Microsoft, Inc." is $91 - The price of a stock in "RedHat, Inc." is $210 - </PRE> - <P> For testing the persistency of the POA, let's shut down the - server and then run the client. - </P> - <PRE> - $tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior - shutdown childPOA - - Successfully shutdown server <childPOA> - - ./client file://stock_factory.ior MSFT RHAT - - The price of a stock in "RedHat, Inc." is $210 - The price of a stock in "Microsoft, Inc." is $91 - </PRE> - <H3>More Reading</H3> - <P>More information on Implementation Repository is - <A HREF="../../../../../docs/implrepo/index.html">here</A>. - </P> - <P>The <A HREF="http://www.triodia.com/staff/michi-henning.html">Henning</A> and <A HREF="http://www.iona.com/hyplan/vinoski/">Vinoski</A> - <A HREF="http://www.iona.com/hyplan/vinoski/#book">CORBA book</A> discusses POA policies in detail. Likewise, - the Schmidt and Vinoski - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">columns</A> in C++ Report also include several articles about the POA. Finally, - the <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</A> - distribution includes <A HREF="../../../../../examples/POA">examples</A> that illustrate how - to use the POA policies. - </P> - <hr> - <address><a href="mailto:pgontla@ece.uci.edu">Priyanka Gontla</a></address> -<!-- Created: Wed Mar 29 17:35:30 PST 2000 --> -<!-- hhmts start --> -Last modified: Sat May 19 17:19:07 CDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/server.cpp b/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/server.cpp deleted file mode 100644 index 096cdc27d7c..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Impl-Repo/server.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// $Id$ - -//=========================================================================== -// -// = FILENAME -// server.cpp -// -// = DESCRIPTION -// In this example, -// - Example showing the working of implementation repository. -// -// = AUTHOR -// Priyanka Gontla -// -//============================================================================ - -#include "Stock_Factory_i.h" -#include "tao/IORTable/IORTable.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - - // Initialze the ORB. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Get a reference to the RootPOA. - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - - // Get the POA_var object from Object_var. - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in ()); - - // Get the POAManager of the RootPOA. - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (); - - poa_manager->activate (); - - // Policies for the childPOA to be created. - CORBA::PolicyList policies; - policies.length (2); - - policies[0] = - root_poa->create_id_assignment_policy (PortableServer::USER_ID); - policies[1] = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT); - - - // Create the childPOA under the RootPOA. - PortableServer::POA_var child_poa = - root_poa->create_POA ("childPOA", - poa_manager.in (), - policies); - - // Destroy the policy objects - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - // Create an instance of class Quoter_Stock_Factory_i. - Quoter_Stock_Factory_i stock_factory_i; - - // Get the Object ID. - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId ("Stock_Factory"); - - // Activate the Stock_Factory object. - child_poa->activate_object_with_id (oid.in (), - &stock_factory_i); - - // Get the object reference. - CORBA::Object_var stock_factory = - child_poa->id_to_reference (oid.in ()); - - CORBA::Object_var table_object = - orb->resolve_initial_references ("IORTable"); - - // Stringify all the object referencs. - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - - IORTable::Table_var adapter = - IORTable::Table::_narrow (table_object.in ()); - if (CORBA::is_nil (adapter.in ())) - { - ACE_ERROR ((LM_ERROR, "Nil IORTable\n")); - } - else - { - CORBA::String_var ior = - orb->object_to_string (stock_factory.in ()); - - adapter->bind ("childPOA", ior.in ()); - } - - orb->run (); - - // Destroy POA, waiting until the destruction terminates. - root_poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised !" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Makefile.am deleted file mode 100644 index b66ca814609..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - - -## Makefile.Quoter_Simple_ImprovedServer.am - -if BUILD_EXCEPTIONS -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS = server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(srcdir)/../../idl \ - -I../../idl - -server_SOURCES = \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Quoter_Simple_ImprovedServer.mpc b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Quoter_Simple_ImprovedServer.mpc deleted file mode 100644 index fda3b450dd6..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Quoter_Simple_ImprovedServer.mpc +++ /dev/null @@ -1,10 +0,0 @@ -// $Id$ -project : taoserver, minimum_corba, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl -} diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.cpp deleted file mode 100644 index 156bb8991de..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i (PortableServer::POA_ptr poa) - : stock_factory_poa_ (PortableServer::POA::_duplicate (poa)) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - try { - CORBA::Object_var tmp = - this->stock_factory_poa_->id_to_reference (oid.in ()); - return Quoter::Stock::_narrow (tmp.in ()); - } - catch (PortableServer::POA::ObjectNotActive &) { - throw Quoter::Invalid_Stock_Symbol (); - } -} diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.h deleted file mode 100644 index fcd68a45587..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_Factory_i.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_FACTORY_I_H - -#include "QuoterS.h" - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (PortableServer::POA_ptr stock_factory_poa); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - PortableServer::POA_var stock_factory_poa_; -}; - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_FACTORY_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.cpp deleted file mode 100644 index 6149cb79c36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.h b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.h deleted file mode 100644 index 55e0530d057..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/Stock_i.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -class Quoter_Stock_i - : public virtual POA_Quoter::Stock -{ -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_IMPROVEDSERVER_STOCK_I_H */ diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/index.html b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/index.html deleted file mode 100644 index a7a85151b77..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/index.html +++ /dev/null @@ -1,342 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Introduction - Improving the Server</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Introduction - Improving the Server</h3> - - <P>In this section we will improve over the - <A HREF="../Server/index.html">simple server</A> described - before. - We will discuss how to use POA policies to assign our own object - ids. - </P> - - <P>In our previous example we used two fields of the - <CODE>Quoter_Stock_Factory_i</CODE> to represent the stock quotes. - If we wish to create hundreds of stock objects this approach - would not scale. We need to use some collection to keep track of - the Stock objects, possibly indexed by the stock symbol. - One solution is to use an STL map or something similar, but this - is clearly wasteful. After all, the ORB is also keeping a - collection of objects, indexed by the object ids. - If we only could choose the ids ourselves, then our problem would - be solved. - The good news is that the POA allows this, - the bad news is that we must create a child POA for that. - Why? Because the Root POA ids are assigned by the ORB, and we - don't want to conflict with those. - Furthermore, creating a separate POA is easier to manage, as - multiple components of the application can get their own POA, - that they can treat as a private namespace. - </P> - - <H3>Child POA creation</H3> - - <P>As before, we gain access to the RootPOA: - </P> -<PRE> - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); -</PRE> - <P>Now we create the policies for the child poa. - In this case we want the <CODE>USER_ID</CODE> policy so we can - assign our own ids. - We also want the <CODE>NO_IMPLICIT_ACTIVATION</CODE> policy, to - have more control over additions to our POA. - The POA has more policies that we can control, but we will use - the defaults in this example. - There are many examples in <CODE>$TAO_ROOT/examples/POA/</CODE> that - show how to use other policies in the POA. - </P> - <P>The policies are stored in a sequence, so we first create the - sequence and initialize its length: - </P> -<PRE> - CORBA::PolicyList policies (2); - policies.length (2); -</PRE> - <P>now we create the policies: - </P> -<PRE> - policies[0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - policies[1] = - poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION); -</PRE> - <P>now we can create the child POA; - </P> -<PRE> - PortableServer::POA_var stock_factory_poa = - poa->create_POA ("Stock_Factory_POA", - poa_manager.in (), - policies); -</PRE> - <P>Notice that we shared the POA manager with the RootPOA, so we - only need to use a single POA manager to control the state of - both. - The new POA makes a copy of the policies, so we need to destroy - them to avoid memory leaks: - </P> -<PRE> - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } -</PRE> - - <H3>Activating objects in the child POA</H3> - - <P>Now we must use this POA to activate the stock objects. - To keep the example simple, we will assume that we read the list - of stocks from the stdin, as in: - </P> -<PRE> - while (!std::cin.eof () && std::cin.peek () != EOF) { - const int max_symbol_length = 8; - char symbol[max_symbol_length]; - const int max_full_name_length = 64; - char full_name[max_full_name_length]; - double price; - - std::cin.getline (symbol, max_symbol_length, '\n'); - std::cin.getline (full_name, max_full_name, '\n'); - std::cin >> price; - std::cin.ignore (1, '\n'); - - // The interesting stuff goes here! - } -</PRE> - <P>For each trio of symbol, full name, and price, we create a stock - implementation object: - </P> -<PRE> - PortableServer::ServantBase_var servant = - new Quoter_Stock_i (symbol, full_name, price); -</PRE> - <P>The <CODE>ServantBase_var</CODE> acts like an auto pointer and - will take care of deallocation in case there is an exception. - This time we cannot use <CODE>_this()</CODE> to activate the servant - though, because we want to create our own ids: - </P> -<PRE> - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); -</PRE> - <P>and then activate the object with that id: - </P> -<PRE> - stock_factory_poa->activate_object_with_id (oid.in (), - servant.in ()); -</PRE> - <P>Be careful not to invoke <CODE>_this()</CODE> on any of these - objects, as that would activate them in the RootPOA, ending with - two activations! It is perfectly legal to activate the same - servant multiple times in different POAs (and sometimes even in - the same POA!), but this is not what we want in this case. - </P> - - <H3>Modifying the Stock Factory</H3> - - <P>Now we need to implement a different version of the stock - factory. We pass a reference to the child POA into the constructor - and keep a reference to it: - </P> -<PRE> -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory -{ -public: - Quoter_Stock_Factory (PortableServer::POA_ptr stock_factory_poa) - : stock_factory_poa_ (PortableServer::POA::_duplicate (stock_factory_poa)) - {} - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - PortableServer::POA_var stock_factory_poa_; -}; -</PRE> - <P>Notice that we duplicate the POA, following the usual CORBA - memory rules for input arguments. Since the constructor is not a - CORBA operation, we could use any rules we wished, but it is less - confusing if we stick to the CORBA set. - </P> - <P>The implementation of the <CODE>get_stock</CODE> operation is more - interesting. First we create an object id based on the symbol: - </P> -<PRE> -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); -</PRE> - <P>next we look up that object id in the POA: - </P> -<PRE> - try { - CORBA::Object_var tmp = - this->stock_factory_poa_->id_to_reference (oid.in ()); -</PRE> - <P>then narrow the object reference to the right type and return - it: - </P> -<PRE> - return Quoter::Stock::_narrow (tmp.in ()); - } -</PRE> - <P>If the symbol was invalid, the POA will not find the right - object id and raise an exception: - </P> -<PRE> - catch (PortableServer::POA::ObjectNotActive &) { - throw Quoter::Invalid_Stock_Symbol (); - } -} -</PRE> - - <H3>Memory management for the Stock objects</H3> - - <P>So far we have not discussed memory management for servants. - This is a good opportunity to do it, because the stock objects - are completely controlled by the POA. - The POA provides reference counting for the Servants. You are - <STRONG>not</STRONG> required to use reference counting, but if - you do, most of the memory management is extremely simple. - So why is reference counting not used all the time? Because some - applications do not require it. For example, - our previous simple server did not require any complex memory - management, as the objects were all created on the stack. - </P> - - <P>To use the reference counting features in the POA, you must - override the <CODE>_add_ref()</CODE> and <CODE>_remove_ref()</CODE> - methods, to increase and decrease the reference count. Once the - count reaches 0, you can safely remove the object (but remember - to start the count at 1!). - Implementing these methods in a thread safe way is a tedious - task. To simplify the task, we use a mixin with the - <CODE>PortableServer::RefCountServantBase</CODE> class, as in: - </P> -<PRE> -class Quoter_Stock_i - : public virtual POA_Quoter::Stock, - public virtual PortableServer::RefCountServantBase -{ -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - // as before -}; -</PRE> - <P>TAO's implementation of the <CODE>RefCountServantBase</CODE> is - even thread safe, so you can use this technique in your - multi-threaded servers to dynamically destroy objects. - You simply delegate control to the POA. - Once you deactivate the object, the POA will only invoke - <CODE>_remove_ref()</CODE> once all the threads performing calls on - an object terminate, - so the object is not removed if it is still in use. - Just remember to increment the reference count if you need to - use it, too. - </P> - - <H3>Exersice</H3> - - <P>Modify the following files in the simple server as follows: - <UL> - <LI> <A HREF="../Server/Stock_i.h">Stock_i.h</A>: - Use the reference counted servant to control memory management. - </LI> - <LI> <A HREF="../Server/Stock_Factory_i.h">Stock_Factory_i.h</A>: - Apply the changes described above to use a child POA with the - appropriate policies. - </LI> - <LI> <A HREF="../Server/Stock_Factory_i.cpp">Stock_Factory_i.cpp</A>: - Apply the changes described above to use a child POA with the - appropriate policies. - </LI> - <LI> <A HREF="../Server/server.cpp">server.cpp</A>: - Create the child POA, - initialize the stock objects from the stdin, and create the - right stock factory class. - </LI> - </UL> - You can use the same - <A HREF="../Quoter.idl">Quoter.idl</A>, - <A HREF="../Server/Stock_i.cpp">Stock_i.cpp</A> - and - <A HREF="GNUmakefile.Quoter_Simple_ImprovedServer">Makefile</A> - </P> - - <H4>Solution</H4> - - <P>Compare your solution with the following files: - <UL> - <LI> <A HREF="Stock_i.h">Stock_i.h</A> - </LI> - <LI> <A HREF="Stock_i.cpp">Stock_i.cpp</A> - </LI> - <LI> <A HREF="Stock_Factory_i.h">Stock_Factory_i.h</A> - </LI> - <LI> <A HREF="Stock_Factory_i.cpp">Stock_Factory_i.cpp</A> - </LI> - <LI> <A HREF="server.cpp">server.cpp</A> - </LI> - </UL> - </P> - - <P>Does this solution scale when the number of stock symbols is in - the thousands or millions? Find out about Servant Locators and - Servant Activators in the POA! - </P> - - <H3>Testing</H3> - - <P>A sample - <A HREF="stock_list.txt">input file</A> - is available. You can use the - <A HREF="../Client/index.html">simple client</A> to check the - results, - as follows: -<PRE> -$ server < stock_list.txt > ior_file -$ client file://ior_file AAAA BBBB MSFT RHAT CCCC -</PRE> - Also test invalid symbols! - </P> - - <H3>More Reading</H3> - - <P>The <A -HREF="http://www.triodia.com/staff/michi-henning.html">Henning</A> and -<A HREF="http://www.iona.com/hyplan/vinoski/">Vinoski</A> <A HREF="http://www.iona.com/hyplan/vinoski/#book">CORBA book</A> discusses POA policies in detail. Likewise, - the Schmidt and Vinoski - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">columns - </A> - in C++ Report also include several articles about the POA. Finally, - the <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</a> distribution includes - <A -HREF="../../../../../examples/POA">examples</A> -that illustrate how to use the POA policies. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 18:11:01 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/server.cpp b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/server.cpp deleted file mode 100644 index 06692da309e..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/server.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "Stock_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - CORBA::PolicyList policies (2); - policies.length (2); - - policies[0] = - poa->create_id_assignment_policy (PortableServer::USER_ID); - policies[1] = - poa->create_implicit_activation_policy (PortableServer::NO_IMPLICIT_ACTIVATION); - - PortableServer::POA_var stock_factory_poa = - poa->create_POA ("Stock_Factory_POA", - poa_manager.in (), - policies); - - for (CORBA::ULong i = 0; i != policies.length (); ++i) { - policies[i]->destroy (); - } - - while (!cin.eof () && cin.peek () != EOF) { - const int max_symbol_length = 8; - char symbol[max_symbol_length]; - const int max_full_name_length = 64; - char full_name[max_full_name_length]; - double price; - - cin.getline (symbol, max_symbol_length, '\n'); - cin.getline (full_name, max_full_name_length, '\n'); - cin >> price; - cin.ignore (1, '\n'); - - PortableServer::ServantBase_var servant = - new Quoter_Stock_i (symbol, full_name, price); - - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (symbol); - - stock_factory_poa->activate_object_with_id (oid.in (), - servant.in ()); - } - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i (stock_factory_poa.in ()); - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Put the object reference as an IOR string - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - // Print it out! - cout << ior.in () << endl; - - orb->run (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl - << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/stock_list.txt b/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/stock_list.txt deleted file mode 100644 index d30a0c0255a..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/ImprovedServer/stock_list.txt +++ /dev/null @@ -1,84 +0,0 @@ -MSFT -Microsoft Inc. -91 -RHAT -RedHat Inc. -210 -AAAA -The AAAA Company -100 -BBBB -The BBBB Company -101 -CCCC -The CCCC Company -102 -DDDD -The DDDD Company -103 -EEEE -The EEEE Company -104 -FFFF -The FFFF Company -105 -GGGG -The GGGG Company -106 -HHHH -The HHHH Company -107 -IIII -The IIII Company -108 -JJJJ -The JJJJ Company -109 -KKKK -The KKKK Company -110 -LLLL -The LLLL Company -111 -MMMM -The MMMM Company -112 -NNNN -The NNNN Company -113 -OOOO -The OOOO Company -114 -PPPP -The PPPP Company -115 -QQQQ -The QQQQ Company -116 -RRRR -The RRRR Company -117 -SSSS -The SSSS Company -118 -TTTT -The TTTT Company -119 -UUUU -The UUUU Company -120 -VVVV -The VVVV Company -121 -WWWW -The WWWW Company -122 -XXXX -The XXXX Company -123 -YYYY -The YYYY Company -124 -ZZZZ -The ZZZZ Company -125 diff --git a/TAO/docs/tutorials/Quoter/Simple/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/Makefile.am deleted file mode 100644 index dbb1885fecd..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -SUBDIRS = \ - Client \ - Impl-Repo \ - ImprovedServer \ - Persistent \ - Server - diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/Persistent/Makefile.am deleted file mode 100644 index 1e20d49fdfa..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - -noinst_PROGRAMS = - -## Makefile.Quoter_Simple_Persistent_Client.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(srcdir)/../../idl \ - -I../../idl - -client_SOURCES = \ - client.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -client_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Makefile.Quoter_Simple_Persistent_Server.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS += server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(srcdir)/../../idl \ - -I../../idl - -server_SOURCES = \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Quoter_Simple_Persistent.mpc b/TAO/docs/tutorials/Quoter/Simple/Persistent/Quoter_Simple_Persistent.mpc deleted file mode 100644 index c8c3a2ad4ae..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Quoter_Simple_Persistent.mpc +++ /dev/null @@ -1,32 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*client) : taoexe, portableserver, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl - - source_files { - client.cpp - } -} - -project(*server) : taoserver, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl - - source_files { - server.cpp - Stock_Factory_i.cpp - Stock_i.cpp - } -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.cpp deleted file mode 100644 index a2323a6be36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () - : rhat_ ("RHAT", "RedHat, Inc.", 210), - msft_ ("MSFT", "Microsoft, Inc.", 91) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this (); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.h deleted file mode 100644 index c0e51d1b3ea..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_Factory_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.cpp deleted file mode 100644 index 6149cb79c36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.h b/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.h deleted file mode 100644 index 9c41dff6ee0..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/Stock_i.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/client.cpp b/TAO/docs/tutorials/Quoter/Simple/Persistent/client.cpp deleted file mode 100644 index 0715a3539fe..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/client.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// $Id$ -// - -// Include the generated names.... -#include "QuoterC.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - - // There must be at least two arguments, the first is the factory - // name, the rest are the names of the stock symbols we want to - // get quotes for. - if (argc < 3) { - cerr << "Usage: " << argv[0] - << " Factory_IOR symbol symbol..." << endl; - return 1; - } - - // Use the first argument to create the factory object reference, - // in real applications we use the naming service, but let's do - // the easy part first! - CORBA::Object_var factory_object = - orb->string_to_object (argv[1]); - - // Now downcast the object reference to the appropriate type - Quoter::Stock_Factory_var factory = - Quoter::Stock_Factory::_narrow (factory_object.in ()); - - // Now get the full name and price of the other arguments: - for (int i = 2; i != argc; ++i) { - try { - // Get the stock object - Quoter::Stock_var stock = - factory->get_stock (argv[i]); - - // Get its name, put it on a _var so it is automatically - // released! - CORBA::String_var full_name = stock->full_name (); - - // Now get the price - CORBA::Double price = stock->price (); - - cout << "The price of a stock in \"" - << full_name.in () << "\" is $" - << price << endl; - } - catch (Quoter::Invalid_Stock_Symbol &) { - cerr << "Invalid stock symbol <" - << argv[i] << ">" << endl; - } - } - - // Finally destroy the ORB - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/index.html b/TAO/docs/tutorials/Quoter/Simple/Persistent/index.html deleted file mode 100644 index f87e26e2f1c..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/index.html +++ /dev/null @@ -1,375 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Persistent Objects</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Introduction - Improving the Server</h3> - - <P>In this section, we will improve the - <!-- @@ Priyanka: I think the HTML spec requires you to use - quotes for all URLs - --> - <A HREF="../Server/server.cpp"> - simple server - </A> - which we have developed before. We will use POA policies - to create an object with a persistent object reference. - </P> - <P> - The characteristics of a POA are controlled via POA policies - that are specified when the POA is created. - POA policies all have the same form: their values are specified - at creation time using an enumerated type. - In our example we will use the <CODE>LifeSpanPolicy</CODE> - that controls how the lifetime of object references relates to - the lifetime of the POAs that generate the object references - and the <CODE>IdAssignmentPolicy</CODE> that controls how - object ids are assigned. - </P> - - <P> - CORBA Objects that can live irrespective of any particular - process in which they are created or activated are called - <EM>Persistent Objects</EM>. - Likewise, - shorter-lived objects whose lifetimes are bound to the - lifetime of the POA in which they are created are called - <EM>Transient Objects</EM>. - Notice that this has nothing to do with the state of the object: - an application can create transient objects to access some - persistent information maintained in a database. - For example, - such objects can represent a different session or transaction view - of the data. - Similarly, some persistent object references may have no state - or no persistent state. - For example, a logging facility is persistent because it is - always available, but it may maintain no state or simply cache - some state for the current activation. - In general, though, - objects that have persistent state are accessed throught - persistent object references. - </P> - <P> - The standard life span policy for the RootPOA is - <CODE>TRANSIENT</CODE>. - This means that any application that needs to support persistent - objects must create at least another POA with the Persistent - life span policy. - In our example we will create two policies for this child POA. - One policy is the <CODE>LifeSpanPolicy</CODE> which we will set - to be <CODE>PERSISTENT</CODE>. - Usually applications that create persistent object references - also set the <CODE>IdAssignmentPolicy</CODE>, - so they can assign the object ids in a predictable way, - consistent across server activations. - It is possible, but very unusual, to use system ids with - persistent object references. - </P> - <!-- - <P>A POA identifies its object by an object identifier, specified - using the ObjectId type, defined in the PortableServer module. - Within the scope of a POA, all Object IDs must be unique. - An application can either supply its own ObjectID or have the - POA create object identifiers for it. - This Object identification is controlled by the IdAssignmentPolicy. If - the policy value is set to be <CODE>USER_ID</CODE>, the application has - the choice. Otherwise, if this policy value is set to be - <CODE>SYSTEM_ID</CODE>, the RootPOA creates the ObjectIDs. - Let's give our - application a choice for the creation of its Object's IDs. - </P> - --> - <P>For more about POA and its policies, - please refer to - "Advanced CORBA Programming with C++" - by Henning and Vinoski. - The TAO distribution also includes many examples on how to use - the POA and its policies in the - <CODE>$TAO_ROOT/examples/POA</CODE> - directory. - </P> - - <H3>Child POA Creation</H3> - - <P> - As before, we first initialize the ORB, - and obtain a reference to the Root POA. - </P> - <PRE> - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - </PRE> - - <P> - Next we get the <CODE>POAManager</CODE> of the <CODE>RootPOA</CODE> - and use it to activate the <CODE>RootPOA</CODE> - </P> - <PRE> - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - - poa_manager->activate (); - </PRE> - - <P> - Now we create a <CODE>LifeSpanPolicy</CODE> - object with the <CODE>PERSISTENT</CODE> value: - <PRE> - // Create a PERSISTENT LifespanPolicy object - PortableServer::LifespanPolicy_var lifespan = - poa->create_lifespan_policy (PortableServer::PERSISTENT); -</PRE> - <P> - and next we create an <CODE>IdAssignmentPolicy</CODE> object with - the <CODE>USER_ID</CODE> value: - </P> -<PRE> - // Create a USER_ID IdAssignmentPolicy object - PortableServer::IdAssignmentPolicy_var idassignment = - poa->create_id_assignment_policy (PortableServer::USER_ID); - </PRE> - <P>Next we can initialize the sequence of policies: - </P> - <PRE> - CORBA::PolicyList polices (2); - policies.length (2); - policies[0] = - PortableServer::IdAssignmentPolicy::_duplicate (idassignment); - policies[1] = - PortableServer::LifespanPolicy::_duplicate (lifespan); - </PRE> - <!-- @@ Priyanka: I noticed that you used "let's" and "doesn't" - several times, I understand that it is not good style for - professional looking documents, then again it may be my fault, - because I was really loose on the first set of tutorials. - --> - <P>Child POAs are created using the <CODE>create_POA</CODE> - operation on the parent POA. - </P> - <PRE> - PortableServer::POA_var child_poa = - poa->create_POA ("childPOA", - poa_manager.in (), - policies); - </PRE> - <P>The values which we pass to this <CODE>create_POA</CODE> operation are - the name of the child POA, the POAManager of the child POA, and the - <CODE>CORBA::PolicyList</CODE>. - We can create a child controlled by a new - <CODE>POAManager</CODE> by passing - a <CODE>nil</CODE> reference, - but commonly the <CODE>POAManager</CODE> of the parent is used. - </P> - <P>Finally, we can now destroy the life span policy and id assignment - policy objects, since they are no longer needed. The - <CODE>create_POA</CODE> operation will make a copy of the objects in the - policy list and the newly created POA will refer to the copies of the - objects passed to the <CODE>create_POA</CODE>. - </P> - <PRE> - idassignment->destroy (); - lifespan->destroy (); - </PRE> - - <H3>Activating Objects in the child POA </H3> - - <P>Now that we have created a new POA, let's use this POA to activate the - stock objects. The first step would be to create an instance of the - stock factory implementation. - <PRE> - // Create a servant of class Quoter_Stock_Factory_i - Quoter_Stock_Factory_i stock_factory_i; - </PRE> - <P> - Objects can be activated explicitly using the - <CODE>activate_object_with_id ()</CODE> - operation. - This operation has two input parameters: - id of the object and a pointer to the servant that implements - it. - We create the id using a helper function: - </P> - <PRE> - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId ("Stock_Factory"); - </PRE> - <P>Next, we can activate the "Stock_Factory" object: - </P> - <PRE> - child_poa->activate_object_with_id (oid.in (), - &stock_factory_i); - </PRE> - <P> - This operation does not return the object reference of the new - object, - but we can use the <CODE>id_to_reference</CODE> operation - to obtain the object reference: - </P> - <PRE> - CORBA::Object_var stock_factory = - child_poa->id_to_reference (oid.in ()); - </PRE> - <P>As before, we convert the object reference into an IOR string - so that the client can use it. - </P> - <PRE> - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - std::cout << ior.in () << std::endl; - </PRE> - <P>As we know already, the final step before a client's request can - get processed would be to run the ORB event loop. Last, we destroy - the POA, waiting until the destruction terminates. - </P> - <PRE> - orb->run (); - - // Destroy the POA - poa->destroy (1,1); - orb->destroy (); - </PRE> - - <H3>Exercise</H3> - - Modify the <a href=../Server/server.cpp>server.cpp</a> in the simple - server to create the persistent child POA. - You can use the same - <a href=../Quoter.idl>Quoter.idl</a> - <a href=../Server/Stock_i.h>Stock_i.h</a> - <a href=../Server/Stock_i.cpp>Stcok_i.cpp</a> - <a href=../Server/Stock_Factory_i.h>Stock_Factory_i.h</a> - <a href=../Server/Stock_Factory_i.cpp>Stock_Factory_i.cpp</a> - You can use this <a href=Makefile>Makefile</a>. - <H3>Solution</H3> - Compare your server.cpp with - <a href="server.cpp"> - server.cpp - </a> file. - - <H3>Testing</H3> - You can use the <a href=../Client/client.cpp>client.cpp</a> to check - the results, as follows: - <PRE> - $ ./server -ORBEndPoint iiop://localhost:12345 > server.ref & - </PRE> - - <P>Normally the ORB selects a listening endpoint at random. - This is inadequate for applications with persistent object - references because the references will become invalid if the - server restarts in a new listening endpoint. - In TAO we can control the listening endpont(s) using the - <!-- @@ Priyanka: can you add a URL for the document that - describes all the ORB options? - --> - <CODE>-ORBEndPoint</CODE> option. - For example, for the IIOP protocol, - the endpoint information contains the name or IP address of the - host and a free TCP port number. - In the next - <A HREF="../Impl-Repo/index.html"> - tutorial - </A> - we will learn how we can use the - <!-- @@ Priyanka: can you add a URL for the document that - describes the implementation repository? - --> - Implementation Repository to work with persistent object - references without setting the listening endpoint explicitly. - </P> - <P> The client is executed as usual: - </P> - <PRE> - $ ./client file://server.ref MSFT RHAT - </PRE> - <P>For testing the persistency of the POA, let's kill the server. Then - direct the object reference into a new foo.ref. - </P> - <PRE> - $ kill %1 - $ ./server -ORBEndPoint iiop://localhost:12345 > foo.ref & - [2] 6941 - </PRE> - <P>If we run the client again, we must get the result from the server - as before. - </P> - <PRE> - $ ./client file://server.ref MSFT RHAT - </PRE> - <P>What happens if we don't tell the server to listen from the - same port? - Let's try to run the new server as usual: - </P> - <PRE> - $ ./server > server.ref & - [1] 23897 - $ ./client file://server.ref MSFT RHAT - The price of a stock in "RedHat, Inc." is $210 - The price of a stock in "Microsoft, Inc." is $91 - $ kill %1 - $ ./server > foo.ref & - [2] 23908 - $ ./client file://server.ref MSFT RHAT - CORBA exception raised!TRANSIENT (IDL:omg.org/CORBA/TRANSIENT:1.0) - </PRE> - <!-- @@ Priyanka: check my comments on what a TRANSIENT exception - means - --> - <P>A CORBA TRANSIENT exception is raised. - This indicates that some of the resources required to perform - the request are not available. - In this case the client ORB cannot find the server on the - expected port number. - Without an Implementation Repository the client ORB cannot - locate the server in its new port. - It has to assume that the server is temporarly down, - and could be restarted in the future, - thus the TRANSIENT exception. - </P> - - <H3>More Reading</H3> - - <P>The - <A HREF="http://www.triodia.com/staff/michi-henning.html"> - Henning - </A> - and - <A HREF="http://www.iona.com/hyplan/vinoski/"> - Vinoski - </A> - <A HREF="http://www.iona.com/hyplan/vinoski/#book"> - CORBA book - </A> discusses POA policies in detail. - Likewise, the Schmidt and Vinoski - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html"> - columns - </A> - in C++ Report also include several articles about the POA. - Finally, the - <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html"> - TAO - </A> - distribution includes several - <A HREF="../../../../../examples/POA"> - examples - </A> - that illustrate how to use the POA policies. - </P> - - <hr> - <address><a href="mailto:pgontla@ece.uci.edu">Priyanka Gontla</a></address> -<!-- Created: Wed Mar 1 20:29:59 PST 2000 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 18:09:33 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Simple/Persistent/server.cpp b/TAO/docs/tutorials/Quoter/Simple/Persistent/server.cpp deleted file mode 100644 index 06f5d6282cb..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Persistent/server.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// $Id$ - -//=========================================================================== -// -// = FILENAME -// server.cpp -// -// = DESCRIPTION -// -// In this example, a new POA (childPOA) is created and its -// policy is set so that it object references are persistent. -// -// = AUTHOR -// Priyanka Gontla <pgontla@ece.uci.edu> -// -//============================================================================ - -#include "Stock_Factory_i.h" -#include "ace/streams.h" - -int main (int argc, char *argv[]) -{ - try { - - // Initialze the ORB. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); - - // Get a reference to the RootPOA. - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - - // Get the POA_var object from Object_var. - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in ()); - - // Get the POAManager of the RootPOA. - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (); - - poa_manager->activate (); - - // Create a USER_ID IdAssignmentpolicy object. - PortableServer::IdAssignmentPolicy_var idassignment = - root_poa->create_id_assignment_policy (PortableServer::USER_ID); - - // Create a PERSISTENT LifespanPolicy object. - PortableServer::LifespanPolicy_var lifespan = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT); - - // Policies for the childPOA to be created. - CORBA::PolicyList policies; - policies.length (2); - - policies[0] = - PortableServer::IdAssignmentPolicy::_duplicate (idassignment.in ()); - - policies[1] = - PortableServer::LifespanPolicy::_duplicate (lifespan.in ()); - - // Create the childPOA under the RootPOA. - PortableServer::POA_var child_poa = - root_poa->create_POA ("childPOA", - poa_manager.in (), - policies); - - // Destroy policy objects. - idassignment->destroy (); - lifespan->destroy (); - - // Create an instance of class Quoter_Stock_Factory_i. - Quoter_Stock_Factory_i stock_factory_i; - - // Get the Object ID. - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId ("Stock_Factory"); - - // Activate the Stock_Factory object. - child_poa->activate_object_with_id (oid.in (), - &stock_factory_i); - - // Get the object reference. - CORBA::Object_var stock_factory = - child_poa->id_to_reference (oid.in ()); - - // Stringify all the object referencs. - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - // Print them out ! - cout << ior.in () << endl; - - orb-> run (); - - // Destroy POA, waiting until the destruction terminates. - root_poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised !" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Quoter.idl b/TAO/docs/tutorials/Quoter/Simple/Quoter.idl deleted file mode 100644 index 3129da38a4b..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Quoter.idl +++ /dev/null @@ -1,44 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; -}; diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Makefile.am b/TAO/docs/tutorials/Quoter/Simple/Server/Makefile.am deleted file mode 100644 index 553f4e013be..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_ROOT = $(top_srcdir) - - -## Makefile.Quoter_Simple_Server.am - -if BUILD_EXCEPTIONS - -noinst_PROGRAMS = server - -server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(srcdir)/../../idl \ - -I../../idl - -server_SOURCES = \ - Stock_Factory_i.cpp \ - Stock_i.cpp \ - server.cpp \ - Stock_Factory_i.h \ - Stock_i.h - -server_LDADD = \ - $(top_builddir)/docs/tutorials/Quoter/idl/libQuoter_Idl_Lib.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif BUILD_EXCEPTIONS - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Quoter_Simple_Server.mpc b/TAO/docs/tutorials/Quoter/Simple/Server/Quoter_Simple_Server.mpc deleted file mode 100644 index dc8789b784c..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Quoter_Simple_Server.mpc +++ /dev/null @@ -1,12 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project : taoserver, exceptions { - libs += Quoter_Idl_Lib - after += Quoter_Idl_Lib - - specific (automake) { - includes += $(srcdir)/../../idl - } - includes += ../../idl -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.cpp deleted file mode 100644 index a2323a6be36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" - -Quoter_Stock_Factory_i::Quoter_Stock_Factory_i () - : rhat_ ("RHAT", "RedHat, Inc.", 210), - msft_ ("MSFT", "Microsoft, Inc.", 91) -{ -} - -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this (); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.h b/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.h deleted file mode 100644 index c0e51d1b3ea..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_Factory_i.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H - -#include "Stock_i.h" - -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory { -public: - Quoter_Stock_Factory_i (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_FACTORY_I_H */ - diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.cpp b/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.cpp deleted file mode 100644 index 6149cb79c36..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -#include "Stock_i.h" - -Quoter_Stock_i::Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price) - : symbol_ (symbol), - full_name_ (full_name), - price_ (price) -{ -} - -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} - -char * -Quoter_Stock_i::full_name () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->full_name_.c_str ()); -} - -CORBA::Double -Quoter_Stock_i::price () throw (CORBA::SystemException) -{ - return this->price_; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.h b/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.h deleted file mode 100644 index 61889a69b63..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/Stock_i.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// $Id$ -// - -#ifndef TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H -#define TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H - -#include "QuoterS.h" -#include <string> - -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); - -private: -#if defined (HPUX) && (ACE_HAS_STANDARD_CPP_LIBRARY == 0) - string symbol_; - string full_name_; -#else - std::string symbol_; - std::string full_name_; -#endif /* HPUX */ - CORBA::Double price_; -}; - -#endif /* TAO_TUTORIAL_QUOTER_SIMPLE_SERVER_STOCK_I_H */ - - diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/index.html b/TAO/docs/tutorials/Quoter/Simple/Server/index.html deleted file mode 100644 index 92f4a5f90ba..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/index.html +++ /dev/null @@ -1,355 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Introduction - A very simple server</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Introduction - A very simple server</h3> - - <P>Now that we know how to implement a - <A HREF="../Client/index.html">simple client</A>, we need to - implement a server to test it out. - We have to provide implementations for both the <CODE>Stock</CODE> - and <CODE>Stock_Factory</CODE> interfaces, - and then create an executable that incorporates those implementations. - </P> - - <H3>Implementing the <CODE>Stock</CODE> interface</H3> - - <P>To keep things simple, let's implement a <CODE>Stock</CODE> - object with a fixed price. The constructor will receive all the - parameters: - </P> -<PRE> -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - Quoter_Stock_i (const char *symbol, - const char *full_name, - CORBA::Double price); - -private: - std::string symbol_; - std::string full_name_; - CORBA::Double price_; -}; -</PRE> - <P>In a server, CORBA objects and functions are implemented and - represented by programming language data and functions. These - programming entities that implement and represent CORBA objects - are called <I>servants</I>. <I>Object Adapters</I> link the world of - CORBA objects to the world of programming language servants. They - provide services for creation of CORBA objects and their object - references and for dispatching requests to the appropriate - servants. - </P> - <P>Notice the name of the base class. TAO implements the CORBA 2.2 - specification, which includes the Portable Object Adapter (hence - the POA prefix). This new Object Adapter fixes many problems - with the previous versions of the CORBA specification, where the - so-called Basic Object Adapter was used. Unfortunately, the - specification was ambiguous and lead to incompatible (yet - compliant) implementations. - Code based on the POA, and conforming to the CORBA 2.2 - specification, is almost completely portable, - the only incompatibilities arising from the names of the - generated header files and and other minor things. - Those problems can be easily wrapped in helper classes, and the - file names can be controlled through IDL compiler options in - most cases. - </P> - <P>A server application may contain multiple POA instances, but all - server applications have at least one POA called the <I>RootPOA</I>. - <P>We have to implement the operations and attributes: - </P> -<PRE> -class Quoter_Stock_i : public POA_Quoter::Stock { -public: - // some details omitted - char *symbol () throw (CORBA::SystemException); - char *full_name () throw (CORBA::SystemException); - CORBA::Double price () throw (CORBA::SystemException); -}; - -// In the .cpp file: -char * -Quoter_Stock_i::symbol () throw (CORBA::SystemException) -{ - return CORBA::string_dup (this->symbol_.c_str ()); -} -</PRE> - <P>The other attributes and methods are similar, so we don't - reproduce them here. - </P> - <P>The first question is what are those <CODE>throw()</CODE> - specifications doing there? Any CORBA operation or attribute - can raise a <CODE>CORBA::SystemException</CODE>. The IDL compiler - must generate a throw specification that includes the CORBA - system exceptions and any user exceptions listed in the - <CODE>raise</CODE> clause. In turn, the C++ specification requires - that any derived classes cannot add exceptions to a throw - specification, so you must have a throw specification in your - methods, either including <CODE>CORBA::SystemException</CODE> or - empty. - </P> - - <H4>Memory management rules for arguments</H4> - - <P>It is important to copy the strings before returning them, - because the ORB will use <CODE>CORBA::string_free</CODE> to release - them. The rationale is that over the network, the string must be - copied anyway, hence, the client must be responsible for releasing - the received string. When both client and servers are in the same - address space the ORB can optimize the path and invoke the server - operation directly, without marshaling or demarshaling. If the - client is going to work with both local and remote servers, it - should always expect to own the string. In consequence, the server - implementation must always allocate a copy and return the copy, - because the server-side must also work identically for local and - remote clients. The memory management rules in CORBA are a bit - subtle, but there are some simple rules to follow: - <UL> - <LI>You must make a copy of the memory that you return. The - caller is going to release it. - </LI> - <LI>Conversely, you must release the memory returned to you. The - callee made a copy. - </LI> - <LI>You don't own the memory that you receive as input - arguments, - you can only use it for the duration of the call. - You must make a copy if you want to hold a reference to it - after you return. - </LI> - </UL> - The complete memory management rules can be found in the Henning and - Vinoski book or the CORBA specification. - </P> - - <P>Typing all this code seems tedious. Can't the IDL compiler - help with this? After all, it seems as if the method declarations - are completely specified! The answer is yes, TAO's IDL compiler - can generate empty implementations that you can modify. Simply - use the <KBD>-GI</KBD> option: -<PRE> -$ $ACE_ROOT/TAO/TAO_IDL/tao_idl -GI Quoter.idl -</PRE> - The empty implementations are generated in the - <CODE>QuoterI.h</CODE> and <CODE>QuoterI.cpp</CODE> files. - Be advised that the <CODE>-GI</CODE> option overwrites these files - every time, so it is better to copy your implementation to - another file. - </P> - - <H3>The Stock Factory implementation</H3> - - <P>Our first implementation of the factory will serve only two - stocks, "RHAT" and "MSFT": - </P> -<PRE> -class Quoter_Stock_Factory_i : public POA_Quoter::Stock_Factory -{ -public: - Quoter_Stock_Factory (); - - Quoter::Stock_ptr get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol); - -private: - Quoter_Stock_i rhat_; - Quoter_Stock_i msft_; -}; -</PRE> - - <P>The implementation of the <CODE>get_stock()</CODE> method is - simple, just compare the symbol name and return the appropriate - object reference: - </P> -<PRE> -Quoter::Stock_ptr -Quoter_Stock_Factory_i::get_stock (const char *symbol) - throw (Quoter::Invalid_Stock_Symbol) -{ - if (strcmp (symbol, "RHAT") == 0) { - return this->rhat_._this(); - } else if (strcmp (symbol, "MSFT") == 0) { - return this->msft_._this (); - } - throw Quoter::Invalid_Stock_Symbol (); -} -</PRE> - - <P>So what is that <CODE>_this()</CODE> method? In the POA mapping - the client-side stubs and server-side skeletons are not related - through inheritance. You must either explicitly activate the - servant (your implementation object) or use <CODE>_this()</CODE> to - activate it with its default POA. <CODE>_this()</CODE> creates and - registers a CORBA object under the RootPOA, and returns the created - object reference for the new object. We will discuss more about - explicit and implicit activation later, but at this point it is - important to remove any thoughts about converting pointers to - servants to object references or vice-versa, it just does not - work that way. - </P> - - <H3>Implementing a CORBA server</H3> - - <P>Now that we have all the object implementations in place, we - must create the server executable. We start with the ORB - initialization: - </P> -<PRE> -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); -</PRE> - - <P>On startup, the ORB starts the POA in the {<em>holding state</em>}, - where all requests received are not processed until the POA is - activated. Meanwhile the requests are stored to some - implementation limit. TAO sets this limit to 0, because queueing - is a severe source of overhead and unpredictability in real-time - systems. - </P> - <P>What does this means for us? Well, we have to activate the POA. - The process is a bit tedious. First we gain access to the - RootPOA: -<PRE> - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); -</PRE> - <P><CODE>resolve_initial_references()</CODE> is used to bootstrap - all kinds of services, like the Naming Service and the Trading - Service, but it is also used to gain access to other ORB - interfaces, such as the RootPOA, the Current objects, and the - Policy Managers. - </P> - <P>Now that we have gained access to the Root POA, we must obtain - its POA manager. The POA managers provide interfaces to activate - and deactivate one or more POAs: - </P> -<PRE> - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); -</PRE> - <P>and now we activate the POA: - </P> -<PRE> - poa_manager->activate (); -</PRE> - - <P>The shutdown process is similar to the client side, but now we - must also remember to destroy the POA. Putting all the code - above together, we get: - </P> -<PRE> -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // The application code goes here! - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &ex) { - std::cerr << "CORBA exception raised!" << std::endl; - } - return 0; -} -</PRE> - - <P>Now we create an instance of our stock factory implementation - and activate it using <CODE>_this()</CODE> - </P> -<PRE> - Quoter_Stock_Factory_i stock_factory_i; - - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); -</PRE> - <P>Next we convert the object reference into an IOR string, so it - can be used by the client: - </P> -<PRE> - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - std::cerr << ior.in () << std::endl; -</PRE> - - <P>There is only one final detail. We must run the ORB event loop - to start processing requests from the client: - </P> -<PRE> - orb->run (); -</PRE> - - <P>There are many details that we have left out from this server, - such as how to terminate the event loop, how to perform servant - memory management, orderly deactivation of servants, and the fact - is that it is not very flexible, but we have covered a number - of other things, and more importantly we can test the client - now! - </P> - - <H3>Exercise 1</H3> - - <P>Flesh out the implementation. You don't have to do it from - scratch, as we provide you with the following files: - <A HREF="Stock_i.h">Stock_i.h</A>, - <A HREF="Stock_i.cpp">Stock_i.cpp</A>, - <A HREF="Stock_Factory_i.h">Stock_Factory_i.h</A> - <A HREF="Stock_Factory_i.cpp">Stock_Factory_i.cpp</A>, - <A HREF="../Quoter.idl">Quoter.idl</A> - and the always useful - <A HREF="GNUmakefile.Quoter_Simple_Server">Makefile</A> - </P> - - <H4>Solution</H4> - - <P>Compare your solution with - <A HREF="server.cpp">server.cpp</A>. - </P> - - <H3>Testing</H3> - - <P>To test this application we need a - <A HREF="../Client/index.html">client</A>. - We just run both of them: -<PRE> -$ server > ior_file -$ client file://ior_file MSFT RHAT -</PRE> - Also test invalid symbols! - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:47:01 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Apr 1 15:03:38 PDT 2001 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/Simple/Server/server.cpp b/TAO/docs/tutorials/Quoter/Simple/Server/server.cpp deleted file mode 100644 index 150b59789bc..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/Server/server.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// $Id$ -// - -#include "Stock_Factory_i.h" -#include "ace/streams.h" - -int main (int argc, char* argv[]) -{ - try { - // First initialize the ORB, that will remove some arguments... - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv, - "" /* the ORB name, it can be anything! */); - CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); - PortableServer::POA_var poa = - PortableServer::POA::_narrow (poa_object.in ()); - PortableServer::POAManager_var poa_manager = - poa->the_POAManager (); - poa_manager->activate (); - - // Create the servant - Quoter_Stock_Factory_i stock_factory_i; - - // Activate it to obtain the object reference - Quoter::Stock_Factory_var stock_factory = - stock_factory_i._this (); - - // Put the object reference as an IOR string - CORBA::String_var ior = orb->object_to_string (stock_factory.in ()); - // Print it out! - cout << ior.in () << endl; - - orb->run (); - - // Destroy the POA, waiting until the destruction terminates - poa->destroy (1, 1); - orb->destroy (); - } - catch (CORBA::Exception &) { - cerr << "CORBA exception raised!" << endl; - } - return 0; -} diff --git a/TAO/docs/tutorials/Quoter/Simple/index.html b/TAO/docs/tutorials/Quoter/Simple/index.html deleted file mode 100644 index 3cbac4318aa..00000000000 --- a/TAO/docs/tutorials/Quoter/Simple/index.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - <head> - <title>Introduction</title> - <!-- $Id$ --> - <META HTTP-EQUIV="Refresh" CONTENT="1; URL=../index.html"> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Introduction</h3> - - <P>The real index to the TAO tutorial is - <A HREF="../index.html">here</A>, - this page should automatically redirect you there, - if not, click on the link. - </P> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 17:57:42 CST 1999 --> -<!-- hhmts start --> -Last modified: Sun Nov 28 23:07:26 CST 1999 -<!-- hhmts end --> - </body> -</html> diff --git a/TAO/docs/tutorials/Quoter/idl/Makefile.am b/TAO/docs/tutorials/Quoter/idl/Makefile.am deleted file mode 100644 index 5670be7df9e..00000000000 --- a/TAO/docs/tutorials/Quoter/idl/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -## Makefile.Quoter_Idl_Lib.am - -BUILT_SOURCES = \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl \ - QuoterS_T.cpp \ - QuoterS_T.h \ - QuoterS_T.inl - -CLEANFILES = \ - Quoter-stamp \ - QuoterC.cpp \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.cpp \ - QuoterS.h \ - QuoterS.inl \ - QuoterS_T.cpp \ - QuoterS_T.h \ - QuoterS_T.inl - -QuoterC.cpp QuoterC.h QuoterC.inl QuoterS.cpp QuoterS.h QuoterS.inl QuoterS_T.cpp QuoterS_T.h QuoterS_T.inl: Quoter-stamp - -Quoter-stamp: $(srcdir)/Quoter.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) -Wb,export_macro=QUOTER_COMMON_Export -Wb,export_include=quoter_common_export.h -GT $(srcdir)/Quoter.idl - @touch $@ - -noinst_LTLIBRARIES = libQuoter_Idl_Lib.la - -libQuoter_Idl_Lib_la_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -DQUOTER_COMMON_BUILD_DLL - -libQuoter_Idl_Lib_la_SOURCES = \ - QuoterC.cpp \ - QuoterS.cpp - -noinst_HEADERS = \ - Quoter.idl \ - QuoterC.h \ - QuoterC.inl \ - QuoterS.h \ - QuoterS.inl \ - QuoterS_T.cpp \ - QuoterS_T.h \ - QuoterS_T.inl \ - quoter_common_export.h - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/docs/tutorials/Quoter/idl/Quoter.idl b/TAO/docs/tutorials/Quoter/idl/Quoter.idl deleted file mode 100644 index b707539eea3..00000000000 --- a/TAO/docs/tutorials/Quoter/idl/Quoter.idl +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// - -module Quoter -{ - exception Invalid_Stock_Symbol {}; - // Used to report an invalid stock name - - // Forward declare the Stock interface - interface Stock; - - interface Stock_Factory - { - // = TITLE - // A factory class for the stock quoter interfaces - // - // = DESCRIPTION - // Return the Quoter interfaces based on their names - // - Stock get_stock (in string stock_symbol) - raises (Invalid_Stock_Symbol); - }; - - interface Stock - { - // = TITLE - // A simple interface to query the name and price of stock - // - // = DESCRIPTION - // Return the price and name of a single stock - // - - readonly attribute string symbol; - // Get the stock symbol. - - readonly attribute string full_name; - // Get the name. - - double price (); - // Get the price - - }; - - // used by the event service - struct Event { - double price; - string symbol; - string full_name; - }; - - interface Modify_Stock : Stock { - void set_price (in double new_price); - }; - -}; diff --git a/TAO/docs/tutorials/Quoter/idl/Quoter_idl.mpc b/TAO/docs/tutorials/Quoter/idl/Quoter_idl.mpc deleted file mode 100644 index cc97a77a069..00000000000 --- a/TAO/docs/tutorials/Quoter/idl/Quoter_idl.mpc +++ /dev/null @@ -1,7 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*Lib) : taoexe, portableserver { - dynamicflags += QUOTER_COMMON_BUILD_DLL - idlflags += -Wb,export_macro=QUOTER_COMMON_Export -Wb,export_include=quoter_common_export.h -GT -} diff --git a/TAO/docs/tutorials/Quoter/idl/quoter_common_export.h b/TAO/docs/tutorials/Quoter/idl/quoter_common_export.h deleted file mode 100644 index fa39fda25f1..00000000000 --- a/TAO/docs/tutorials/Quoter/idl/quoter_common_export.h +++ /dev/null @@ -1,40 +0,0 @@ - -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl -// ------------------------------ -#ifndef QUOTER_COMMON_EXPORT_H -#define QUOTER_COMMON_EXPORT_H - -#include "ace/config-all.h" - -#if defined (TAO_AS_STATIC_LIBS) -# if !defined (QUOTER_COMMON_HAS_DLL) -# define QUOTER_COMMON_HAS_DLL 0 -# endif /* ! QUOTER_COMMON_HAS_DLL */ -#else -# if !defined (QUOTER_COMMON_HAS_DLL) -# define QUOTER_COMMON_HAS_DLL 1 -# endif /* ! QUOTER_COMMON_HAS_DLL */ -#endif - -#if defined (QUOTER_COMMON_HAS_DLL) && (QUOTER_COMMON_HAS_DLL == 1) -# if defined (QUOTER_COMMON_BUILD_DLL) -# define QUOTER_COMMON_Export ACE_Proper_Export_Flag -# define QUOTER_COMMON_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define QUOTER_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* QUOTER_COMMON_BUILD_DLL */ -# define QUOTER_COMMON_Export ACE_Proper_Import_Flag -# define QUOTER_COMMON_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define QUOTER_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* QUOTER_COMMON_BUILD_DLL */ -#else /* QUOTER_COMMON_HAS_DLL == 1 */ -# define QUOTER_COMMON_Export -# define QUOTER_COMMON_SINGLETON_DECLARATION(T) -# define QUOTER_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* QUOTER_COMMON_HAS_DLL == 1 */ - -#endif /* QUOTER_COMMON_EXPORT_H */ - -// End of auto generated file. diff --git a/TAO/docs/tutorials/Quoter/index.html b/TAO/docs/tutorials/Quoter/index.html deleted file mode 100644 index d910ceafd98..00000000000 --- a/TAO/docs/tutorials/Quoter/index.html +++ /dev/null @@ -1,97 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> - - <head> - <title>Building a Stock Quoter with TAO - A Tutorial</title> - <!-- $Id$ --> - </head> - - <BODY text = "#000000" - link="#000fff" - vlink="#ff0f0f" - bgcolor="#ffffff"> - - <h3>Building a Stock Quoter with TAO - A Tutorial</h3> - - <P>The tutorial is organized around a single application, which - allows client applications to obtain stock quotes from a quote - service. This application is based on a series of - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">Object Interconnections</A> - columns written by - <A HREF="http://www.cs.wustl.edu/~schmidt/">Doug Schmidt</A> - and <A HREF="http://www.iona.com/hyplan/vinoski/">Steve Vinoski</A> - for the - <A HREF="http://www.cs.wustl.edu/~schmidt/report.html">C++ Report</A> - magazine. - </P> - - <P>This tutorial builds up from simple client and server - applications to explore advanced TAO features, such as - <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html#ami"> - asynchronous method invocation</A>, - <A HREF="http://www.cs.wustl.edu/~schmidt/PDF/C++-report-col19.pdf"> - reliable oneways</A>, - the <A HREF="http://www.cs.wustl.edu/~schmidt/PDF/JSAC-98.pdf"> - real-time Events Service</A>, - the <A HREF="../../INS.html"> - Interoperable Naming Service</A> - support and much more. - </P> - - As you go through the tutorial, feel free to check out the source - files for which links are provided. If you choose to build and - run the example, however, use the files which are part of - the TAO source you <A - HREF="http://deuce.doc.wustl.edu/Download.html">download</a>. You can - find those source files in <CODE>$TAO_ROOT/docs/tutorials/Quoter</CODE>, - where there's also a Makefile to build them with. Downloading the files - individually from these links may result in source that does not build - since the online tutorials may use a different version of - ACE+TAO. <P> - - <HR> - - <OL> - <LI><A HREF="Simple/Client/index.html"> - Introduction - A very simple client</A> - </LI> - <LI><A HREF="Simple/Server/index.html"> - Introduction - A very simple server</A> - </LI> - <LI><A HREF="Simple/ImprovedServer/index.html"> - Introduction - Improving the server via POA policies for - explicit activation and user-defined object ids</A> - </LI> - <LI><A HREF="Simple/Persistent/index.html"> - Introduction - Improving the server via POA policies for - persistent object references</A> - </LI> - <LI><A HREF="Simple/Impl-Repo/index.html"> - Implementation Repository</A> - </LI> - <LI><A HREF="Naming_Service/index.html"> - TAO's Naming Service</A> - </LI> - <LI><A HREF="AMI/index.html"> - Asynchronous Method Invocation - CORBA for impatient clients</A> - </LI> - <LI><A HREF="On_Demand_Activation/index.html"> - On_Demand_Activation</A> - </LI> - <LI><A HREF="Event_Service/index.html"> - TAO's COS Event Service</A> - </LI> - <LI><A HREF="RT_Event_Service/index.html"> - TAO's RT Event Service</A> - </LI> - <li><a href="RTCORBA/docs/index.html" >RTCORBA</a></li> - </OL> - - <hr> - <address><a href="mailto:coryan@cs.wustl.edu">Carlos O'Ryan</a></address> -<!-- Created: Sat Nov 27 15:25:06 CST 1999 --> -<!-- hhmts start --> -Last modified: Fri Aug 27 13:04:01 CDT 2004 -<!-- hhmts end --> - </body> -</html> |