diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-21 20:18:19 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-21 20:18:19 +0000 |
commit | ed6ef1f8d4f727a0b79e688d2089912794a1c05b (patch) | |
tree | 53c22539dbfa73758ff9253d35e9cb11db90374a | |
parent | 1bb5dec15cf0dffad146eded28b72e0b2bae4a38 (diff) | |
download | ATCD-ed6ef1f8d4f727a0b79e688d2089912794a1c05b.tar.gz |
ChangeLogTag:Thu Oct 21 14:55:02 1999 Darrell Brunsch <brunsch@cs.wustl.edu>
20 files changed, 441 insertions, 327 deletions
diff --git a/TAO/examples/Quoter/Factory_Finder.cpp b/TAO/examples/Quoter/Factory_Finder.cpp index 319e558116b..05f6acada8d 100644 --- a/TAO/examples/Quoter/Factory_Finder.cpp +++ b/TAO/examples/Quoter/Factory_Finder.cpp @@ -19,9 +19,8 @@ ACE_RCSID(Quoter, Factory_Finder, "$Id$") -static const char usage [] = "[-? |\n[-O[RBport] ORB port number]]"; - Quoter_Factory_Finder_Server::Quoter_Factory_Finder_Server (void) +: debug_level_ (1) { // Nothing } @@ -66,6 +65,12 @@ Quoter_Factory_Finder_Server::init (int argc, -1); ACE_TRY_CHECK; + // Activate the POA manager + exception_message = "While activating the POA manager"; + if (this->orb_manager_.activate_poa_manager (ACE_TRY_ENV) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activate_poa_manager"), -1); + ACE_TRY_CHECK; + // Copy them, because parse_args expects them there. this->argc_ = argc; this->argv_ = argv; @@ -74,7 +79,7 @@ Quoter_Factory_Finder_Server::init (int argc, ACE_NEW_RETURN (this->quoter_Factory_Finder_i_ptr_, - Quoter_Factory_Finder_i(), + Quoter_Factory_Finder_i(this->debug_level_), -1); // Activate the object. @@ -84,13 +89,13 @@ Quoter_Factory_Finder_Server::init (int argc, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "The IOR is: <%s>\n", - str.in ())); + // 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 - - ACE_DEBUG ((LM_DEBUG,"Trying to get a reference to the Naming Service.\n")); + 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"; @@ -125,8 +130,9 @@ Quoter_Factory_Finder_Server::init (int argc, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Have a proper reference to the Quoter Naming Context.\n")); + 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. @@ -140,8 +146,9 @@ Quoter_Factory_Finder_Server::init (int argc, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Bound the Quoter Factory Finder to the Quoter Naming Context.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "Factory_Finder: Bound the Quoter Factory Finder to the Quoter Naming Context.\n")); } ACE_CATCHANY { @@ -159,6 +166,10 @@ Quoter_Factory_Finder_Server::run (CORBA::Environment &ACE_TRY_ENV) { ACE_UNUSED_ARG (ACE_TRY_ENV); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, + "\nQuoter Example: Quoter_Factory_Finder_Server is running\n")); + if (orb_manager_.orb()->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", @@ -173,28 +184,30 @@ Quoter_Factory_Finder_Server::run (CORBA::Environment &ACE_TRY_ENV) u_int Quoter_Factory_Finder_Server::parse_args (void) { - // We need the 'O' in get_opt () because we also want to have ORB - // parameters, they all start with 'O'. - ACE_Get_Opt get_opt (this->argc_, this->argv_, "O?"); + 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.optarg); + 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 %s\n", - this->argv_[0], usage)); - ACE_OS::exit (0); + "usage: %s" + " [-d] <debug level> - Set the debug level\n" + " [-?] - Prints this message\n" + "\n", + this->argv_[0])); + ACE_OS::exit (exit_code); break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%s: unknown arg, -%c\n" - "Usage: %s %s\n", - this->argv_[0], char (opt), - this->argv_[0], - usage), - 1); } return 0; } @@ -206,8 +219,6 @@ main (int argc, char *argv []) { Quoter_Factory_Finder_Server quoter_Factory_Finder_Server; - ACE_DEBUG ((LM_DEBUG, - "\n\tIDL_Quoter:Quoter_Factory_Finder \n \n")); ACE_TRY_NEW_ENV { if (quoter_Factory_Finder_Server.init (argc,argv,ACE_TRY_ENV) == -1) diff --git a/TAO/examples/Quoter/Factory_Finder.h b/TAO/examples/Quoter/Factory_Finder.h index b2ec79f92f9..80103767307 100644 --- a/TAO/examples/Quoter/Factory_Finder.h +++ b/TAO/examples/Quoter/Factory_Finder.h @@ -61,6 +61,9 @@ private: 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 index bc122b3bb28..9f01843fddd 100644 --- a/TAO/examples/Quoter/Factory_Finder_i.cpp +++ b/TAO/examples/Quoter/Factory_Finder_i.cpp @@ -22,7 +22,8 @@ ACE_RCSID(Quoter, Factory_Finder_i, "$Id$") // Constructor -Quoter_Factory_Finder_i::Quoter_Factory_Finder_i (void) +Quoter_Factory_Finder_i::Quoter_Factory_Finder_i (int debug_level) +: debug_level_ (debug_level) { // Nothing } @@ -92,8 +93,9 @@ Quoter_Factory_Finder_i::find_factories (const CosLifeCycle::Key &factory_key, // insert the object reference (*factories_ptr)[0] = CORBA::Object::_duplicate (quoterFactoryObject_var.ptr()); - ACE_DEBUG ((LM_DEBUG, - "Have reference to a Quoter Factory.\n")); + if (this->debug_level_ > 1) + ACE_DEBUG ((LM_DEBUG, + "Factory Finder: Have reference to a Quoter Factory.\n")); } ACE_CATCHANY { diff --git a/TAO/examples/Quoter/Factory_Finder_i.h b/TAO/examples/Quoter/Factory_Finder_i.h index 3852336c793..81bf7dad2c1 100644 --- a/TAO/examples/Quoter/Factory_Finder_i.h +++ b/TAO/examples/Quoter/Factory_Finder_i.h @@ -25,7 +25,7 @@ class Quoter_Factory_Finder_i : public POA_Stock::Quoter_Factory_Finder // example. It uses the Naming Service to find a fitting factory. public: - Quoter_Factory_Finder_i (void); + Quoter_Factory_Finder_i (int debug_level = 1); ~Quoter_Factory_Finder_i (void); virtual CosLifeCycle::Factories * find_factories (const CosLifeCycle::Key &factory_key, @@ -35,6 +35,10 @@ public: // 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: + 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 index bf9f3a14844..baf2352115b 100644 --- a/TAO/examples/Quoter/Generic_Factory.cpp +++ b/TAO/examples/Quoter/Generic_Factory.cpp @@ -19,10 +19,9 @@ ACE_RCSID(Quoter, Generic_Factory, "$Id$") -static const char usage [] = "[-? |\n[-O[RBport] ORB port number]]"; - Quoter_Generic_Factory_Server::Quoter_Generic_Factory_Server (void) -: use_LifeCycle_Service_ (0) +: use_LifeCycle_Service_ (0), + debug_level_ (1) { } @@ -55,44 +54,49 @@ Quoter_Generic_Factory_Server::init (int argc, char *argv[], CORBA::Environment &ACE_TRY_ENV) { - if (this->orb_manager_.init (argc, - argv, - ACE_TRY_ENV) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "init"), - -1); - - // Copy them, because parse_args expects them there. - this->argc_ = argc; - this->argv_ = argv; + const char *exception_message = "Null Message"; - this->parse_args (); + ACE_TRY + { + // Initialize the ORB Manager + exception_message = "While initing the orb_manager"; + if (this->orb_manager_.init (argc, argv, ACE_TRY_ENV) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init"), -1); + ACE_TRY_CHECK; + // Activate the POA manager + exception_message = "While activating the POA manager"; + if (this->orb_manager_.activate_poa_manager (ACE_TRY_ENV) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activate_poa_manager"), -1); + ACE_TRY_CHECK; - ACE_NEW_RETURN (this->quoter_Generic_Factory_i_ptr_, - Quoter_Generic_Factory_i(), - -1); + // Copy them, because parse_args expects them there. + this->argc_ = argc; + this->argv_ = argv; + this->parse_args (); - // Activate the object. - CORBA::String_var str = - this->orb_manager_.activate (this->quoter_Generic_Factory_i_ptr_, - ACE_TRY_ENV); - ACE_CHECK_RETURN (-1); - // Failure while activating the Quoter Factory Finder object + 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_TRY_ENV); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "The IOR is: <%s>\n", - str.in ())); + // 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. - ACE_TRY - { - ACE_DEBUG ((LM_DEBUG, - "Trying to get a reference to the Naming Service.\n")); + // 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_TRY_CHECK; @@ -102,35 +106,41 @@ Quoter_Generic_Factory_Server::init (int argc, " (%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_TRY_ENV); + ACE_TRY_CHECK; if (CORBA::is_nil (namingContext_var.in ())) ACE_ERROR ((LM_ERROR, " (%P|%t) Unable get the Naming Service.\n")); - - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Have a proper reference to 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_TRY_ENV); ACE_TRY_CHECK; + exception_message = "While narrowing the Quoter"; quoterNamingContext_var_ = CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Have a proper reference to the Quoter Naming Context.\n")); + 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. @@ -138,19 +148,20 @@ Quoter_Generic_Factory_Server::init (int argc, quoter_Generic_Factory_Name.length (1); quoter_Generic_Factory_Name[0].id = CORBA::string_dup ("Quoter_Generic_Factory"); + exception_message = "While binding the Generic Factory"; quoterNamingContext_var_->bind (quoter_Generic_Factory_Name, this->quoter_Generic_Factory_i_ptr_->_this(ACE_TRY_ENV), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Bound the Quoter GenericFactory to the Quoter Naming Context.\n")); + + 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. - /* for now as long as the trading service is not ported to NT we skip this */ - if (this->use_LifeCycle_Service_) { // get the Quoter_Life_Cycle_Service @@ -158,34 +169,44 @@ Quoter_Generic_Factory_Server::init (int argc, 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_TRY_ENV); 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_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Have a proper reference to Life Cycle Service.\n")); + 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_TRY_ENV); + 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_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Registered the Quoter GenericFactory to the Life Cycle Service.\n")); + + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "Generic_Factory: Registered the Quoter GenericFactory to the Life Cycle Service.\n")); } } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Quoter_Generic_Factory_Server::init: Exception"); + 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; @@ -194,8 +215,14 @@ Quoter_Generic_Factory_Server::init (int argc, } int -Quoter_Generic_Factory_Server::run (CORBA::Environment& /*env*/) +Quoter_Generic_Factory_Server::run (CORBA::Environment &ACE_TRY_ENV) { + ACE_UNUSED_ARG (ACE_TRY_ENV); + + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, + "\nQuoter Example: Quoter_Generic_Factory_Server is running\n")); + if (orb_manager_.orb()->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", @@ -209,31 +236,34 @@ Quoter_Generic_Factory_Server::run (CORBA::Environment& /*env*/) u_int Quoter_Generic_Factory_Server::parse_args (void) { - // We need the 'O' in get_opt () because we also want to have ORB - // parameters, they all start with 'O'. - ACE_Get_Opt get_opt (this->argc_, this->argv_, "Ol?"); + 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 '?': - ACE_DEBUG ((LM_DEBUG, - "Usage: %s %s\n", - this->argv_[0], usage)); - ACE_OS::exit (0); + case 'd': // debug flag. + this->debug_level_ = ACE_OS::atoi (get_opt.optarg); break; case 'l': this->use_LifeCycle_Service_ = 1; break; default: - ACE_ERROR_RETURN ((LM_ERROR, - "%s: unknown arg, -%c\n" - "Usage: %s %s\n", - this->argv_[0], char (opt), - this->argv_[0], - usage), - 1); + 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; } @@ -245,8 +275,6 @@ main (int argc, char *argv []) { Quoter_Generic_Factory_Server quoter_Generic_Factory_Server; - ACE_DEBUG ((LM_DEBUG, - "\n\tIDL_Quoter: Quoter_Generic_Factory_Server \n\n")); ACE_TRY_NEW_ENV { if (quoter_Generic_Factory_Server.init (argc, diff --git a/TAO/examples/Quoter/Generic_Factory.h b/TAO/examples/Quoter/Generic_Factory.h index 0d614088019..a9f91a253c0 100644 --- a/TAO/examples/Quoter/Generic_Factory.h +++ b/TAO/examples/Quoter/Generic_Factory.h @@ -65,6 +65,10 @@ private: // 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 index d55c44252ab..b39ab5af983 100644 --- a/TAO/examples/Quoter/Generic_Factory_i.cpp +++ b/TAO/examples/Quoter/Generic_Factory_i.cpp @@ -21,7 +21,8 @@ ACE_RCSID(Quoter, Generic_Factory_i, "$Id$") // Constructor -Quoter_Generic_Factory_i::Quoter_Generic_Factory_i (void) +Quoter_Generic_Factory_i::Quoter_Generic_Factory_i (int debug_level) +: debug_level_ (debug_level) { } @@ -139,8 +140,8 @@ Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key, return CORBA::Object::_nil (); } - ACE_DEBUG ((LM_DEBUG, - "Factory reference OK.\n")); + 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 = @@ -148,8 +149,8 @@ Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Quoter Created\n")); + if (this->debug_level_ > 1) + ACE_DEBUG ((LM_DEBUG, "Generic_Factory: Quoter Created\n")); if (CORBA::is_nil (quoter_var.in ())) { @@ -158,8 +159,8 @@ Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key, return CORBA::Object::_nil (); } - ACE_DEBUG ((LM_DEBUG, - "Return a object reference to a new object.\n")); + if (this->debug_level_ > 1) + ACE_DEBUG ((LM_DEBUG, "Generic_Factory: Return an object reference to a new object.\n")); } ACE_CATCHANY diff --git a/TAO/examples/Quoter/Generic_Factory_i.h b/TAO/examples/Quoter/Generic_Factory_i.h index 94c153d21fb..f9066ee3a9e 100644 --- a/TAO/examples/Quoter/Generic_Factory_i.h +++ b/TAO/examples/Quoter/Generic_Factory_i.h @@ -26,7 +26,7 @@ class Quoter_Generic_Factory_i : public POA_Stock::Quoter_Generic_Factory // example. It uses the Naming Service to find a fitting factory. public: - Quoter_Generic_Factory_i (void); + Quoter_Generic_Factory_i (int debug_level = 1); ~Quoter_Generic_Factory_i (void); CORBA::Boolean supports (const CosLifeCycle::Key &factory_key, @@ -51,6 +51,8 @@ private: CORBA::Environment &); // 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/Quoter.dsw b/TAO/examples/Quoter/Quoter.dsw index d76f398199f..89a7b0af241 100644 --- a/TAO/examples/Quoter/Quoter.dsw +++ b/TAO/examples/Quoter/Quoter.dsw @@ -3,6 +3,18 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ###############################################################################
+Project: "LifeCycle_Service"=..\..\orbsvcs\LifeCycle_Service\LifeCycle_Service.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "Quoter Client"=.\client.dsp - Package Owner=<4>
Package=<5>
@@ -27,7 +39,7 @@ Package=<4> ###############################################################################
-Project: "Quoter Server"=.\server.dsp - Package Owner=<4>
+Project: "Quoter Generic Factory"=.\Generic_Factory.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -39,7 +51,7 @@ Package=<4> ###############################################################################
-Project: "QuoterGenericFactory"=.\Generic_Factory.dsp - Package Owner=<4>
+Project: "Quoter Server"=.\server.dsp - Package Owner=<4>
Package=<5>
{{{
diff --git a/TAO/examples/Quoter/client.cpp b/TAO/examples/Quoter/client.cpp index 6fef5b30fb5..95938a200cf 100644 --- a/TAO/examples/Quoter/client.cpp +++ b/TAO/examples/Quoter/client.cpp @@ -27,7 +27,8 @@ Quoter_Client::Quoter_Client (void) quoter_key_ (ACE_OS::strdup ("key0")), shutdown_ (0), quoter_var_ (Stock::Quoter::_nil ()), - useLifeCycleService_(0) // use the Generic Factory + useLifeCycleService_(0), // use the Generic Factory + debug_level_ (1) { // Nothing } @@ -37,17 +38,18 @@ Quoter_Client::Quoter_Client (void) int Quoter_Client::parse_args (void) { - ACE_Get_Opt get_opts (argc_, argv_, "n:dlx"); - int c; + ACE_Get_Opt get_opts (argc_, argv_, "n:d:lx"); + int opt; + int exit_code = 0; - while ((c = get_opts ()) != -1) - switch (c) + while ((opt = get_opts ()) != -1) + switch (opt) { case 'n': // multiple threads // ignore it, it was handled already break; - case 'd': // debug flag - TAO_debug_level++; + case 'd': // debug flag. + this->debug_level_ = ACE_OS::atoi (get_opts.optarg); break; case 'l': this->useLifeCycleService_ = 1; @@ -55,19 +57,22 @@ Quoter_Client::parse_args (void) case 'x': this->shutdown_ = 1; break; - case '?': default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s" - " [-m]" - " [-d]" - " [-l] # use the lifecycle service instead of the generic factory" - " [-x]" - " [-s]" - "\n", - this->argv_ [0]), - -1); - } + 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; @@ -76,6 +81,10 @@ Quoter_Client::parse_args (void) 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 { @@ -83,7 +92,8 @@ Quoter_Client::run (void) CORBA::Long q = this->quoter_var_->get_quote ("ACE Hardware", ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "ACE Hardware = %i\n", q)); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, "Quoter Client: ACE Hardware = %i\n", q)); // Copy the Quoter @@ -112,14 +122,15 @@ Quoter_Client::run (void) "Quoter_Client::run: Copied Quoter is nil!"), -1); - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Copied object.\n")); + 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_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Copied object: ACE Hardware = %i\n", q)); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, "Quoter Client: Copied object: ACE Hardware = %i\n", q)); // Move the Quoter @@ -131,14 +142,15 @@ Quoter_Client::run (void) // Caution, the object reference stays the same - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Moved object\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Quoter Client: Moved object\n")); exception_message = "While using get_quote () on moved object"; q = this->quoter_var_->get_quote ("ACE Hardware", ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Moved object: ACE Hardware = %i\n", q)); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, "Quoter Client: Moved object: ACE Hardware = %i\n", q)); } ACE_CATCHANY { @@ -182,16 +194,16 @@ Quoter_Client::init_naming_service (void) CosNaming::NamingContext::_narrow (naming_obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Have a proper reference to the Naming Service.\n")); + 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 (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Trying to resolve the Quoter Factory Finder!\n")); + 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 = @@ -199,8 +211,8 @@ Quoter_Client::init_naming_service (void) ACE_TRY_ENV); ACE_TRY_CHECK; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Resolved the Quoter Factory Finder!\n")); + 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_ = @@ -213,8 +225,8 @@ Quoter_Client::init_naming_service (void) " could not resolve quoter factory in Naming service <%s>\n"), -1); - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Have a proper reference to the Quoter Factory Finder.\n")); + 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 @@ -233,8 +245,8 @@ Quoter_Client::init_naming_service (void) factoryName[1].id = CORBA::string_dup ("Quoter_Generic_Factory"); } - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Trying to get a reference of a factory.\n")); + 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"; @@ -247,8 +259,8 @@ Quoter_Client::init_naming_service (void) "Did not get a Generic Quoter Factory.\n"), -1); - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Got a proper reference of a factory.\n")); + 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. @@ -273,8 +285,8 @@ Quoter_Client::init_naming_service (void) "Factory received is not valid.\n"), -1); - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Have a proper reference to the Quoter Factory.\n")); + 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) { @@ -321,8 +333,8 @@ Quoter_Client::init (int argc, char **argv) if (naming_result == -1) return naming_result; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Factory received OK\n")); + 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 @@ -346,8 +358,8 @@ Quoter_Client::init (int argc, char **argv) this->quoter_var_ = Stock::Quoter::_narrow (quoterObject_var.in(), ACE_TRY_ENV); ACE_TRY_CHECK; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Quoter Created\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Quoter Client: Quoter Created\n")); if (CORBA::is_nil (this->quoter_var_.in())) { @@ -374,8 +386,6 @@ main (int argc, char **argv) { ACE_Thread_Manager thr_mgr; - ACE_DEBUG ((LM_DEBUG,"\n\tQuoter: client\n\n")); - int i; int threads = 1; diff --git a/TAO/examples/Quoter/client.h b/TAO/examples/Quoter/client.h index e59ea061b85..7af1f955ced 100644 --- a/TAO/examples/Quoter/client.h +++ b/TAO/examples/Quoter/client.h @@ -90,6 +90,9 @@ private: 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> diff --git a/TAO/examples/Quoter/run_test.pl b/TAO/examples/Quoter/run_test.pl index 67e8218b981..33f065d2ffc 100755 --- a/TAO/examples/Quoter/run_test.pl +++ b/TAO/examples/Quoter/run_test.pl @@ -31,59 +31,61 @@ $debug = ""; $cm = ""; $sm = ""; $other = ""; -$c_conf = "client.conf"; -$s_conf = "server.conf"; +$c_conf = ""; #-ORBsvcconf client.conf"; +$s_conf = ""; #-ORBsvcconf server.conf"; + +# Programs that are run + +$name_server = "..$DIR_SEPARATOR..$DIR_SEPARATOR"."orbsvcs$DIR_SEPARATOR". + "Naming_Service$DIR_SEPARATOR"."Naming_Service$EXE_EXT"; +$lifecycle_server = "..$DIR_SEPARATOR..$DIR_SEPARATOR"."orbsvcs$DIR_SEPARATOR". + "LifeCycle_Service$DIR_SEPARATOR"."LifeCycle_Service$EXE_EXT"; +$quoter_server = $EXE_PREFIX."server$EXE_EXT"; +$factory_finder = $EXE_PREFIX."Factory_Finder$EXE_EXT"; +$generic_factory = $EXE_PREFIX."Generic_Factory$EXE_EXT"; +$quoter_client = $EXE_PREFIX."client$EXE_EXT"; sub name_server { my $args = "$other -o $nsiorfile"; - my $prog = "..$DIR_SEPARATOR..$DIR_SEPARATOR"."orbsvcs$DIR_SEPARATOR". - "Naming_Service$DIR_SEPARATOR". - "Naming_Service$EXE_EXT"; - - $NS = Process::Create ($prog, $args); + $NS = Process::Create ($name_server, $args); } sub lifecycle_server { - my $args = "$other -ORBInitRef NameService=file://$nsiorfile -ORBsvcconf svc.conf"; - my $prog = "..$DIR_SEPARATOR..$DIR_SEPARATOR"."orbsvcs$DIR_SEPARATOR". - "LifeCycle_Service$DIR_SEPARATOR". - "LifeCycle_Service$EXE_EXT"; - - $LC = Process::Create ($prog, $args); + my $args = "$other $debug -ORBInitRef NameService=file://$nsiorfile"; + $LC = Process::Create ($lifecycle_server, $args); } sub server { my $args = "$other $debug $sm ". - "-ORBInitRef NameService=file://$nsiorfile -ORBsvcconf $s_conf"; + "-ORBInitRef NameService=file://$nsiorfile $s_conf"; - $SV = Process::Create ("server$EXE_EXT", $args); + $SV = Process::Create ($quoter_server, $args); } sub factory_finder { - my $args = "$other -ORBInitRef NameService=file://$nsiorfile -ORBsvcconf svc.conf"; + my $args = "$other $debug -ORBInitRef NameService=file://$nsiorfile"; - $FF = Process::Create ("Factory_Finder".$EXE_EXT, $args); + $FF = Process::Create ($factory_finder, $args); } sub generic_factory { - my $args = "$other -l -ORBInitRef NameService=file://$nsiorfile -ORBsvcconf svc.conf"; + my $args = "$other -l $debug -ORBInitRef NameService=file://$nsiorfile"; - $GF = Process::Create ("Generic_Factory".$EXE_EXT, $args); + $GF = Process::Create ($generic_factory, $args); } sub client { - my $exe = $EXEPREFIX."client$EXE_EXT"; - my $args2 = "$other -l $debug $cm ". - "-ORBInitRef NameService=file://$nsiorfile -ORBsvcconf $c_conf"; + my $args = "$other -l $debug $cm ". + "-ORBInitRef NameService=file://$nsiorfile $c_conf"; for ($j = 0; $j < $n; $j++) { - $client_ = Process::Create($exe, $args2); + $client_ = Process::Create($quoter_client, $args); if ( $client_->TimedWait (60) ) { print STDERR "ERROR: a client has timedout\n"; $status = 1; @@ -101,13 +103,13 @@ for ($i = 0; $i <= $#ARGV; $i++) if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") { print "run_test [-n num] [-leave] [-onewin]". - "[-twowin] [-d] [-h] [-nt] [-cm] [-sm] [-ns|sv|ff|cl|gf]\n"; + "[-twowin] [-d level] [-h] [-nt] [-cm] [-sm] [-ns|sv|ff|cl|gf]\n"; print "\n"; print "-n num -- runs the client num times\n"; print "-leave -- leaves the servers running and their windows open\n"; print "-onewin -- keeps all tests in one window on NT\n"; print "-twowin -- put each test in a separate window on NT\n"; - print "-d -- runs each in debug mode\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"; @@ -130,7 +132,8 @@ for ($i = 0; $i <= $#ARGV; $i++) } if ($ARGV[$i] eq "-d") { - $debug = $debug." -d"; + $debug = $debug." -d $ARGV[$i + 1]"; + $i++; last SWITCH; } if ($ARGV[$i] eq "-cm") @@ -176,8 +179,8 @@ for ($i = 0; $i <= $#ARGV; $i++) if ($ARGV[$i] eq "-customconf") #secret flag from testall.pl { #use a different set of *.conf files - $c_conf = "c.conf"; - $s_conf = "s.conf"; + $c_conf = "-ORBsvcconf c.conf"; + $s_conf = "-ORBsvcconf s.conf"; last SWITCH; } if ($ARGV[$i] eq "-onewin") diff --git a/TAO/examples/Quoter/server.cpp b/TAO/examples/Quoter/server.cpp index dd78475d4e6..df96d85135d 100644 --- a/TAO/examples/Quoter/server.cpp +++ b/TAO/examples/Quoter/server.cpp @@ -19,21 +19,22 @@ ACE_RCSID(Quoter, server, "$Id$") Quoter_Server::Quoter_Server (void) : num_of_objs_ (1), - quoter_Factory_i_ptr_ (0) + quoter_Factory_i_ptr_ (0), + debug_level_ (1) { } int Quoter_Server::parse_args (void) { - ACE_Get_Opt get_opts (argc_, argv_, "dn:"); + ACE_Get_Opt get_opts (argc_, argv_, "d:n:"); int c; while ((c = get_opts ()) != -1) switch (c) { case 'd': // debug flag. - TAO_debug_level++; + this->debug_level_ = ACE_OS::atoi (get_opts.optarg); break; case 'n': // number of Quoter objects we export this->num_of_objs_ = ACE_OS::atoi (get_opts.optarg); @@ -42,7 +43,7 @@ Quoter_Server::parse_args (void) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s" - " [-d]" + " [-d] <debug level>" " [-n] <num of Quoter objects>" "\n", argv_ [0]), @@ -131,9 +132,9 @@ Quoter_Server::init (int argc, exception_message = "While activating the POA Manager"; poa_manager->activate (ACE_TRY_ENV); - ACE_DEBUG ((LM_DEBUG, - "The IOR is: <%s>\n", - quoter_Factory_ior.in ())); + // Print the IOR. + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Quoter Server: IOR is: <%s>\n", quoter_Factory_ior.in ())); } ACE_CATCHANY { @@ -212,6 +213,10 @@ Quoter_Server::run (CORBA::Environment &ACE_TRY_ENV) { ACE_UNUSED_ARG (ACE_TRY_ENV); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, + "\nQuoter Example: Quoter_Server is running\n")); + if (orb_manager_.orb()->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", @@ -247,7 +252,6 @@ Quoter_Server::~Quoter_Server (void) ACE_ENDTRY; delete [] this->argv_; - delete this->quoter_Factory_i_ptr_; } int @@ -255,9 +259,6 @@ main (int argc, char *argv[]) { Quoter_Server quoter_server; - ACE_DEBUG ((LM_DEBUG, - "\n\tQuoter:SERVER \n \n")); - ACE_TRY_NEW_ENV { if (quoter_server.init (argc, argv, ACE_TRY_ENV) == -1) diff --git a/TAO/examples/Quoter/server.h b/TAO/examples/Quoter/server.h index d8883bacf08..5e8ebd3a1bb 100644 --- a/TAO/examples/Quoter/server.h +++ b/TAO/examples/Quoter/server.h @@ -83,6 +83,9 @@ private: char **argv_; // commandline arguments. + + int debug_level_; + // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); }; #endif /* QUOTER_SERVER_H */ diff --git a/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.cpp b/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.cpp index 103fb35a510..0ce333c6610 100644 --- a/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.cpp +++ b/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.cpp @@ -26,13 +26,14 @@ ACE_RCSID(LifeCycle_Service, Factory_Trader, "$Id$") // This const char * is used for adding a new type to the service repository // the added types will be subclasses of this. -const char * Factory_Trader::GENERIC_FACTORY_INTERFACE_REPOSITORY_ID = "IDL:CosLifeCycle/GenericFactory:1.0"; +const char * Factory_Trader::GENERIC_FACTORY_INTERFACE_REPOSITORY_ID = "IDL:omg.org/CosLifeCycle/GenericFactory:1.0"; -Factory_Trader::Factory_Trader () +Factory_Trader::Factory_Trader (int debug_level) : trader_ptr_(0), trading_Components_ptr_ (0), - support_Attributes_ptr_(0) + support_Attributes_ptr_(0), + debug_level_ (debug_level) { ACE_TRY_NEW_ENV { @@ -54,7 +55,7 @@ Factory_Trader::Factory_Trader () ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Factory_Trader constructor: Failed adding a new type.\n"); + "LifeCycle Server: (Factory_Trader::Factory_Trader) Failed adding a new type.\n"); } ACE_ENDTRY; // @@ ACE_CHECK? No way to pass back any exceptions. @@ -96,7 +97,7 @@ Factory_Trader::add_type () CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq superTypeSeq; // Add the new type - this->repository_.add_type (CORBA::string_dup("Factory"), + this->repository_.add_type (CORBA::string_dup("GenericFactory"), GENERIC_FACTORY_INTERFACE_REPOSITORY_ID, propStructSeq, superTypeSeq, @@ -106,7 +107,7 @@ Factory_Trader::add_type () ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Factory_Trader::init.\n"); + "LifeCycle Server: (Factory_Trader::init).\n"); } ACE_ENDTRY; // @@ ACE_CHECK @@ -115,17 +116,18 @@ Factory_Trader::add_type () void Factory_Trader::_cxx_export (const char * name, - const char * location, - const char * description, - const CORBA::Object_ptr object_ptr) + const char * location, + const char * description, + const CORBA::Object_ptr object_ptr) { ACE_TRY_NEW_ENV { if (CORBA::is_nil(object_ptr)) - { - ACE_DEBUG ((LM_DEBUG,"Factory_Trader::export: Object pointer is nil, cannot export!\n")); - return; - } + { + ACE_ERROR ((LM_ERROR, "LifeCycle Server (Factory_Trader::export): " + "Object pointer is nil, cannot export!\n")); + return; + } CosTrading::PropertySeq propertySeq(3); propertySeq.length (3); @@ -142,7 +144,7 @@ Factory_Trader::_cxx_export (const char * name, // invoke the export method on the Register interface of the Trading Service register_ptr->_cxx_export (CORBA::Object::_duplicate (object_ptr), - CORBA::string_dup("Factory"), + CORBA::string_dup("GenericFactory"), propertySeq, ACE_TRY_ENV); @@ -151,7 +153,8 @@ Factory_Trader::_cxx_export (const char * name, ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Factory_Trader::export: Failed to export factory.\n"); + "LifeCycle Server (Factory_Trader::export): " + "Failed to export factory.\n"); } ACE_ENDTRY; // @@ ACE_CHECK* @@ -179,15 +182,15 @@ Factory_Trader::query (const CORBA::String constraint) // this pointer is deleted when the trader_ptr is deleted // Invoke the query method on the Lookup Interface. - lookup_ptr->query ("Factory", // Type name - constraint, // Constraint, very important - "", // Preferences - policySeq, // Policy - specifiedProps, // Specified Properties - 1, // Number of wanted results - CosTrading::OfferSeq_out(offerSeq_ptr), // results - CosTrading::OfferIterator_out(offerIterator_ptr), // more results - CosTrading::PolicyNameSeq_out(policyNameSeq_ptr), // Policies + lookup_ptr->query ("GenericFactory", // Type name + constraint, // Constraint, very important + "", // Preferences + policySeq, // Policy + specifiedProps, // Specified Properties + 1, // Number of wanted results + CosTrading::OfferSeq_out(offerSeq_ptr), // results + CosTrading::OfferIterator_out(offerIterator_ptr), // more results + CosTrading::PolicyNameSeq_out(policyNameSeq_ptr), // Policies ACE_TRY_ENV); ACE_TRY_CHECK; @@ -196,27 +199,25 @@ Factory_Trader::query (const CORBA::String constraint) // Check if an offer was made if (offerSeq_ptr != 0) - { - // Insert the pointer into the out class - CosTrading::OfferSeq_var offerSeq_var(offerSeq_ptr); - - // We need at least one offer. - if (offerSeq_var->length() >= 1) - { - // now we are all set to read from the sequence the result - object_ptr = CORBA::Object::_duplicate (offerSeq_var[0].reference.in()); - - if (CORBA::is_nil (object_ptr)) - { - ACE_DEBUG ((LM_DEBUG,"Factory_Trader::query: Object reference is nil.\n")); - return 0; - } - else - ACE_DEBUG ((LM_DEBUG,"Factory_Trader::query: Received a proper object reference.\n")); - } - else - ACE_DEBUG ((LM_DEBUG,"Factory_Trader::query: OfferSequence.length is smaller than 1.\n")); - } + { + // Insert the pointer into the out class + CosTrading::OfferSeq_var offerSeq_var(offerSeq_ptr); + + // We need at least one offer. + if (offerSeq_var->length() >= 1) + { + // now we are all set to read from the sequence the result + object_ptr = CORBA::Object::_duplicate (offerSeq_var[0].reference.in()); + + if (CORBA::is_nil (object_ptr)) + ACE_ERROR_RETURN ((LM_ERROR,"Factory_Trader::query: Object reference is nil.\n"), 0); + else + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Factory_Trader::query: Received a proper object reference.\n")); + } + else + ACE_ERROR ((LM_ERROR, "Factory_Trader::query: OfferSequence.length is smaller than 1.\n")); + } return object_ptr; } ACE_CATCHANY diff --git a/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.h b/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.h index 9556cc43dc9..ff4284af91b 100644 --- a/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.h +++ b/TAO/orbsvcs/LifeCycle_Service/Factory_Trader.h @@ -26,7 +26,7 @@ class Factory_Trader { public: - Factory_Trader (); + Factory_Trader (int debug_level = 1); ~Factory_Trader (); void add_type (); @@ -47,6 +47,9 @@ private: TAO_Trader_Factory::TAO_TRADER *trader_ptr_; TAO_Trading_Components_i *trading_Components_ptr_; TAO_Support_Attributes_i *support_Attributes_ptr_; + + int debug_level_; + // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); }; #endif // FACTORY_TRADER_H diff --git a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp index c76406a16e5..34e3c9a5734 100644 --- a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp +++ b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp @@ -18,9 +18,8 @@ ACE_RCSID(LifeCycle_Service, LifeCycle_Service, "$Id$") -static const char usage [] = "[-? |\n[-O[RBport] ORB port number]]"; - Life_Cycle_Service_Server::Life_Cycle_Service_Server (void) +: debug_level_ (1) { } @@ -57,6 +56,11 @@ Life_Cycle_Service_Server::init (int argc, // @@ Oh well. This should actually come before "if". ACE_CHECK_RETURN (-1); + // Activate the POA manager + if (this->orb_manager_.activate_poa_manager (ACE_TRY_ENV) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activate_poa_manager"), -1); + + ACE_CHECK_RETURN (-1); // Copy them, because parse_args expects them there. this->argc_ = argc; this->argv_ = argv; @@ -65,7 +69,7 @@ Life_Cycle_Service_Server::init (int argc, ACE_NEW_RETURN (this->life_Cycle_Service_i_ptr_, - Life_Cycle_Service_i(), + Life_Cycle_Service_i(this->debug_level_), -1); // Activate the object. @@ -74,17 +78,15 @@ Life_Cycle_Service_Server::init (int argc, ACE_TRY_ENV); ACE_CHECK_RETURN (-1); - // Failure while activating the Factory Finder object - - ACE_DEBUG ((LM_DEBUG, - "The IOR is: <%s>\n", - str.in ())); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "LifeCycle_Service: IOR is: <%s>\n", str.in ())); // Register the LifeCycle Service with the Naming Service. ACE_TRY { - ACE_DEBUG ((LM_DEBUG, - "Trying to get a reference to the Naming Service.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "LifeCycle_Service: Trying to get a reference to the Naming Service.\n")); // Get the Naming Service object reference. CORBA::Object_var namingObj_var = @@ -93,7 +95,7 @@ Life_Cycle_Service_Server::init (int argc, if (CORBA::is_nil (namingObj_var.in ())) ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); + " LifeCycle_Service: Unable get the Naming Service.\n")); // Narrow the object reference to a Naming Context. namingContext_var_ = CosNaming::NamingContext::_narrow (namingObj_var.in (), @@ -103,10 +105,11 @@ Life_Cycle_Service_Server::init (int argc, if (CORBA::is_nil (namingContext_var_.in ())) ACE_ERROR ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n")); + "LifeCycle_Service: Unable get the Naming Service.\n")); - ACE_DEBUG ((LM_DEBUG, - "Have a proper reference to the Naming Service.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "LifeCycle_Service: Have a proper reference to the Naming Service.\n")); CosNaming::Name life_Cycle_Service_Name (1); life_Cycle_Service_Name.length (1); @@ -120,8 +123,9 @@ Life_Cycle_Service_Server::init (int argc, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Bound the LifeCycle Service to the Naming Context.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "LifeCycle_Service: Bound the LifeCycle Service to the Naming Context.\n")); } ACE_CATCHANY { @@ -134,8 +138,13 @@ Life_Cycle_Service_Server::init (int argc, int -Life_Cycle_Service_Server::run (CORBA::Environment &) +Life_Cycle_Service_Server::run (CORBA::Environment &ACE_TRY_ENV) { + ACE_UNUSED_ARG (ACE_TRY_ENV); + + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, + "\nLifeCycle Service: Life_Cycle_Service_Server is running\n")); if (orb_manager_.orb()->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, @@ -151,28 +160,30 @@ Life_Cycle_Service_Server::run (CORBA::Environment &) u_int Life_Cycle_Service_Server::parse_args (void) { - // We need the 'O' in get_opt () because we also want to have ORB - // parameters, they all start with 'O'. - ACE_Get_Opt get_opt (this->argc_, this->argv_, "O?"); + 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.optarg); + 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 %s\n", - this->argv_[0], usage)); - ACE_OS::exit (0); + "usage: %s" + " [-d] <debug level> - Set the debug level\n" + " [-?] - Prints this message\n" + "\n", + this->argv_[0])); + ACE_OS::exit (exit_code); break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%s: unknown arg, -%c\n" - "Usage: %s %s\n", - this->argv_[0], char (opt), - this->argv_[0], - usage), - 1); } return 0; } @@ -184,8 +195,6 @@ main (int argc, char *argv []) { Life_Cycle_Service_Server life_Cycle_Service_Server; - ACE_DEBUG ((LM_DEBUG, - "\n\tIDL_LifeCycleService: Life_Cycle_Service_Server \n\n")); ACE_TRY_NEW_ENV { int check = life_Cycle_Service_Server.init (argc, @@ -203,7 +212,7 @@ main (int argc, char *argv []) } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "main"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "LifeCycleService::main"); return -1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.h b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.h index 7e103fabe55..d120087a357 100644 --- a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.h +++ b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.h @@ -63,6 +63,9 @@ private: char **argv_; // commandline arguments. + + int debug_level_; + // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); }; #endif /* LIFECYCLE_SERVICE_H */ diff --git a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.cpp b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.cpp index 723b735a437..0f1eca080a0 100644 --- a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.cpp +++ b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.cpp @@ -21,8 +21,9 @@ ACE_RCSID(LifeCycle_Service, LifeCycle_Service_i, "$Id$") // Constructor -Life_Cycle_Service_i::Life_Cycle_Service_i (void) - : factory_trader_ptr_ (0) +Life_Cycle_Service_i::Life_Cycle_Service_i (int debug_level) + : factory_trader_ptr_ (0), + debug_level_ (debug_level) { } @@ -34,46 +35,53 @@ Life_Cycle_Service_i::~Life_Cycle_Service_i (void) CORBA::Boolean Life_Cycle_Service_i::supports (const CosLifeCycle::Key &, - CORBA::Environment &) - ACE_THROW_SPEC ((CORBA::SystemException)) + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) { return 0; } CORBA::Object_ptr Life_Cycle_Service_i::create_object (const CosLifeCycle::Key &factory_key, - const CosLifeCycle::Criteria &the_criteria, - CORBA::Environment &ACE_TRY_ENV) - ACE_THROW_SPEC ((CORBA::SystemException, - CosLifeCycle::NoFactory, - CosLifeCycle::InvalidCriteria, - CosLifeCycle::CannotMeetCriteria)) + const CosLifeCycle::Criteria &the_criteria, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + CosLifeCycle::NoFactory, + CosLifeCycle::InvalidCriteria, + CosLifeCycle::CannotMeetCriteria)) { - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: called.\n")); - // Exceptions are forwarded, not handled !! + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: called.\n")); + // Exceptions are forwarded, not handled !! if (factory_trader_ptr_ != 0) { Criteria_Evaluator criteria_Evaluator(the_criteria); - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: new evaluator.\n")); - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: getFilter will be called.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: new evaluator.\n")); + + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: getFilter will be called.\n")); CORBA::String filter = criteria_Evaluator.getFilter (ACE_TRY_ENV); ACE_CHECK_RETURN (0); - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: query(%s) will be called.\n",filter)); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: query(%s) will be called.\n",filter)); CORBA::Object_ptr genericFactoryObj_ptr = factory_trader_ptr_->query (filter); - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: query was called.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i:create_object: query was called.\n")); if (CORBA::is_nil (genericFactoryObj_ptr)) - ACE_ERROR_RETURN ((LM_ERROR, - "Life_Cycle_Service_i::create_object: Factory is nil!\n"), - 0); + ACE_ERROR_RETURN ((LM_ERROR, + "Life_Cycle_Service_i::create_object: Factory is nil!\n"), + 0); else // everyting is ok - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i::create_object: Object reference OK.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i::create_object: Object reference OK.\n")); // Now we have a proper reference to a Generic Factory // the create_object call will be forwarded to this factory @@ -83,7 +91,7 @@ Life_Cycle_Service_i::create_object (const CosLifeCycle::Key &factory_key, if (CORBA::is_nil (genericFactoryObj_ptr)) ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key), 0); else - { + { CosLifeCycle::GenericFactory_var genericFactory_var; ACE_TRY { @@ -96,37 +104,40 @@ Life_Cycle_Service_i::create_object (const CosLifeCycle::Key &factory_key, { // see if there is an exception, if yes then throw the // NoFactory exception throw a NoFactory exception - ACE_TRY_THROW (CosLifeCycle::NoFactory (factory_key)); - } + ACE_TRY_THROW (CosLifeCycle::NoFactory (factory_key)); + } ACE_ENDTRY; ACE_CHECK_RETURN (0); - if (CORBA::is_nil (genericFactory_var.in())) - ACE_ERROR_RETURN ((LM_ERROR, - "Life_Cycle_Service_i::create_object: Invalid Generic Factory.\n"), - 0); + if (CORBA::is_nil (genericFactory_var.in())) + ACE_ERROR_RETURN ((LM_ERROR, + "Life_Cycle_Service_i::create_object: Invalid Generic Factory.\n"), + 0); - ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i::create_object: Generic Factory reference OK.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, "Life_Cycle_Service_i::create_object: Generic Factory reference OK.\n")); - // Now retrieve the Object obj ref corresponding to the key. - CORBA::Object_var object_var = genericFactory_var->create_object (factory_key, - the_criteria, + // Now retrieve the Object obj ref corresponding to the key. + CORBA::Object_var object_var = genericFactory_var->create_object (factory_key, + the_criteria, ACE_TRY_ENV); ACE_CHECK_RETURN (0); - ACE_DEBUG ((LM_DEBUG, - "Life_Cycle_Service_i::create_object: Forwarded request.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "Life_Cycle_Service_i::create_object: Forwarded request.\n")); - if (CORBA::is_nil (object_var.in())) - ACE_ERROR_RETURN ((LM_ERROR, - "Life_Cycle_Service_i::create_object: Null object refeference returned by factory.\n"), - 0); + if (CORBA::is_nil (object_var.in())) + ACE_ERROR_RETURN ((LM_ERROR, + "Life_Cycle_Service_i::create_object: Null object refeference returned by factory.\n"), + 0); - ACE_DEBUG ((LM_DEBUG, - "Life_Cycle_Service_i::create_object: Return a object reference to a new object.\n")); + if (this->debug_level_ >= 2) + ACE_DEBUG ((LM_DEBUG, + "Life_Cycle_Service_i::create_object: Return a object reference to a new object.\n")); - return CORBA::Object::_duplicate (object_var.in()); - } + return CORBA::Object::_duplicate (object_var.in()); + } } else { @@ -136,28 +147,25 @@ Life_Cycle_Service_i::create_object (const CosLifeCycle::Key &factory_key, void Life_Cycle_Service_i::register_factory (const char * name, - const char * location, - const char * description, - CORBA::Object_ptr object, - CORBA::Environment &) - ACE_THROW_SPEC (( CORBA::SystemException)) + const char * location, + const char * description, + CORBA::Object_ptr object, + CORBA::Environment &) + ACE_THROW_SPEC (( CORBA::SystemException)) { - if (factory_trader_ptr_ == 0) - { - ACE_NEW (factory_trader_ptr_, Factory_Trader()); - } + ACE_NEW (factory_trader_ptr_, Factory_Trader(this->debug_level_)); // we have an proper reference to the Factory Trader // Just forward the call to the factory trader // Exceptions are not handled here, they are returned factory_trader_ptr_->_cxx_export (name, location, description, object); - ACE_DEBUG ((LM_DEBUG, "Registered a factory with:\n" - " name: %s\n" - " location: %s\n" - " description: %s\n", - name, location, description)); + if (this->debug_level_ >= 1) + ACE_DEBUG ((LM_DEBUG, "LifeCycle Server: Registered %s\n" + " Location: %s\n" + " Description: %s\n", + name, location, description)); } diff --git a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.h b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.h index 0e1a1c971bd..734ce9cbce4 100644 --- a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.h +++ b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service_i.h @@ -26,7 +26,7 @@ class Life_Cycle_Service_i : public POA_LifeCycleService::Life_Cycle_Service // A CosLifeCycle conforming Generic Factory. public: - Life_Cycle_Service_i (void); + Life_Cycle_Service_i (int debug_level = 1); ~Life_Cycle_Service_i (void); CORBA::Boolean supports (const CosLifeCycle::Key &factory_key, @@ -57,6 +57,9 @@ public: private: Factory_Trader *factory_trader_ptr_; + + int debug_level_; + // debug level (0 = quiet, 1 = default, informative, 2+ = noisy); }; #endif /* LIFECYCLE_SERVICE_IMPL_H */ |