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 | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (patch) | |
tree | da50d054f9c761c3f6a5923f6979e93306c56d68 /TAO/examples/Quoter | |
parent | 0e555b9150d38e3b3473ba325b56db2642e6352b (diff) | |
download | ATCD-6b846cf03c0bcbd8c276cb0af61a181e5f98eaae.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/examples/Quoter')
23 files changed, 0 insertions, 3060 deletions
diff --git a/TAO/examples/Quoter/Factory_Finder.cpp b/TAO/examples/Quoter/Factory_Finder.cpp deleted file mode 100644 index f8b7c4a070e..00000000000 --- a/TAO/examples/Quoter/Factory_Finder.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinder.cpp -// -// = DESCRIPTION -// A Factory Finder for the Quoter example. This example conforms -// to the CosLifeCycle Factory Finder notion. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "Factory_Finder.h" - -ACE_RCSID (Quoter, - - Factory_Finder, "$Id$") - -Quoter_Factory_Finder_Server::Quoter_Factory_Finder_Server (void) -: debug_level_ (1) -{ - // Nothing -} - -Quoter_Factory_Finder_Server::~Quoter_Factory_Finder_Server (void) -{ - ACE_TRY_NEW_ENV - { - // Unbind the Quoter Factory Finder. - CosNaming::Name factory_Finder_Name (2); - factory_Finder_Name.length (2); - factory_Finder_Name[0].id = CORBA::string_dup ("IDL_Quoter"); - factory_Finder_Name[1].id = CORBA::string_dup ("Quoter_Factory_Finder"); - if (!CORBA::is_nil (this->quoterNamingContext_var_.in ())) - this->quoterNamingContext_var_->unbind (factory_Finder_Name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Could not unbind the Factor Finder from the Name Service\n")); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "~Quoter_Factor_Finder_Server"); - } - ACE_ENDTRY; -} - -int -Quoter_Factory_Finder_Server::init (int argc, - char *argv[] - ACE_ENV_ARG_DECL) -{ - const char *exception_message = "Null Message"; - - ACE_TRY - { - exception_message = "While ORB_Manager::init"; - int initvalue = this->orb_manager_.init (argc, - argv - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (initvalue == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "init"), - -1); - - // Activate the POA manager - exception_message = "While activating the POA manager"; - int result = this->orb_manager_.activate_poa_manager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activate_poa_manager"), -1); - - // Copy them, because parse_args expects them there. - this->argc_ = argc; - this->argv_ = argv; - - this->parse_args (); - - - ACE_NEW_RETURN (this->quoter_Factory_Finder_i_ptr_, - Quoter_Factory_Finder_i(this->debug_level_), - -1); - - // Activate the object. - exception_message = "Failure while activating the Quoter Factory Finder Impl"; - CORBA::String_var str = - this->orb_manager_.activate (this->quoter_Factory_Finder_i_ptr_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Print the IOR. - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Factory Finder: IOR is: <%s>\n", str.in ())); - - // Register the Quoter Factory Finder with the Naming Service - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG,"Factory Finder: Trying to get a reference to the Naming Service.\n")); - - // Get the Naming Service object reference. - exception_message = "While resolving the Name Service"; - CORBA::Object_var namingObj_var = - orb_manager_.orb()->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (namingObj_var.in ())) - ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); - - // Narrow the object reference to a Naming Context. - exception_message = "While narrowing the Naming Context"; - CosNaming::NamingContext_var namingContext_var = - CosNaming::NamingContext::_narrow (namingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Get the IDL_Quoter naming context. - CosNaming::Name quoterContextName (1); // max = 1 - quoterContextName.length (1); - quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); - - exception_message = "While resolving the Quoter Naming Context"; - CORBA::Object_var quoterNamingObj_var = - namingContext_var->resolve (quoterContextName ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While narrowing the Quoter Naming Context"; - quoterNamingContext_var_ = - CosNaming::NamingContext::_narrow (quoterNamingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Factory Finder: Have a proper reference to the Quoter Naming Context.\n")); - - // Bind the QuoterFactory Finder to the IDL_Quoter naming - // context. - CosNaming::Name quoter_Factory_Finder_Name_ (1); - quoter_Factory_Finder_Name_.length (1); - quoter_Factory_Finder_Name_[0].id = CORBA::string_dup ("Quoter_Factory_Finder"); - - exception_message = "Factory_Factory::_this"; - CORBA::Object_var ff_obj = this->quoter_Factory_Finder_i_ptr_->_this(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While binding the Factory Finder"; - quoterNamingContext_var_->bind (quoter_Factory_Finder_Name_, - ff_obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Factory_Finder: Bound the Quoter Factory Finder to the Quoter Naming Context.\n")); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_Factor_Finder_Server::init - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "SYS_EX"); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -int -Quoter_Factory_Finder_Server::run (ACE_ENV_SINGLE_ARG_DECL) -{ - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, - "\nQuoter Example: Quoter_Factory_Finder_Server is running\n")); - - orb_manager_.orb()->run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - return 0; -} - - -// Function get_options. - -u_int -Quoter_Factory_Finder_Server::parse_args (void) -{ - ACE_Get_Opt get_opt (this->argc_, this->argv_, "?d:"); - int opt; - int exit_code = 0; - - while ((opt = get_opt ()) != EOF) - switch (opt) - { - case 'd': // debug flag. - this->debug_level_ = ACE_OS::atoi (get_opt.opt_arg ()); - break; - default: - exit_code = 1; - ACE_ERROR ((LM_ERROR, - "%s: unknown arg, -%c\n", - this->argv_[0], char(opt))); - case '?': - ACE_DEBUG ((LM_DEBUG, - "usage: %s" - " [-d] <debug level> - Set the debug level\n" - " [-?] - Prints this message\n" - "\n", - this->argv_[0])); - ACE_OS::exit (exit_code); - break; - } - return 0; -} - -// function main - -int -main (int argc, char *argv []) -{ - Quoter_Factory_Finder_Server quoter_Factory_Finder_Server; - - ACE_TRY_NEW_ENV - { - int result = quoter_Factory_Finder_Server.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - return 1; - else - { - quoter_Factory_Finder_Server.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - return -1; - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - return -1; - } - ACE_ENDTRY; - return 0; -} diff --git a/TAO/examples/Quoter/Factory_Finder.h b/TAO/examples/Quoter/Factory_Finder.h deleted file mode 100644 index 2bed421dc17..00000000000 --- a/TAO/examples/Quoter/Factory_Finder.h +++ /dev/null @@ -1,69 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinder.h -// -// = DESCRIPTION -// Server for the Quoter Factory Finder -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "ace/Get_Opt.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "tao/Utils/ORB_Manager.h" -#include "Factory_Finder_i.h" - -#ifndef QUOTER_FACTORY_FINDER_H -#define QUOTER_FACTORY_FINDER_H - -class Quoter_Factory_Finder_Server -{ - // = TILE - // Server object for the Quoter Factory Finder - -public: - Quoter_Factory_Finder_Server (void); - // Default constructor - - ~Quoter_Factory_Finder_Server (void); - // Destructor - - int init (int argc, char *argv[] ACE_ENV_ARG_DECL); - // Initialize the Quoter_Server state - parsing arguments and ... - - int run (ACE_ENV_SINGLE_ARG_DECL); - // Run the orb - - u_int parse_args (void); - // parse the passed parameters - -private: - TAO_ORB_Manager orb_manager_; - // instance of the ORB Manager - - Quoter_Factory_Finder_i *quoter_Factory_Finder_i_ptr_; - // instance of the Quoter Factory Finder - - CosNaming::NamingContext_var quoterNamingContext_var_; - // reference to the Quoter naming context - - int argc_; - // Number of commandline arguments. - - char **argv_; - // commandline arguments. - - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -#endif /* QUOTER_FACTORY_FINDER_H */ diff --git a/TAO/examples/Quoter/Factory_Finder_i.cpp b/TAO/examples/Quoter/Factory_Finder_i.cpp deleted file mode 100644 index db7d0eec12f..00000000000 --- a/TAO/examples/Quoter/Factory_Finder_i.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinder_i.cpp -// -// = DESCRIPTION -// A Factory Finder for the Quoter example. This example conforms -// to the CosLifeCycle Factory Finder notion. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "Factory_Finder_i.h" -#include "QuoterC.h" - -#include "tao/ORB_Core.h" - -#include "ace/Get_Opt.h" - -ACE_RCSID (Quoter, - Factory_Finder_i, - "$Id$") - -// Constructor -Quoter_Factory_Finder_i::Quoter_Factory_Finder_i (int debug_level) -: debug_level_ (debug_level) -{ - // Nothing -} - -// Destructor. -Quoter_Factory_Finder_i::~Quoter_Factory_Finder_i (void) -{ - // Nothing -} - - -CosLifeCycle::Factories * -Quoter_Factory_Finder_i::find_factories (const CosLifeCycle::Key &factory_key - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory)) -{ - const char *exception_message = "Null Message"; - - CosLifeCycle::Factories *factories_ptr = 0; - - ACE_TRY - { - // Get a reference to the ORB. - CORBA::ORB_ptr orb_ptr = TAO_ORB_Core_instance ()->orb (); - - // Get the Naming Service object reference. - exception_message = "While resolving the Name Service"; - CORBA::Object_var namingObj_var = - orb_ptr->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (namingObj_var.in ())) - ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); - - // Narrow the object reference to a Naming Context. - exception_message = "While narrowing the Naming Context"; - CosNaming::NamingContext_var namingContext_var = - CosNaming::NamingContext::_narrow (namingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Take the key supplied to search for a Quoter Factory - CosNaming::Name factoryName = (CosNaming::Name) factory_key; - - // Try to get a reference to a Quoter Factory - exception_message = "While resolving the Factory Object"; - CORBA::Object_var quoterFactoryObject_var = - namingContext_var->resolve (factoryName ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Check if it is a valid Quoter Factory reference - if (CORBA::is_nil (quoterFactoryObject_var.in())) - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), 0); - - // create a sequence of factories object - factories_ptr = new CosLifeCycle::Factories (1); - - // using the Naming Service only one reference is available - factories_ptr->length (1); - - // Check if it is a valid Quoter Factory reference. - if (CORBA::is_nil (quoterFactoryObject_var.in ())) // throw a NoFactory exception. - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), 0); - - // insert the object reference - (*factories_ptr)[0] = CORBA::Object::_duplicate (quoterFactoryObject_var.in()); - - if (this->debug_level_ > 1) - ACE_DEBUG ((LM_DEBUG, - "Factory Finder: Have reference to a Quoter Factory.\n")); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_Factory_Finder::find_factories - %s\n", exception_message)); - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), 0); - } - ACE_ENDTRY; - - return factories_ptr; -} diff --git a/TAO/examples/Quoter/Factory_Finder_i.h b/TAO/examples/Quoter/Factory_Finder_i.h deleted file mode 100644 index 97695c7c9b2..00000000000 --- a/TAO/examples/Quoter/Factory_Finder_i.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinder_i.h -// -// = DESCRIPTION -// Factory Finder Implementation for the Quoter example -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "QuoterS.h" - -#ifndef QUOTER_FACTORY_FINDER_IMPL_H -#define QUOTER_FACTORY_FINDER_IMPL_H - -class Quoter_Factory_Finder_i : public POA_Stock::Quoter_Factory_Finder -{ - // = TILE - // A CosLifeCycle conforming Factory Finder for the Quoter - // example. It uses the Naming Service to find a fitting factory. - -public: - Quoter_Factory_Finder_i (int debug_level = 1); - ~Quoter_Factory_Finder_i (void); - - virtual CosLifeCycle::Factories * find_factories (const CosLifeCycle::Key &factory_key - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory)); - // Returns a sequence of Factories if factories matching the - // factory_key were found. If no factory was found, then the - // NoFactory exception, defined in CosLifeCycle, is raised. - -private: - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -#endif /* QUOTER_FACTORY_FINDER_IMPL_H */ diff --git a/TAO/examples/Quoter/Generic_Factory.cpp b/TAO/examples/Quoter/Generic_Factory.cpp deleted file mode 100644 index eb1bfe506ab..00000000000 --- a/TAO/examples/Quoter/Generic_Factory.cpp +++ /dev/null @@ -1,309 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// Generic_Factory.cpp -// -// = DESCRIPTION -// The server for the GenericFactory for the quoter example. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "Generic_Factory.h" - -#include "orbsvcs/LifeCycleServiceC.h" - -ACE_RCSID (Quoter, - Generic_Factory, - "$Id$") - -Quoter_Generic_Factory_Server::Quoter_Generic_Factory_Server (void) -: use_LifeCycle_Service_ (0), - debug_level_ (1) -{ -} - -Quoter_Generic_Factory_Server::~Quoter_Generic_Factory_Server (void) -{ - ACE_TRY_NEW_ENV - { - // Unbind the Quoter Factory Finder. - CosNaming::Name generic_Factory_Name (2); - generic_Factory_Name.length (2); - generic_Factory_Name[0].id = CORBA::string_dup ("IDL_Quoter"); - generic_Factory_Name[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); - if (!CORBA::is_nil (this->quoterNamingContext_var_.in ())) - this->quoterNamingContext_var_->unbind (generic_Factory_Name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - } - ACE_ENDTRY; -} - -int -Quoter_Generic_Factory_Server::init (int argc, - char *argv[] - ACE_ENV_ARG_DECL) -{ - const char *exception_message = "Null Message"; - - ACE_TRY - { - int result = 0; - // Initialize the ORB Manager - exception_message = "While initing the orb_manager"; - result = this->orb_manager_.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); - - // Activate the POA manager - exception_message = "While activating the POA manager"; - result = this->orb_manager_.activate_poa_manager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activate_poa_manager"), -1); - - // Copy them, because parse_args expects them there. - this->argc_ = argc; - this->argv_ = argv; - this->parse_args (); - - ACE_NEW_RETURN (this->quoter_Generic_Factory_i_ptr_, - Quoter_Generic_Factory_i(this->debug_level_), - -1); - - // Activate the object. - exception_message = "While activating the Generic Factory"; - CORBA::String_var str = - this->orb_manager_.activate (this->quoter_Generic_Factory_i_ptr_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Print the IOR. - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Generic_Factory: IOR is: <%s>\n", str.in ())); - - // Register the Quoter GenericFactory with the Naming Service. - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Generic_Factory: Trying to get a reference to the Naming Service.\n")); - - // Get the Naming Service object reference. - exception_message = "While getting the Naming Service Reference"; - CORBA::Object_var namingObj_var = - orb_manager_.orb()->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (namingObj_var.in ())) - ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); - - // Narrow the object reference to a Naming Context. - exception_message = "While narrowing the Naming Context"; - CosNaming::NamingContext_var namingContext_var = - CosNaming::NamingContext::_narrow (namingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (namingContext_var.in ())) - ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); - - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Generic_Factory: Have a proper reference to the Naming Service.\n")); - - // Get the IDL_Quoter naming context. - CosNaming::Name quoterContextName (1); // max = 1 - quoterContextName.length (1); - quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); - - exception_message = "While resolving the Quoter"; - CORBA::Object_var quoterNamingObj_var = - namingContext_var->resolve (quoterContextName - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While narrowing the Quoter"; - quoterNamingContext_var_ = - CosNaming::NamingContext::_narrow (quoterNamingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Generic_Factory: Have a proper reference to the Quoter Naming Context.\n")); - - // Bind the Quoter GenericFactory to the IDL_Quoter naming - // context. - CosNaming::Name quoter_Generic_Factory_Name (1); - quoter_Generic_Factory_Name.length (1); - quoter_Generic_Factory_Name[0].id = CORBA::string_dup ("Quoter_Generic_Factory"); - - exception_message = "Generic_Factory::_this"; - CORBA::Object_var gf_obj = this->quoter_Generic_Factory_i_ptr_->_this(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While binding the Generic Factory"; - quoterNamingContext_var_->bind (quoter_Generic_Factory_Name, - gf_obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Generic_Factory: Bound the Quoter GenericFactory to the Quoter Naming Context.\n")); - - // now the Quoter GenericFactory is bound to the Naming Context - // the Generic Factory should try to register itself to the closest - // Life Cycle Service is order to be called. - - if (this->use_LifeCycle_Service_) - { - // get the Quoter_Life_Cycle_Service - CosNaming::Name life_Cycle_Service_Name (1); - life_Cycle_Service_Name.length (1); - life_Cycle_Service_Name[0].id = CORBA::string_dup ("Life_Cycle_Service"); - - exception_message = "While resolving the Life Cycle Service"; - CORBA::Object_var life_Cycle_Service_Obj_var = - namingContext_var->resolve (life_Cycle_Service_Name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While narrowing the Life Cycle Service"; - LifeCycleService::Life_Cycle_Service_var life_Cycle_Service_var = - LifeCycleService::Life_Cycle_Service::_narrow (life_Cycle_Service_Obj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Generic_Factory: Have a proper reference to Life Cycle Service.\n")); - - exception_message = "While _this on Generic Factory"; - CORBA::Object_var object_var = this->quoter_Generic_Factory_i_ptr_->_this(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While registering the generic factory"; - life_Cycle_Service_var->register_factory ("Quoter_Generic_Factory", // name - "Bryan 503", // location - "Generic Factory", // description - object_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, - "Generic_Factory: Registered the Quoter GenericFactory to the Life Cycle Service.\n")); - } - - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_Generic_Factory_Server::init - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Quoter_Generic_Factory_Server::init"); - return -1; - } - ACE_ENDTRY; - - - return 0; -} - -int -Quoter_Generic_Factory_Server::run (ACE_ENV_SINGLE_ARG_DECL) -{ - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, - "\nQuoter Example: Quoter_Generic_Factory_Server is running\n")); - - orb_manager_.orb()->run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - return 0; -} - -// Function get_options. - -u_int -Quoter_Generic_Factory_Server::parse_args (void) -{ - ACE_Get_Opt get_opt (this->argc_, this->argv_, "l?d:"); - int opt; - int exit_code = 0; - - while ((opt = get_opt ()) != EOF) - switch (opt) - { - case 'd': // debug flag. - this->debug_level_ = ACE_OS::atoi (get_opt.opt_arg ()); - break; - case 'l': - this->use_LifeCycle_Service_ = 1; - break; - default: - exit_code = 1; - ACE_ERROR ((LM_ERROR, - "%s: unknown arg, -%c\n", - this->argv_[0], char(opt))); - case '?': - ACE_DEBUG ((LM_DEBUG, - "usage: %s" - " [-d] <debug level> - Set the debug level\n" - " [-?] - Prints this message\n" - " [-l] - Use the lifecycle service\n" - "\n", - this->argv_[0])); - ACE_OS::exit (exit_code); - break; - } - return 0; -} - -// function main - -int -main (int argc, char *argv []) -{ - Quoter_Generic_Factory_Server quoter_Generic_Factory_Server; - - ACE_TRY_NEW_ENV - { - if (quoter_Generic_Factory_Server.init (argc, - argv - ACE_ENV_ARG_PARAMETER) == -1) - return 1; - else - { - quoter_Generic_Factory_Server.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - return -1; - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - return -1; - } - ACE_ENDTRY; - return 0; -} diff --git a/TAO/examples/Quoter/Generic_Factory.h b/TAO/examples/Quoter/Generic_Factory.h deleted file mode 100644 index 8e20a97cba0..00000000000 --- a/TAO/examples/Quoter/Generic_Factory.h +++ /dev/null @@ -1,74 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// Generic_Factory.h -// -// = DESCRIPTION -// A generic factory, customized for the use with the Quoter example. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "ace/Get_Opt.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "tao/Utils/ORB_Manager.h" -#include "Generic_Factory_i.h" - -#ifndef GENERIC_FACTORY_H -#define GENERIC_FACTORY_H - -class Quoter_Generic_Factory_Server -{ - // = TILE - // Server object for the Quoter Generic Factory - -public: - Quoter_Generic_Factory_Server (void); - // Default constructor - - ~Quoter_Generic_Factory_Server (void); - // Destructor - - int init (int argc, - char *argv[] - ACE_ENV_ARG_DECL); - // Initialize the Quoter_Server state - parsing arguments and ... - - int run (ACE_ENV_SINGLE_ARG_DECL); - // Run the orb. - - u_int parse_args (void); - // Parse the passed parameters. - -private: - TAO_ORB_Manager orb_manager_; - // instance of the ORB Manager - - Quoter_Generic_Factory_i *quoter_Generic_Factory_i_ptr_; - // Instance of the Quoter Generic Factory. - - CosNaming::NamingContext_var quoterNamingContext_var_; - // Reference to the Quoter naming context. - - int argc_; - // Number of commandline arguments. - - char **argv_; - // commandline arguments. - - unsigned char use_LifeCycle_Service_; - // flag for whether or not to use the lifecycle service - - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -#endif /* GENERIC_FACTORY_H */ diff --git a/TAO/examples/Quoter/Generic_Factory_i.cpp b/TAO/examples/Quoter/Generic_Factory_i.cpp deleted file mode 100644 index 15c9a4034c5..00000000000 --- a/TAO/examples/Quoter/Generic_Factory_i.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// Generic_Factory_i.cpp -// -// = DESCRIPTION -// The implementation of a LifeCycle Service GenericFactory for the -// Quoter example. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// ============================================================================ - -#include "Generic_Factory_i.h" -#include "QuoterC.h" - -#include "tao/ORB_Core.h" - -#include "ace/Get_Opt.h" - -ACE_RCSID (Quoter, - Generic_Factory_i, - "$Id$") - -// Constructor -Quoter_Generic_Factory_i::Quoter_Generic_Factory_i (int debug_level) -: debug_level_ (debug_level) -{ -} - -// Destructor. -Quoter_Generic_Factory_i::~Quoter_Generic_Factory_i (void) -{ -} - -CORBA::Boolean -Quoter_Generic_Factory_i::supports (const CosLifeCycle::Key & - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return 0; -} - - - -CosNaming::NamingContext_ptr -Quoter_Generic_Factory_i::get_naming_context (const CosLifeCycle::Key &factory_key - ACE_ENV_ARG_DECL) -{ - CosNaming::NamingContext_var quoterNamingContext_var; - ACE_TRY - { - // @@ FIXME Get a reference to the ORB. - CORBA::ORB_ptr orb_ptr = - TAO_ORB_Core_instance ()->orb (); - - // Get the Naming Service object reference. - CORBA::Object_var namingObj_var = - orb_ptr->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (namingObj_var.in ())) - ACE_ERROR ((LM_ERROR, - "(%P|%t) Unable get the Naming Service.\n")); - - // Narrow the object reference to a Naming Context. - CosNaming::NamingContext_var namingContext_var = - CosNaming::NamingContext::_narrow (namingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::Name quoterContextName (1); // max = 1 - quoterContextName.length (1); - quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); - - // Get the IDL_Quoter naming context. - CORBA::Object_var quoterNamingObj_var = - namingContext_var->resolve (quoterContextName ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - quoterNamingContext_var = - CosNaming::NamingContext::_narrow (quoterNamingObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), - CosNaming::NamingContext::_nil ()); - } - ACE_ENDTRY; - return quoterNamingContext_var._retn (); -} - - - -CORBA::Object_ptr -Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key, - const CosLifeCycle::Criteria & - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)) -{ - Stock::Quoter_var quoter_var; - ACE_TRY - { - CosNaming::NamingContext_var quoterNamingContext_var = - this->get_naming_context (factory_key - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // ** now a proper reference to the quoter naming context is - // available - - // Fill in the name of the Quoter Factory. - // Take the key supplied to search for a Quoter Factory - CosNaming::Name factory_Name = (CosNaming::Name) factory_key; - - // Try to get a reference to a Quoter Factory - CORBA::Object_var quoterFactoryObject_var = - quoterNamingContext_var->resolve (factory_Name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // We were able to get a reference to Quoter Factory. - // Check if it is a valid Quoter Factory reference - if (CORBA::is_nil (quoterFactoryObject_var.in())) - { // throw a NoFactory exception - ACE_TRY_THROW (CosLifeCycle::NoFactory (factory_key)); - } - - Stock::Quoter_Factory_var factory_var = - Stock::Quoter_Factory::_narrow (quoterFactoryObject_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (factory_var.in ())) - { - ACE_ERROR ((LM_ERROR, - "invalid factory.\n")); - return CORBA::Object::_nil (); - } - - if (this->debug_level_ > 1) - ACE_DEBUG ((LM_DEBUG, "Generic Factory: Factory reference OK.\n")); - - // Now retrieve the Quoter obj ref corresponding to the key. - quoter_var = - factory_var->create_quoter ("test" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ > 1) - ACE_DEBUG ((LM_DEBUG, "Generic_Factory: Quoter Created\n")); - - if (CORBA::is_nil (quoter_var.in ())) - { - ACE_ERROR ((LM_ERROR, - "null quoter objref returned by factory\n")); - return CORBA::Object::_nil (); - } - - if (this->debug_level_ > 1) - ACE_DEBUG ((LM_DEBUG, "Generic_Factory: Return an object reference to a new object.\n")); - - } - ACE_CATCHANY - { - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), - CORBA::Object::_nil ()); - } - ACE_ENDTRY; - return quoter_var._retn (); -} diff --git a/TAO/examples/Quoter/Generic_Factory_i.h b/TAO/examples/Quoter/Generic_Factory_i.h deleted file mode 100644 index b03ee673647..00000000000 --- a/TAO/examples/Quoter/Generic_Factory_i.h +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// Generic_Factory_i.h -// -// = DESCRIPTION -// A LifeCycle Service Generic Factory for the Quoter example. -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "QuoterS.h" - - -#ifndef QUOTER_GENERIC_FACTORY_IMPL_H -#define QUOTER_GENERIC_FACTORY_IMPL_H - -class Quoter_Generic_Factory_i : public POA_Stock::Quoter_Generic_Factory -{ - // = TILE - // A CosLifeCycle conforming Generic Factory for the Quoter - // example. It uses the Naming Service to find a fitting factory. - -public: - Quoter_Generic_Factory_i (int debug_level = 1); - ~Quoter_Generic_Factory_i (void); - - CORBA::Boolean supports (const CosLifeCycle::Key &factory_key - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Returns true if the Generic Factory is able to forward a request - // for creating an object described by the <factory_key>. - - CORBA::Object_ptr create_object (const CosLifeCycle::Key &factory_key, - const CosLifeCycle::Criteria &the_criteria - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)); - // Returns an object reference to a newly created object, though the - // Generic Factory itself cannot create objects, it will forward the - // request to a more concrete Factory. - -private: - CosNaming::NamingContext_ptr get_naming_context (const CosLifeCycle::Key &factory_key - ACE_ENV_ARG_DECL_NOT_USED); - // a helper to get the proper naming context. - - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -#endif /* QUOTER_GENERIC_FACTORY_IMPL_H */ diff --git a/TAO/examples/Quoter/Makefile.am b/TAO/examples/Quoter/Makefile.am deleted file mode 100644 index 0085dd9be4e..00000000000 --- a/TAO/examples/Quoter/Makefile.am +++ /dev/null @@ -1,190 +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_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) -Sa -St $(srcdir)/Quoter.idl - @touch $@ - - -noinst_HEADERS = \ - Quoter.idl - -## Makefile.Quoter_Client.am - -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 \ - client.cpp \ - client.h - -client_LDADD = \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosLifeCycle.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA - -## Makefile.Quoter_Factory_Finder.am - -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += Factory_Finder - -Factory_Finder_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -Factory_Finder_SOURCES = \ - Factory_Finder.cpp \ - Factory_Finder_i.cpp \ - QuoterC.cpp \ - QuoterS.cpp \ - Factory_Finder.h \ - Factory_Finder_i.h - -Factory_Finder_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosLifeCycle.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA - -## Makefile.Quoter_Generic_Factory.am - -if !BUILD_MINIMUM_CORBA - -noinst_PROGRAMS += Generic_Factory - -Generic_Factory_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -Generic_Factory_SOURCES = \ - Generic_Factory.cpp \ - Generic_Factory_i.cpp \ - QuoterC.cpp \ - QuoterS.cpp \ - Generic_Factory.h \ - Generic_Factory_i.h - -Generic_Factory_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosLifeCycle.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA - -## Makefile.Quoter_Server.am - -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 \ - Quoter_i.cpp \ - server.cpp \ - Quoter_i.h \ - server.h - -server_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosLifeCycle.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -endif !BUILD_MINIMUM_CORBA - -## 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/examples/Quoter/Quoter.idl b/TAO/examples/Quoter/Quoter.idl deleted file mode 100644 index a434287cbca..00000000000 --- a/TAO/examples/Quoter/Quoter.idl +++ /dev/null @@ -1,131 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// quoter.idl -// -// = DESCRIPTION -// Quoter example that illustrate the use of the global POA and -// the CosLifeCycle service. -// -// = AUTHOR -// Darrell Brunsch (brunsch@cs.wustl.edu) -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "orbsvcs/CosLifeCycle.idl" - -module Stock -{ - exception Invalid_Stock {}; - exception Invalid_Quoter {}; - - interface Quoter : CosLifeCycle::LifeCycleObject - { - // = TITLE - // Access Stock information. - - // Returns the current stock value or throws an exception. - long get_quote (in string stock_name) - raises (Invalid_Stock, Invalid_Quoter); - - // LifeCycleObject copy(in FactoryFinder there, - // in Criteria the_criteria) - // raises(NoFactory, NotCopyable, InvalidCriteria, CannotMeetCriteria); - // copies this object to a location "there" using the "the_criteria" - - // void move(in FactoryFinder there, - // in Criteria the_criteria) - // raises(NoFactory, NotMovable, InvalidCriteria, CannotMeetCriteria); - // moves this object to a location "there" using the "the_criteria" - - // void remove() - // raises(NotRemovable); - // removes/deletes this object - - }; - - interface Quoter_Factory - { - // = TITLE - // Creation of Quoter objects - - Quoter create_quoter (in string name) - raises (Invalid_Quoter); - // Returns a new Quoter selected by name e.g., "Dow Jones," - // "Reuters,", etc - }; - - interface Quoter_Factory_Finder : CosLifeCycle::FactoryFinder - { - // = TITLE - // Wrapper for the CosLifeCycle FactoryFinder - // - // inherits: - // Factories find_factories(in Key factory_key) raises(NoFactory); - }; - - interface Quoter_Generic_Factory : CosLifeCycle::GenericFactory - { - // = TITLE - // Wrapper for the CosLifeCycle GenericFactory - // - // inherits: - // boolean supports(in Key k); - // Object create_object(in Key k, in Criteria the_criteria) - // raises (NoFactory, InvalidCriteria, CannotMeetCriteria); - }; - - interface Quoter_Life_Cycle_Service : CosLifeCycle::GenericFactory - { - // = TITLE - // Wrapper for the CosLifeCycle GenericFactory - // - // inherits: - // boolean supports(in Key k); - // Object create_object(in Key k, in Criteria the_criteria) - // raises (NoFactory, InvalidCriteria, CannotMeetCriteria); - - void register_factory (in string name, - in string location, - in string description, - in Object _object); - // provide an method for registering factories with their properties - }; - - interface Criteria_Evaluator - { - // = TITLE - // Criteria Evaluator - // - // = DESCRIPTION - // Interface description for an evaluator of CosLifeCycle - // Criterias. It is mainly a wrapper, which should make - // access easier - // - typedef sequence <CosLifeCycle::NameValuePair> SeqNamedValuePair; - - typedef CosLifeCycle::Criteria Criteria; - - exception NotAvailable { string reason; }; - // raised if the questioned configuration is not available - - SeqNamedValuePair getInitialization (); - // get the initialization - - string getFilter (); - // get a filter string - - SeqNamedValuePair getLogicalLocation (); - // get the logical location - - string getPreferences (); - // get the preferences, not implemented - - void setCriteria (in Criteria criteria_); - // set the Criteria which is searched for keywords - }; -}; - diff --git a/TAO/examples/Quoter/Quoter.mpc b/TAO/examples/Quoter/Quoter.mpc deleted file mode 100644 index a5ed3d19def..00000000000 --- a/TAO/examples/Quoter/Quoter.mpc +++ /dev/null @@ -1,55 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*IDL): taoidldefaults { - IDL_Files { - Quoter.idl - } - custom_only = 1 -} - -project(*server): namingexe, lifecycle, minimum_corba, utils { - after += *IDL - Source_Files { - server.cpp - Quoter_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*client): namingexe, lifecycle, minimum_corba { - after += *IDL - Source_Files { - client.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*Factory Finder): namingexe, lifecycle, minimum_corba, utils { - after += *IDL - Source_Files { - Factory_Finder.cpp - Factory_Finder_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} - -project(*Generic Factory): namingexe, lifecycle, minimum_corba, utils { - after += *IDL - Source_Files { - Generic_Factory.cpp - Generic_Factory_i.cpp - QuoterS.cpp - QuoterC.cpp - } - IDL_Files { - } -} diff --git a/TAO/examples/Quoter/Quoter_i.cpp b/TAO/examples/Quoter/Quoter_i.cpp deleted file mode 100644 index 17caadc1bc1..00000000000 --- a/TAO/examples/Quoter/Quoter_i.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/tests/Quoter -// -// = FILENAME -// Quoter_i.cpp -// -// = AUTHOR -// Darrell Brunsch <brunsch@cs.wustl.edu> -// -// ============================================================================ - -#include "Quoter_i.h" - -#include "tao/debug.h" -#include "tao/ORB_Core.h" - -ACE_RCSID (Quoter, - Quoter_i, - "$Id$") - -// Constructor. Create all the quoter factories. - -Quoter_Factory_i::Quoter_Factory_i (size_t num, PortableServer::POA_ptr poa_ptr) - : poa_ptr_ (poa_ptr), - my_quoters_ (0), - quoter_num_ (num), - next_quoter_ (0) -{ - // Nothing -} - - -// Destructor - -Quoter_Factory_i::~Quoter_Factory_i (void) -{ - for (size_t i = 0; i < this->quoter_num_; i++) - delete this->my_quoters_[i]; - delete [] this->my_quoters_; -} - - -// Initialize everything in the factory - -int Quoter_Factory_i::init (ACE_ENV_SINGLE_ARG_DECL) -{ - ACE_NEW_RETURN (this->my_quoters_, - Quoter_i *[this->quoter_num_], - -1); - - for (size_t i = 0; i < this->quoter_num_; i++) - { - ACE_NEW_RETURN (this->my_quoters_[i], - Quoter_i("x", // name - 0, // don't use the LifeCycle_Service - this->poa_ptr_), // a reference to the poa - -1); - - const char *location_string = "POA::activate"; - ACE_TRY - { - this->poa_ptr_->activate_object (this->my_quoters_[i] ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - location_string = "_this"; - Stock::Quoter_var quoter_var = this->my_quoters_[i]->_this(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - location_string = "CORBA::ORB::object_to_string"; - // Stringify the object reference and print it out. - CORBA::String_var quoter_ior = - TAO_ORB_Core_instance()->orb()->object_to_string (quoter_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, location_string); - return -1; - } - ACE_ENDTRY; - } - - // Everything is ok - return 0; -} - - -// Return the quoter by the id <name>. - -Stock::Quoter_ptr -Quoter_Factory_i::create_quoter (const char * - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Stock::Invalid_Quoter)) -{ - this->next_quoter_ = (this->next_quoter_ + 1) % this->quoter_num_; - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Quoter %d Created\n", this->next_quoter_)); - - return my_quoters_[this->next_quoter_]->_this (ACE_ENV_SINGLE_ARG_PARAMETER); -} - - -// Constructor - -Quoter_i::Quoter_i (const char *name, - const unsigned char use_LifeCycle_Service, - PortableServer::POA_ptr poa_ptr) - : use_LifeCycle_Service_ (use_LifeCycle_Service), - poa_var_ (PortableServer::POA::_duplicate (poa_ptr)) -{ - ACE_UNUSED_ARG (name); -} - - -// Destructor - -Quoter_i::~Quoter_i (void) -{ - // Nothing -} - - -// Returns the current quote for the stock <stock_name>. -// For now, just return 42. It was a good day on Wall Street. - -CORBA::Long -Quoter_i::get_quote (char const * - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, - Stock::Invalid_Stock, - Stock::Invalid_Quoter)) -{ - return 42; -} - - -// Make a copy of this object - -CosLifeCycle::LifeCycleObject_ptr -Quoter_i::copy (CosLifeCycle::FactoryFinder_ptr there, - const CosLifeCycle::Criteria &/*the_criteria*/ - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::NotCopyable, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)) -{ - const char *exception_message = "Null message"; - CosLifeCycle::LifeCycleObject_ptr lifeCycleObject_ptr = -CosLifeCycle::LifeCycleObject::_nil (); - ACE_TRY - { - // The name of the Generic Factory - CosLifeCycle::Key factoryKey (2); // max = 2 - - if (this->use_LifeCycle_Service_ == 1) - { - // use the LifeCycle Service - factoryKey.length(1); - factoryKey[0].id = CORBA::string_dup ("Life_Cycle_Service"); - } - else - { - // use a Generic Factory - factoryKey.length(2); - factoryKey[0].id = CORBA::string_dup ("IDL_Quoter"); - factoryKey[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); - } - - // Find an appropriate factory over there. - exception_message = "While trying to find a factory.\n"; - CosLifeCycle::Factories *factories_ptr = - there->find_factories (factoryKey ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Now it is known that there is at least one factory. - Stock::Quoter_var quoter_var; - - for (u_int i = 0; i < factories_ptr->length (); i++) - { - // Get the first object reference to a factory. - CORBA::Object_ptr generic_FactoryObj_ptr = (*factories_ptr)[i]; - - // Narrow it to a Quoter Factory. - exception_message = "While narrowing.\n"; - CosLifeCycle::GenericFactory_var generic_Factory_var = - CosLifeCycle::GenericFactory::_narrow (generic_FactoryObj_ptr - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (generic_Factory_var.in ())) - { - ACE_ERROR ((LM_ERROR, - "Quoter::copy: Narrow failed. Generic Factory is not valid.\n")); - return CosLifeCycle::LifeCycleObject::_nil(); - } - - CosLifeCycle::Key genericFactoryName (1); // max = 1 - genericFactoryName.length(1); - genericFactoryName[0].id = CORBA::string_dup ("Quoter_Factory"); - - CosLifeCycle::Criteria criteria(1); - criteria.length (1); - criteria[0].name = CORBA::string_dup ("filter"); - criteria[0].value <<= CORBA::string_dup ("name=='Quoter_Generic_Factory'"); - - exception_message = "While creating an object"; - CORBA::Object_var quoterObject_var = - generic_Factory_var->create_object (genericFactoryName, - criteria - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While narrowing object"; - quoter_var = Stock::Quoter::_narrow (quoterObject_var.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (quoter_var.in ())) - { - // If we had already our last chance, then give up. - if (i == factories_ptr->length ()) - { - ACE_ERROR ((LM_ERROR, - "Quoter::copy: Last factory did not work. \n" - "No more factories are available. I give up.\n")); - ACE_THROW_RETURN (CosLifeCycle::NoFactory (factoryKey), - CosLifeCycle::LifeCycleObject::_nil()); - } - else - { - ACE_ERROR ((LM_ERROR, - "Quoter::copy: Factory did not create the Quoter properly.\n")); - // Tell what's wrong and try the next factory. - } - } - else - // if succeeded in creating a new Quoter over there, then stop trying - break; - } - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Quoter copied\n")); - - lifeCycleObject_ptr = - CosLifeCycle::LifeCycleObject::_duplicate ((CosLifeCycle::LifeCycleObject_ptr) quoter_var.in()); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_i::copy - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception"); - - // Report a NoFactory exception back to the caller - ACE_TRY_THROW (CosLifeCycle::NoFactory ()); - } - ACE_ENDTRY; - - ACE_CHECK_RETURN (CosLifeCycle::LifeCycleObject::_nil()); - - return lifeCycleObject_ptr; -} - - -// Move this object using <there> and <the_criteria> - -void -Quoter_i::move (CosLifeCycle::FactoryFinder_ptr /* there */, - const CosLifeCycle::Criteria & /* the_criteria */ - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::NotMovable, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)) -{ - ACE_ERROR ((LM_ERROR, - "Quoter_i::move: The Quoter object is not movable!")); - - ACE_THROW (CosLifeCycle::NotMovable()); -} - - -// Removes the object. Once we shut down the ORB we can call it a day. - -void -Quoter_i::remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NotRemovable)) -{ - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "I have been asked to shut down.\n")); - - TAO_ORB_Core_instance ()->orb ()->shutdown (); -} diff --git a/TAO/examples/Quoter/Quoter_i.h b/TAO/examples/Quoter/Quoter_i.h deleted file mode 100644 index b7e1e2b7e5f..00000000000 --- a/TAO/examples/Quoter/Quoter_i.h +++ /dev/null @@ -1,131 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/examples/Quoter -// -// = FILENAME -// Quoter_i.h -// -// = AUTHOR -// Darrell Brunsch <brunsch@uci.edu> -// -// ============================================================================ - -#ifndef QUOTER_IMPL_H -#define QUOTER_IMPL_H - -#include "QuoterS.h" - -// Forward declaration. -class Quoter_i; - -// Typedefs. -typedef Quoter_i *Quoter_i_ptr; -typedef Quoter_i_ptr Quoter_i_ref; - -class Quoter_i: public POA_Stock::Quoter -{ - // = TITLE - // Quoter_i - // - // = DESCRIPTION - // Actual Quoter Implementation class. Returns a quoter for a given stock - // and provides an example for the lifecycle functionality. -public: - Quoter_i (const char *obj_name = "", - const unsigned char use_LifeCycle_Service = 0, - PortableServer::POA_ptr poa_ptr = 0); - // Constructor (use_LifeCycle_Service is 1 if the LifeCycle_Service should be used - // instead of the Quoter Generic_Factory - - ~Quoter_i (void); - // Destructor - - virtual CORBA::Long get_quote (const char *stock_name - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Stock::Invalid_Stock, - Stock::Invalid_Quoter)); - // Returns the current quote for the stock <stock_name> - - // = Lifecycle methods - - virtual CosLifeCycle::LifeCycleObject_ptr copy (CosLifeCycle::FactoryFinder_ptr there, - const CosLifeCycle::Criteria &the_criteria - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::NotCopyable, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)); - // Make a copy of this object - - virtual void move (CosLifeCycle::FactoryFinder_ptr there, - const CosLifeCycle::Criteria &the_criteria - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::NotMovable, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)); - // Move this object using <there> - - virtual void remove (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NotRemovable)); - // Removes the object. - -private: - unsigned char use_LifeCycle_Service_; - // This flag defines if a Generic Factory is used (0 by default) or - // the more sophisticated LifeCycle Service (1) - - PortableServer::POA_var poa_var_; - // Keep a reference to the POA for use by the move operation -}; - -// Forward declaration. -class Quoter_Factory_i; - -typedef Quoter_Factory_i *Quoter_Factory_i_ptr; - -class Quoter_Factory_i: public POA_Stock::Quoter_Factory -{ - // = TITLE - // Quoter_Factory_i - // - // = DESCRIPTION - // Factory object returning the quoter_impl objrefs. -public: - Quoter_Factory_i (size_t num, PortableServer::POA_ptr poa_ptr); - // Constructor that takes in the number of quoters in the pool. - - ~Quoter_Factory_i (void); - // Destructor. - - int init (ACE_ENV_SINGLE_ARG_DECL); - // Initialize everything in the factory - - virtual Stock::Quoter_ptr create_quoter (const char *name - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Stock::Invalid_Quoter)); - // Return the quoter by the id <name>. - -private: - PortableServer::POA_ptr poa_ptr_; - // Pointer to the poa. - - Quoter_i **my_quoters_; - // Array of quoters. - - size_t quoter_num_; - // Number of quoters. - - size_t next_quoter_; - // Which quoter to return next. -}; - -#endif /* QUOTER_IMPL_H */ diff --git a/TAO/examples/Quoter/README b/TAO/examples/Quoter/README deleted file mode 100644 index 35bddc465a8..00000000000 --- a/TAO/examples/Quoter/README +++ /dev/null @@ -1,78 +0,0 @@ -// $Id$ - -Here is a Stock Quoter example that features the use of the TAO IDL -compiler, the different types of configuration settings (global vs -tss, etc), and the Life Cycle Service. - -For your convenience, the run_test.btm has been provided. It is a -batch file that runs under 4NT. Work is in progress for a regular -batch file that performs the same action. We'll probably get it -working on other platforms as soon as it is completed. - ----------------------------------------- - -DOCUMENTATION FOR THE EXAMPLE -============================= - -Note: Moving the Quoter object is no longer available! - The code was relying on ORB internal mechanisms. One way to - implement the move operation in a standard way would be - to use a servant locator on the POA managing the Quoter object. - -Context: The Quoter example serves several tests, the first is the test - of several multithreading policies and the second is showing the - use of the Life Cycle Service as it is defined in the - CORBA Common Object Services specification. - -Life Cycle Service use-case: - -several processes exist: server, - Factory_Finder, - Generic_Factory, - Life_Cycle_Service - client - -several object exist: Quoter, - Quoter_Factory, - Quoter_Factory_Finder, - Quoter_Generic_Factory, - Quoter_Life_Cycle_Service - -server: The server process contains two kind of objects: Quoter and - Quoter_Factory's. A Quoter is a very simple Object supporting - only one method. The focus is not on a sophisticated object - but on showing how policies work. - The object Quoter_Factory serves as a factory for Quoters. - -Factory_Finder: The COS spec. introduces the concept of a Factory Finder - which is capable to find proper factories. The Naming - Service is used as lookup-mechanism. A reference to - the Factory_Finder is passed as parameter of any copy - or move request. - -Generic_Factory: This process supports the object Quoter_Generic_Factory (QGF). - The QGF supports the GenericFactory interface introduced by - the COS specification. It forwards create_object requests to - more concrete factories, e.g. the Quoter_Factory. The - concrete factories are found via the Naming Service. - -Life_Cycle_Service: This process is very similar to the Generic_Factory - proocess. It also supports an Object, which conforms to - the GenericFactory interface. The Quoter_Life_Cycle_Service - conforms to the idea of a life cycle service as it is - introduced by the COS specification. The Quoter_Life_Cycle_Service - is neutral against the Quoter example. It is not dependent - on it. Only interfaces defined by the CosLifeCycle.idl file - are used. The implemenation uses the COS Trading Service - manage registered Generic Factories, as the Quoter_Generic_Factory - for example. A lookup on the Trading Service is performed - when a create_object request is invoked on it. - -client: Creates one Quoter through using the Quoter_Factory_Finder. After that - the copy method of Quoter is invoked to copy the Quoter to an other - location, which is in this example the same location, but that does - not matter so much. The concept is important in this example. - - The objects are invoked in the following order: - client->Quoter->Quoter_Factory_Finder->Quoter_Life_Cycle_Service - ->Quoter_Generic_Factory->Quoter_Factory diff --git a/TAO/examples/Quoter/client.conf b/TAO/examples/Quoter/client.conf deleted file mode 100644 index 7adf91ec452..00000000000 --- a/TAO/examples/Quoter/client.conf +++ /dev/null @@ -1,4 +0,0 @@ -# $Id$ -# -dynamic Client_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Client_Strategy_Factory() -dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency reactive -ORBsystemidpolicydemuxstrategy dynamic -ORBtablesize 128" diff --git a/TAO/examples/Quoter/client.conf.xml b/TAO/examples/Quoter/client.conf.xml deleted file mode 100644 index 3fb0800e130..00000000000 --- a/TAO/examples/Quoter/client.conf.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from ./examples/Quoter/client.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <!-- $Id$ --> - <!-- --> - <dynamic id="Resource_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Resource_Factory"/> - </dynamic> - <dynamic id="Client_Strategy_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Client_Strategy_Factory"/> - </dynamic> - <dynamic id="Server_Strategy_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Server_Strategy_Factory" params="-ORBconcurrency reactive -ORBsystemidpolicydemuxstrategy dynamic -ORBtablesize 128"/> - </dynamic> -</ACE_Svc_Conf> diff --git a/TAO/examples/Quoter/client.cpp b/TAO/examples/Quoter/client.cpp deleted file mode 100644 index 7dec1d90a22..00000000000 --- a/TAO/examples/Quoter/client.cpp +++ /dev/null @@ -1,404 +0,0 @@ -// $Id$ - -#include "ace/Read_Buffer.h" - -#include "orbsvcs/CosNamingC.h" - -#include "client.h" - -ACE_RCSID (Quoter, - client, - "$Id$") - -Quoter_Task::Quoter_Task (int argc, char **argv) - : argc_ (argc), argv_ (argv) -{ - // Nothing -} - -int -Quoter_Task::svc (void) -{ - if (this->quoter_client.init (this->argc_, this->argv_) == -1) - return 1; - else - return this->quoter_client.run (); -} - -// Constructor. -Quoter_Client::Quoter_Client (void) - : quoter_factory_key_ (0), - quoter_key_ (ACE_OS::strdup ("key0")), - shutdown_ (0), - quoter_var_ (Stock::Quoter::_nil ()), - useLifeCycleService_(0), // use the Generic Factory - debug_level_ (1) -{ - // Nothing -} - -// Parses the command line arguments and returns an error status. - -int -Quoter_Client::parse_args (void) -{ - ACE_Get_Opt get_opts (argc_, argv_, "n:d:lx"); - int opt; - int exit_code = 0; - - while ((opt = get_opts ()) != -1) - switch (opt) - { - case 'n': // multiple threads - // ignore it, it was handled already - break; - case 'd': // debug flag. - this->debug_level_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'l': - this->useLifeCycleService_ = 1; - break; - case 'x': - this->shutdown_ = 1; - break; - default: - exit_code = 1; - ACE_ERROR ((LM_ERROR, - "%s: unknown arg, -%c\n", - this->argv_[0], char(opt))); - case '?': - ACE_DEBUG ((LM_DEBUG, - "usage: %s" - " [-m]" - " [-d] <debug level> - Set the debug level\n" - " [-l] - use the lifecycle service instead of the generic factory" - " [-x]" - "\n", - this->argv_ [0])); - ACE_OS::exit (exit_code); - } - - // Indicates successful parsing of command line. - return 0; -} - -int -Quoter_Client::run (void) -{ - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, - "\nQuoter Example: Quoter_Client is running\n")); - - const char *exception_message = "Null Message"; - ACE_TRY_NEW_ENV - { - exception_message = "While using get_quote ()"; - CORBA::Long q = this->quoter_var_->get_quote ("ACE Hardware" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: ACE Hardware = %i\n", q)); - - // Copy the Quoter - - CosLifeCycle::Criteria criteria; - exception_message = "While copying the quoter"; - CORBA::Object_var quoterObj_var = - this->quoter_var_->copy (factory_Finder_var_.in (), - criteria - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (quoterObj_var.in())) - ACE_ERROR_RETURN ((LM_ERROR, - "Quoter_Client::run: Copied Object pointer is nil!"), - -1); - - // Narrow it to the actual Quoter interface - exception_message = "While narrowing the quoter"; - Stock::Quoter_var copied_quoter_var = - Stock::Quoter::_narrow (quoterObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (copied_quoter_var.in())) - ACE_ERROR_RETURN ((LM_ERROR, - "Quoter_Client::run: Copied Quoter is nil!"), - -1); - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Copied object.\n")); - - exception_message = "While using get_quote () on copied object"; - q = copied_quoter_var->get_quote ("ACE Hardware" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Copied object: ACE Hardware = %i\n", q)); - - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_Client::run - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Quoter_Client::run"); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -Quoter_Client::~Quoter_Client (void) -{ - // Free resources - // Close the ior files - if (this->quoter_factory_key_ != 0) - ACE_OS::free (this->quoter_factory_key_); - if (this->quoter_key_ != 0) - ACE_OS::free (this->quoter_key_); -} - -int -Quoter_Client::init_naming_service (void) -{ - const char *exception_message = "Null Message"; - - ACE_TRY_NEW_ENV - { - // Resolve the Naming Service - CORBA::Object_var naming_obj = - orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to resolve the Name Service.\n"), - -1); - - exception_message = "While narrowing the naming context"; - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Have a proper reference to the Naming Service.\n")); - - CosNaming::Name quoterFactoryFinderName (2); - quoterFactoryFinderName.length (2); - quoterFactoryFinderName[0].id = CORBA::string_dup ("IDL_Quoter"); - quoterFactoryFinderName[1].id = CORBA::string_dup ("Quoter_Factory_Finder"); - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Trying to resolve the Quoter Factory Finder!\n")); - - exception_message = "While resolving the factory finder"; - CORBA::Object_var factory_obj = - naming_context->resolve (quoterFactoryFinderName - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Resolved the Quoter Factory Finder!\n")); - - exception_message = "While narrowing the factory finder"; - factory_Finder_var_ = - Stock::Quoter_Factory_Finder::_narrow (factory_obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (factory_Finder_var_.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " could not resolve quoter factory in Naming service <%s>\n"), - -1); - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Have a proper reference to the Quoter Factory Finder.\n")); - - // The name of the Quoter Generic Factory - CosLifeCycle::Key factoryName (2); // max = 2 - - if (this->useLifeCycleService_ == 1) - { - // use the LifeCycle Service - factoryName.length(1); - factoryName[0].id = CORBA::string_dup ("Life_Cycle_Service"); - } - else - { - // use a Generic Factory - factoryName.length(2); - factoryName[0].id = CORBA::string_dup ("IDL_Quoter"); - factoryName[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); - } - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Trying to get a reference of a factory.\n")); - - // Find an appropriate factory over there. - exception_message = "While finding factories"; - CosLifeCycle::Factories *factories_ptr = - factory_Finder_var_->find_factories (factoryName ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (factories_ptr == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Did not get a Generic Quoter Factory.\n"), - -1); - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Got a proper reference of a factory.\n")); - - - // Get the first object reference to a factory. - CORBA::Object_var quoter_FactoryObj_var; - - if (factories_ptr->length () >= 1) - { - // everything is ok, at least one factory is there - CosLifeCycle::Factory_ptr factory = (*factories_ptr)[0]; - quoter_FactoryObj_var = factory; - } - else - ACE_ERROR_RETURN ((LM_ERROR, - "No Factory received.\n"), - -1); - - // Narrow it to a Quoter Generic Factory - exception_message = "While narrowing the factory"; - generic_Factory_var_ = - CosLifeCycle::GenericFactory::_narrow (quoter_FactoryObj_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (this->generic_Factory_var_.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "Factory received is not valid.\n"), - -1); - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Have a proper reference to the Quoter Factory.\n")); - } - ACE_CATCH (CosLifeCycle::NoFactory, excpt) - { - ACE_ERROR ((LM_ERROR, "Quoter_Client::run - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (excpt, "Quoter::init_naming_service: No Factory available!"); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quoter_Client::init_naming_service - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Quoter::init_naming_service"); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -int -Quoter_Client::init (int argc, char **argv) -{ - this->argc_ = argc; - int i; - - // Make a copy of argv since ORB_init will change it. - this->argv_ = new char *[argc]; - - for (i = 0; i < argc; i++) - this->argv_[i] = argv[i]; - - ACE_TRY_NEW_ENV - { - // Retrieve the ORB. - this->orb_ = CORBA::ORB_init (this->argc_, - this->argv_, - "internet" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Parse command line and verify parameters. - if (this->parse_args () == -1) - return -1; - - int naming_result = this->init_naming_service (); - if (naming_result == -1) - return naming_result; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Factory received OK\n")); - - // using the Quoter Generic Factory - CosLifeCycle::Key genericFactoryName (1); // max = 1 - genericFactoryName.length(1); - genericFactoryName[0].id = CORBA::string_dup ("Quoter_Factory"); - - // The final factory - - CosLifeCycle::Criteria criteria(1); - criteria.length (1); - criteria[0].name = CORBA::string_dup ("filter"); - criteria[0].value <<= CORBA::string_dup ("name=='Quoter_Generic_Factory'"); - // used to find the last generic factory in the chain - - CORBA::Object_var quoterObject_var = - this->generic_Factory_var_->create_object (genericFactoryName, - criteria - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->quoter_var_ = Stock::Quoter::_narrow (quoterObject_var.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Client: Quoter Created\n")); - - if (CORBA::is_nil (this->quoter_var_.in())) - { - ACE_ERROR_RETURN ((LM_ERROR, - "null quoter objref returned by factory\n"), - -1); - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Quoter::init"); - return -1; - } - ACE_ENDTRY; - - return 0; -} - - -// This function runs the test. - -int -main (int argc, char **argv) -{ - ACE_Thread_Manager thr_mgr; - - int i; - int threads = 1; - - for (i = 0; i < argc; i++) - if (ACE_OS::strcmp (argv[i], "-n") == 0) - threads = ACE_OS::atoi(argv[i + 1]); - - Quoter_Task **clients = new Quoter_Task*[threads]; - - for (i = 0; i < threads; i++) - clients[i] = new Quoter_Task (argc, argv); - - - for (i = 0; i < threads; i++) - clients[i]->activate (THR_BOUND | THR_SCHED_FIFO, 1, 0, - ACE_DEFAULT_THREAD_PRIORITY); - - int result = ACE_Thread_Manager::instance ()->wait (); - - for (i = 0; i < threads; i++) - delete clients[i]; - - delete [] clients; - - return result; -} diff --git a/TAO/examples/Quoter/client.h b/TAO/examples/Quoter/client.h deleted file mode 100644 index d5014c872c8..00000000000 --- a/TAO/examples/Quoter/client.h +++ /dev/null @@ -1,118 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/examples/Quoter -// -// = FILENAME -// quoter_client.h -// -// = DESCRIPTION -// Contains classes that do the work of the client side of the Quoter Test -// -// = AUTHORS -// Darrell Brunsch -// -// ============================================================================ - -#ifndef QUOTER_CLIENT_H -#define QUOTER_CLIENT_H - -#include "ace/Get_Opt.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "QuoterC.h" - -#include "orbsvcs/CosLifeCycleC.h" - -#include "ace/Task.h" -#include "ace/Thread_Manager.h" - -class Quoter_Client -{ - // = TITLE - // Quoter_Client - // - // = DESCRIPTION - // Does all the work of making the calls on the Quoter server -public: - // = Constructor and destructor. - Quoter_Client (void); - ~Quoter_Client (void); - - int run (void); - // Execute client example code. - - int init (int argc, char **argv); - // Initialize the client communication endpoint with server. - -private: - CORBA::ORB_var orb_; - // Remember our orb. - - int init_naming_service (void); - // Function to initialize the naming service. - - int parse_args (void); - // Parses the arguments passed on the command line. - - int argc_; - // # of arguments on the command line. - - char **argv_; - // arguments from command line. - - char *quoter_factory_key_; - // Key of factory obj ref. - - char *quoter_key_; - // Key of the obj ref to be retrieved via the factory. - - int shutdown_; - // Flag to tell server to shutdown. - - Stock::Quoter_Factory_Finder_var factory_Finder_var_; - // Pointer to a factory finder - - Stock::Quoter_Factory_var factory_var_; - // Pointer to a factory - - CosLifeCycle::GenericFactory_var generic_Factory_var_; - // Pointer to a generic factory - - Stock::Quoter_var quoter_var_; - // Quoter obj ref. - - int useLifeCycleService_; - // Flag to tell if the a Generic Factory is going to be used - // or the LifeCycle Service (0 means Generic Factory, 1 means LCS) - - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -class Quoter_Task : public ACE_Task<ACE_SYNCH> -{ - // = TITLE - // Quoter_Task - // - // = DESCRIPTION - // Task that creates a Quoter_Client and uses it -public: - Quoter_Task (int argc, char **argv); - - virtual int svc (void); - -private: - Quoter_Client quoter_client; - int argc_; - char **argv_; - -}; - -#endif /* QUOTER_CLIENT_H */ diff --git a/TAO/examples/Quoter/run_test.pl b/TAO/examples/Quoter/run_test.pl deleted file mode 100755 index 143228896c5..00000000000 --- a/TAO/examples/Quoter/run_test.pl +++ /dev/null @@ -1,139 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# $Id$ -# -*- perl -*- - -# This is a Perl script that runs the client and all the other servers that -# are needed. - -use lib '../../../bin'; -use PerlACE::Run_Test; - -$nsiorfile = PerlACE::LocalFile ("ns.ior"); - -# number of threads to use for multithreaded clients or servers - -$num_threads = 4; - -# amount of delay between running the servers - -$sleeptime = 8; - -# other variables - -$status = 0; -$n = 1; -$debug = ""; -$cm = ""; -$sm = ""; - -# Parse the arguments - -for ($i = 0; $i <= $#ARGV; $i++) { - if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") { - print "run_test [-n num] [-d level] [-h] [-nt] [-cm] [-sm]\n"; - print "\n"; - print "-n num -- runs the client num times\n"; - print "-d level -- runs each at debug level <level>\n"; - print "-h -- prints this information\n"; - print "-nt num -- number of threads in the client (twice for server)\n"; - print " make sure this is before any -cm or -sm\n"; - print "-cm -- use more than one thread in the client\n"; - print "-sm -- use more than one thread in the server\n"; - exit; - } - elsif ($ARGV[$i] eq "-n") { - $n = $ARGV[$i + 1]; - $i++; - } - elsif ($ARGV[$i] eq "-nt") { - $num_threads = $ARGV[$i + 1]; - $i++; - } - elsif ($ARGV[$i] eq "-d") { - $debug = $debug." -d $ARGV[$i + 1]"; - $i++; - } - elsif ($ARGV[$i] eq "-cm") { - $cm = "-n ".$num_threads; - } - elsif ($ARGV[$i] eq "-sm") { - $sm = "-n ".($num_threads * 3); - } -} - -# Programs that are run - -$NS = new PerlACE::Process ("../../orbsvcs/Naming_Service/Naming_Service", "-o $nsiorfile"); -$LC = new PerlACE::Process ("../../orbsvcs/LifeCycle_Service/LifeCycle_Service", "$debug -ORBInitRef NameService=file://$nsiorfile"); - -$SV = new PerlACE::Process ("server", "$debug $sm -ORBInitRef NameService=file://$nsiorfile"); -$FF = new PerlACE::Process ("Factory_Finder", "$debug -ORBInitRef NameService=file://$nsiorfile"); -$GF = new PerlACE::Process ("Generic_Factory", "-l $debug -ORBInitRef NameService=file://$nsiorfile"); -$CL = new PerlACE::Process ("client", "-l $debug $cm -ORBInitRef NameService=file://$nsiorfile"); - -$NS->Spawn (); -sleep $sleeptime; - -$LC->Spawn (); -sleep $sleeptime; - -$SV->Spawn (); -sleep $sleeptime; - -$FF->Spawn (); -sleep $sleeptime; - -$GF->Spawn (); -sleep $sleeptime; - - -for ($j = 1; $j <= $n; ++$j) { - $client = $CL->SpawnWaitKill (60); - - if ($client != 0) { - print STDERR "ERROR: client $j returned $client\n"; - $status = 1; - } -} - -$server = $GF->TerminateWaitKill (10); - -if ($server != 0) { - print STDERR "ERROR: Generic Factory returned $server\n"; - $status = 1; -} - -$server = $FF->TerminateWaitKill (10); - -if ($server != 0) { - print STDERR "ERROR: Factory Finder returned $server\n"; - $status = 1; -} - -$server = $SV->TerminateWaitKill (10); - -if ($server != 0) { - print STDERR "ERROR: Server returned $server\n"; - $status = 1; -} - -$server = $LC->TerminateWaitKill (10); - -if ($server != 0) { - print STDERR "ERROR: LifeCycle returned $server\n"; - $status = 1; -} - -$server = $NS->TerminateWaitKill (10); - -if ($server != 0) { - print STDERR "ERROR: Naming Service returned $server\n"; - $status = 1; -} - -unlink $nsiorfile; - -exit $status; diff --git a/TAO/examples/Quoter/server.conf b/TAO/examples/Quoter/server.conf deleted file mode 100644 index 7adf91ec452..00000000000 --- a/TAO/examples/Quoter/server.conf +++ /dev/null @@ -1,4 +0,0 @@ -# $Id$ -# -dynamic Client_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Client_Strategy_Factory() -dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency reactive -ORBsystemidpolicydemuxstrategy dynamic -ORBtablesize 128" diff --git a/TAO/examples/Quoter/server.conf.xml b/TAO/examples/Quoter/server.conf.xml deleted file mode 100644 index 14134f9150c..00000000000 --- a/TAO/examples/Quoter/server.conf.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from ./examples/Quoter/server.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <!-- $Id$ --> - <!-- --> - <dynamic id="Resource_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Resource_Factory"/> - </dynamic> - <dynamic id="Client_Strategy_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Client_Strategy_Factory"/> - </dynamic> - <dynamic id="Server_Strategy_Factory" type="Service_Object"> - <initializer path="TAO" init="_make_TAO_Default_Server_Strategy_Factory" params="-ORBconcurrency reactive -ORBsystemidpolicydemuxstrategy dynamic -ORBtablesize 128"/> - </dynamic> -</ACE_Svc_Conf> diff --git a/TAO/examples/Quoter/server.cpp b/TAO/examples/Quoter/server.cpp deleted file mode 100644 index 973111c3e7e..00000000000 --- a/TAO/examples/Quoter/server.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// $Id$ -// ============================================================================ -// -// = FILENAME -// Quoter_Server.cpp -// -// = DESCRIPTION -// The Server for the Quoter Factory -// -// = AUTHOR -// Darrell Brunsch (brunsch@cs.wustl.edu) -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "server.h" -#include "tao/ORB_Core.h" - -ACE_RCSID(Quoter, server, "$Id$") - -Quoter_Server::Quoter_Server (void) - : num_of_objs_ (1), - quoter_Factory_i_ptr_ (0), - debug_level_ (1) -{ -} - -int -Quoter_Server::parse_args (void) -{ - ACE_Get_Opt get_opts (argc_, argv_, "d:n:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'd': // debug flag. - this->debug_level_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'n': // number of Quoter objects we export - this->num_of_objs_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s" - " [-d] <debug level>" - " [-n] <num of Quoter objects>" - "\n", - argv_ [0]), - 1); - } - - - // Indicates successful parsing of command line. - return 0; -} - - -//Initialize the Quoter Server - -int -Quoter_Server::init (int argc, - char* argv[] - ACE_ENV_ARG_DECL) -{ - const char *exception_message = "Null Message"; - ACE_TRY - { - exception_message = "While ORB Manager init"; - int result = this->orb_manager_.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "init"), - -1); - - // Copy them, because parse_args expects them there. - this->argc_ = argc; - int i; - - // Make a copy of argv since ORB_init will change it. - this->argv_ = new char *[argc]; - - for (i = 0; i < argc; i++) - this->argv_[i] = argv[i]; - - this->parse_args (); - - // Obtain the RootPOA. - CORBA::Object_var obj = - this->orb_manager_.orb()->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Get the POA_var object from Object_var. - exception_message = "While narrowing the root pos"; - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Get the POAManager of the RootPOA. - exception_message = "While getting the POA Manager"; - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_NEW_RETURN (quoter_Factory_i_ptr_, - Quoter_Factory_i(this->num_of_objs_, - root_poa.in()), - 0); - - exception_message = "While initing the quoter factory"; - quoter_Factory_i_ptr_->init (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - PortableServer::ObjectId_var quoter_Factory_oid = - PortableServer::string_to_ObjectId ("Quoter_Factory"); - - exception_message = "While activating quoter factory"; - root_poa->activate_object_with_id (quoter_Factory_oid.in (), - quoter_Factory_i_ptr_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Get Object reference for first_foo_impl object. - exception_message = "While quoter_Factor::_this"; - Stock::Quoter_Factory_var quoter_Factory_var = quoter_Factory_i_ptr_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Stringify the object reference and print it out. - exception_message = "While object_to_string"; - CORBA::String_var quoter_Factory_ior = - this->orb_manager_.orb()->object_to_string (quoter_Factory_var.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While activating the POA Manager"; - poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Print the IOR. - if (this->debug_level_ >= 2) - ACE_DEBUG ((LM_DEBUG, "Quoter Server: IOR is: <%s>\n", quoter_Factory_ior.in ())); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quote_Server::init - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception"); - ACE_RE_THROW; - } - ACE_ENDTRY; - - return this->init_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); -} - - -// Initialization of Naming Service and register IDL_Quoter Context -// and Quoter_factory object. - -int -Quoter_Server::init_naming_service (ACE_ENV_SINGLE_ARG_DECL) -{ - const char *exception_message = "Null Message"; - ACE_TRY - { - CORBA::ORB_ptr orb_ptr = TAO_ORB_Core_instance()->orb(); - - CORBA::Object_var naming_obj = - orb_ptr->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to resolve the Name Service.\n"), - -1); - - exception_message = "While narrowing naming context"; - namingContext_var_ = - CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::Name quoterContextName (1); - quoterContextName.length (1); - quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); - - exception_message = "While binding a new context"; - CosNaming::NamingContext_var quoterNameContext = - namingContext_var_->bind_new_context (quoterContextName ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - //Register the quoter_factory name with the IDL_quoter Naming - //Context... - CosNaming::Name quoterFactoryContextName (1); - quoterFactoryContextName.length (1); - quoterFactoryContextName[0].id = CORBA::string_dup ("Quoter_Factory"); - - exception_message = "While using factory _this"; - Stock::Quoter_Factory_var quoter_factory_var = quoter_Factory_i_ptr_->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - exception_message = "While binding factory"; - quoterNameContext->bind (quoterFactoryContextName, - quoter_factory_var.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "Quote_Server::init_naming_service - %s", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception"); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -int -Quoter_Server::run (ACE_ENV_SINGLE_ARG_DECL) -{ - if (this->debug_level_ >= 1) - ACE_DEBUG ((LM_DEBUG, - "\nQuoter Example: Quoter_Server is running\n")); - - orb_manager_.orb()->run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - return 0; -} - -Quoter_Server::~Quoter_Server (void) -{ - ACE_TRY_NEW_ENV - { - // Unbind quoter factory context and name. - CosNaming::Name factory_name (2); - factory_name.length (2); - factory_name[0].id = CORBA::string_dup ("IDL_Quoter"); - factory_name[1].id = CORBA::string_dup ("Quoter_Factory"); - if (!CORBA::is_nil (this->namingContext_var_.in ())) - this->namingContext_var_->unbind (factory_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - factory_name.length (1); - if (!CORBA::is_nil (this->namingContext_var_.in ())) - this->namingContext_var_->unbind (factory_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, - "Could not unbind Quoter Server from the Name Service\n")); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "~Quoter_Server"); - } - ACE_ENDTRY; - - delete [] this->argv_; -} - -int -main (int argc, char *argv[]) -{ - Quoter_Server quoter_server; - - ACE_TRY_NEW_ENV - { - int result = quoter_server.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result == -1) - return 1; - - quoter_server.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - return -1; - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - return -1; - } - ACE_ENDTRY; - return 0; -} diff --git a/TAO/examples/Quoter/server.h b/TAO/examples/Quoter/server.h deleted file mode 100644 index 26a0540be88..00000000000 --- a/TAO/examples/Quoter/server.h +++ /dev/null @@ -1,91 +0,0 @@ -// $Id$ -// -*- C++ -*- - -// ============================================================================ -// -// = LIBRARY -// TAO/examples/Quoter -// -// = FILENAME -// quoter_server.h -// -// = DESCRIPTION -// Implements the Quoter_Server class which handles the initialization of -// the quoter implementations. -// -// = AUTHORS -// Darrell Brunsch (brunsch@cs.wustl.edu) -// -// ============================================================================ - -#ifndef QUOTER_SERVER_H -#define QUOTER_SERVER_H - -#include "ace/Get_Opt.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Log_Msg.h" -#include "orbsvcs/CosNamingC.h" -#include "orbsvcs/Naming/Naming_Server.h" -#include "tao/Utils/ORB_Manager.h" -#include "Quoter_i.h" -#include "QuoterC.h" - -class Quoter_Server -{ - // =TITLE - // Defines a Quoter Server class that implements the functionality - // of a server process as an object. - // - // =DESCRIPTION - // The interface is quite simple. A server program has to call - // init to initialize the quoter_server's state and then call run - // to run the orb. -public: - - Quoter_Server (void); - // Default constructor - - ~Quoter_Server (void); - // Destructor - - int init (int argc, char *argv[] ACE_ENV_ARG_DECL); - // Initialize the Quoter_Server state - parsing arguments and ... - - int run (ACE_ENV_SINGLE_ARG_DECL); - // Run the server. - -private: - int parse_args (void); - // Parses the commandline arguments. - - int init_naming_service (ACE_ENV_SINGLE_ARG_DECL); - // Initializes the name server and registers cubit factory with the - // name server. - - int num_of_objs_; - // Number of quoter objects we export. - - CosNaming::NamingContext_var namingContext_var_; - // Naming Service context - - Quoter_Factory_i *quoter_Factory_i_ptr_; - // Instantiate the Quoter Factory - - TAO_ORB_Manager orb_manager_; - // The ORB manager. - - int argc_; - // Number of commandline arguments. - - char **argv_; - // commandline arguments. - - int debug_level_; - // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); -}; - -#endif /* QUOTER_SERVER_H */ |