From 7bd7fd7cfbd248b30263c23968542bcfb0113da5 Mon Sep 17 00:00:00 2001 From: mk1 Date: Wed, 15 Apr 1998 16:19:17 +0000 Subject: minor --- TAO/tests/Quoter/FactoryFinderImpl.cpp | 152 -------------------------------- TAO/tests/Quoter/FactoryFinderImpl.h | 42 --------- TAO/tests/Quoter/FactoryFinder_Impl.cpp | 152 ++++++++++++++++++++++++++++++++ TAO/tests/Quoter/FactoryFinder_Impl.h | 42 +++++++++ 4 files changed, 194 insertions(+), 194 deletions(-) delete mode 100644 TAO/tests/Quoter/FactoryFinderImpl.cpp delete mode 100644 TAO/tests/Quoter/FactoryFinderImpl.h create mode 100644 TAO/tests/Quoter/FactoryFinder_Impl.cpp create mode 100644 TAO/tests/Quoter/FactoryFinder_Impl.h diff --git a/TAO/tests/Quoter/FactoryFinderImpl.cpp b/TAO/tests/Quoter/FactoryFinderImpl.cpp deleted file mode 100644 index 84dc10bd95d..00000000000 --- a/TAO/tests/Quoter/FactoryFinderImpl.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinder_Impl.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 "ace/Get_Opt.h" -#include "tao/corba.h" -#include "FactoryFinder_Impl.h" -#include "QuoterC.h" - -static const char usage [] = -"[-? |\n[-O[RBport] ORB port number]]"; - -// Constructor -QuoterFactoryFinderImpl::QuoterFactoryFinderImpl (void) -{ -} - -// Destructor. -QuoterFactoryFinderImpl::~QuoterFactoryFinderImpl (void) -{ -} - - -CosLifeCycle::Factories * -QuoterFactoryFinderImpl::find_factories (const CosLifeCycle::Key &factory_key, - CORBA::Environment &_env_there) -{ - CORBA::Environment env_here; - - // fill in the name of the Quoter Factory - CosNaming::Name factoryName (1); // max = 1 - factoryName.length (1); - factoryName[0].id = CORBA::string_dup ("quoter_factory"); - // or - - // 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"); - - 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 (), - env_here); - - // see if there is an exception, if yes then throw the NoFactory exception - if (env_here.exception () != 0) // throw a NoFactory exception - { - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - // Get the IDL_Quoter naming context. - CosNaming::Name quoterContextName (1); // max = 1 - quoterContextName.length (1); - quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); - - CORBA::Object_var quoterNamingObj_var = - namingContext_var->resolve (quoterContextName, env_here); - - // see if there is an exception, if yes then throw the NoFactory exception - if (env_here.exception () != 0) // throw a NoFactory exception - { - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - CosNaming::NamingContext_var quoterNamingContext_var = - CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (), - env_here); - - // see if there is an exception, if yes then throw the NoFactory exception - if (env_here.exception () != 0) // throw a NoFactory exception - { - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - - // ** now a proper reference to the quoter naming context is available - - // 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 - CORBA::Object_var quoterFactoryObject_var = - quoterNamingContext_var->resolve (factoryName, env_here); - - // see if there is an exception, if yes then throw the NoFactory exception - if (env_here.exception () != 0) // throw a NoFactory exception - { - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - // 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 - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - else { - - // create a sequence of factories object - CosLifeCycle::Factories *factories_ptr = new CosLifeCycle::Factories (1); - - // See if there is an exception, if yes then throw the NoFactory - // exception. - if (env_here.exception () != 0) - { - // Throw a NoFactory exception. - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - // 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. - { - _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); - return 0; - } - - // insert the object reference - (*factories_ptr)[0] = CORBA::Object::_duplicate (quoterFactoryObject_var.ptr()); - - ACE_DEBUG ((LM_DEBUG,"Have reference to a Quoter Factory.\n")); - return factories_ptr; - } -} diff --git a/TAO/tests/Quoter/FactoryFinderImpl.h b/TAO/tests/Quoter/FactoryFinderImpl.h deleted file mode 100644 index 1081278372b..00000000000 --- a/TAO/tests/Quoter/FactoryFinderImpl.h +++ /dev/null @@ -1,42 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = FILENAME -// FactoryFinderImpl.h -// -// = DESCRIPTION -// Factory Finder Implementation for the Quoter example -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// ============================================================================ - -#include "quoterS.h" - -#if !defined (QUOTER_FACTORY_FINDER_IMPL_H) -#define QUOTER_FACTORY_FINDER_IMPL_H - -class QuoterFactoryFinderImpl : public POA_Stock::QuoterFactoryFinder -{ - // = TILE - // A CosLifeCycle conforming Factory Finder for the Quoter - // example. It uses the Naming Service to find a fitting factory. - -public: - QuoterFactoryFinderImpl (void); - ~QuoterFactoryFinderImpl (void); - - virtual CosLifeCycle::Factories * find_factories (const CosLifeCycle::Key & factory_key, - CORBA::Environment &_tao_environment); - // Returns a squence 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: - // CosNaming::NamingContext_var quoterNamingContext_var_; - // Hold a reference to the Quoter example naming context. -}; - -#endif /* QUOTER_FACTORY_FINDER_IMPL_H */ diff --git a/TAO/tests/Quoter/FactoryFinder_Impl.cpp b/TAO/tests/Quoter/FactoryFinder_Impl.cpp new file mode 100644 index 00000000000..40783931001 --- /dev/null +++ b/TAO/tests/Quoter/FactoryFinder_Impl.cpp @@ -0,0 +1,152 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// FactoryFinder_Impl.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 "ace/Get_Opt.h" +#include "tao/corba.h" +#include "FactoryFinderImpl.h" +#include "QuoterC.h" + +static const char usage [] = +"[-? |\n[-O[RBport] ORB port number]]"; + +// Constructor +QuoterFactoryFinderImpl::QuoterFactoryFinderImpl (void) +{ +} + +// Destructor. +QuoterFactoryFinderImpl::~QuoterFactoryFinderImpl (void) +{ +} + + +CosLifeCycle::Factories * +QuoterFactoryFinderImpl::find_factories (const CosLifeCycle::Key &factory_key, + CORBA::Environment &_env_there) +{ + CORBA::Environment env_here; + + // fill in the name of the Quoter Factory + CosNaming::Name factoryName (1); // max = 1 + factoryName.length (1); + factoryName[0].id = CORBA::string_dup ("quoter_factory"); + // or + + // 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"); + + 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 (), + env_here); + + // see if there is an exception, if yes then throw the NoFactory exception + if (env_here.exception () != 0) // throw a NoFactory exception + { + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + // Get the IDL_Quoter naming context. + CosNaming::Name quoterContextName (1); // max = 1 + quoterContextName.length (1); + quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter"); + + CORBA::Object_var quoterNamingObj_var = + namingContext_var->resolve (quoterContextName, env_here); + + // see if there is an exception, if yes then throw the NoFactory exception + if (env_here.exception () != 0) // throw a NoFactory exception + { + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + CosNaming::NamingContext_var quoterNamingContext_var = + CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (), + env_here); + + // see if there is an exception, if yes then throw the NoFactory exception + if (env_here.exception () != 0) // throw a NoFactory exception + { + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + + // ** now a proper reference to the quoter naming context is available + + // 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 + CORBA::Object_var quoterFactoryObject_var = + quoterNamingContext_var->resolve (factoryName, env_here); + + // see if there is an exception, if yes then throw the NoFactory exception + if (env_here.exception () != 0) // throw a NoFactory exception + { + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + // 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 + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + else { + + // create a sequence of factories object + CosLifeCycle::Factories *factories_ptr = new CosLifeCycle::Factories (1); + + // See if there is an exception, if yes then throw the NoFactory + // exception. + if (env_here.exception () != 0) + { + // Throw a NoFactory exception. + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + // 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. + { + _env_there.exception (new CosLifeCycle::NoFactory (factory_key)); + return 0; + } + + // insert the object reference + (*factories_ptr)[0] = CORBA::Object::_duplicate (quoterFactoryObject_var.ptr()); + + ACE_DEBUG ((LM_DEBUG,"Have reference to a Quoter Factory.\n")); + return factories_ptr; + } +} diff --git a/TAO/tests/Quoter/FactoryFinder_Impl.h b/TAO/tests/Quoter/FactoryFinder_Impl.h new file mode 100644 index 00000000000..61b1118f747 --- /dev/null +++ b/TAO/tests/Quoter/FactoryFinder_Impl.h @@ -0,0 +1,42 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// FactoryFinder_Impl.h +// +// = DESCRIPTION +// Factory Finder Implementation for the Quoter example +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// ============================================================================ + +#include "quoterS.h" + +#if !defined (QUOTER_FACTORY_FINDER_IMPL_H) +#define QUOTER_FACTORY_FINDER_IMPL_H + +class QuoterFactoryFinderImpl : public POA_Stock::QuoterFactoryFinder +{ + // = TILE + // A CosLifeCycle conforming Factory Finder for the Quoter + // example. It uses the Naming Service to find a fitting factory. + +public: + QuoterFactoryFinderImpl (void); + ~QuoterFactoryFinderImpl (void); + + virtual CosLifeCycle::Factories * find_factories (const CosLifeCycle::Key & factory_key, + CORBA::Environment &_tao_environment); + // Returns a squence 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: + // CosNaming::NamingContext_var quoterNamingContext_var_; + // Hold a reference to the Quoter example naming context. +}; + +#endif /* QUOTER_FACTORY_FINDER_IMPL_H */ -- cgit v1.2.1