diff options
author | jeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-04-26 21:21:54 +0000 |
---|---|---|
committer | jeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-04-26 21:21:54 +0000 |
commit | 1eb32850ac74670c4baf84f7113119e596016e60 (patch) | |
tree | a9b9968661496861e290f57b51d11264f75c299f /TAO/tao | |
parent | b9a9a05f27a7afd4b57329b9409385f9bff0a754 (diff) | |
download | ATCD-1eb32850ac74670c4baf84f7113119e596016e60.tar.gz |
ChangeLogTag: Wed Apr 26 20:21:49 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_i.cpp | 5 | ||||
-rw-r--r-- | TAO/tao/Codeset/Codeset_Manager_i.h | 10 | ||||
-rw-r--r-- | TAO/tao/DLL_Parser.cpp | 6 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 64 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 328 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 7 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.i | 40 | ||||
-rw-r--r-- | TAO/tao/PI/ORBInitializer_Registry_Impl.cpp | 65 | ||||
-rw-r--r-- | TAO/tao/PI/ORBInitializer_Registry_Impl.h | 11 | ||||
-rw-r--r-- | TAO/tao/PI/PI.cpp | 58 | ||||
-rw-r--r-- | TAO/tao/PI/PI.h | 16 | ||||
-rw-r--r-- | TAO/tao/PI/PolicyFactory_Loader.cpp | 9 | ||||
-rw-r--r-- | TAO/tao/PI/PolicyFactory_Loader.h | 6 | ||||
-rw-r--r-- | TAO/tao/Parser_Registry.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Root_POA.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/TAO_Internal.cpp | 632 | ||||
-rw-r--r-- | TAO/tao/TAO_Internal.h | 21 | ||||
-rw-r--r-- | TAO/tao/default_resource.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/default_resource.h | 7 |
20 files changed, 838 insertions, 472 deletions
diff --git a/TAO/tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.cpp b/TAO/tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.cpp index 71aa9aa9b8c..9e87aaf73e6 100644 --- a/TAO/tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.cpp +++ b/TAO/tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.cpp @@ -86,7 +86,7 @@ TAO::CSD::TP_Strategy_Factory::init (int argc, arg_remainder.substr (pos + 1, arg.length () - pos); // Case-insensitive string comparison. - if (ACE_OS::strcasecmp (off_str.c_str(), + if (ACE_OS::strcasecmp (ACE_TEXT_CHAR_TO_TCHAR (off_str.c_str()), ACE_TEXT("OFF")) == 0) { serialize_servants = false; diff --git a/TAO/tao/Codeset/Codeset_Manager_i.cpp b/TAO/tao/Codeset/Codeset_Manager_i.cpp index 25f8d360848..98664b6f60e 100644 --- a/TAO/tao/Codeset/Codeset_Manager_i.cpp +++ b/TAO/tao/Codeset/Codeset_Manager_i.cpp @@ -62,7 +62,7 @@ TAO_Codeset_Manager_i::default_char_codeset = TAO_DEFAULT_CHAR_CODESET_ID; CONV_FRAME::CodeSetId TAO_Codeset_Manager_i::default_wchar_codeset = TAO_DEFAULT_WCHAR_CODESET_ID; -TAO_Codeset_Manager_i::TAO_Codeset_Manager_i () +TAO_Codeset_Manager_i::TAO_Codeset_Manager_i (void) : codeset_info_ (), char_descriptor_ (), wchar_descriptor_ () @@ -72,9 +72,10 @@ TAO_Codeset_Manager_i::TAO_Codeset_Manager_i () wchar_descriptor_.ncs(TAO_Codeset_Manager_i::default_wchar_codeset); wchar_descriptor_.add_translator (ACE_TEXT ("UTF16_BOM_Factory")); + } -TAO_Codeset_Manager_i::~TAO_Codeset_Manager_i () +TAO_Codeset_Manager_i::~TAO_Codeset_Manager_i (void) { } diff --git a/TAO/tao/Codeset/Codeset_Manager_i.h b/TAO/tao/Codeset/Codeset_Manager_i.h index f5ca8491ca3..a9167804b1c 100644 --- a/TAO/tao/Codeset/Codeset_Manager_i.h +++ b/TAO/tao/Codeset/Codeset_Manager_i.h @@ -19,15 +19,15 @@ #include "tao/CONV_FRAMEC.h" #include "tao/Codeset_Manager.h" +#include "tao/Codeset/codeset_export.h" +#include "tao/Codeset/Codeset_Descriptor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Unbounded_Set.h" -#include "tao/Codeset/codeset_export.h" -#include "tao/Codeset/Codeset_Descriptor.h" - +#include "ace/Dynamic_Service_Dependency.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -70,8 +70,8 @@ public: /// to provide a non-compliant default wchar codeset may do so. static CONV_FRAME::CodeSetId default_wchar_codeset; - TAO_Codeset_Manager_i (); - ~TAO_Codeset_Manager_i (); + TAO_Codeset_Manager_i (void); + ~TAO_Codeset_Manager_i (void); /// Called by an object of TAO_Acceptor to set NCS and CCS values /// for Char/Wchar in to the Object Reference. diff --git a/TAO/tao/DLL_Parser.cpp b/TAO/tao/DLL_Parser.cpp index 753ae4496d7..87fb45d897f 100644 --- a/TAO/tao/DLL_Parser.cpp +++ b/TAO/tao/DLL_Parser.cpp @@ -6,6 +6,7 @@ #include "tao/Environment.h" #include "tao/ORB_Constants.h" #include "tao/SystemException.h" +#include "tao/ORB_Core.h" #include "ace/Dynamic_Service.h" #include "ace/Log_Msg.h" @@ -44,8 +45,11 @@ TAO_DLL_Parser::parse_string (const char *ior, const char *name = ior + sizeof (::dll_prefix) - 1; + TAO_ORB_Core *oc = orb->orb_core (); + TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance (name); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (oc->configuration(), name); if (loader == 0) { diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 85b04ebe58c..e25baaaa44a 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -36,6 +36,7 @@ ACE_RCSID (tao, #endif /* ! __ACE_INLINE__ */ #include "ace/Dynamic_Service.h" +#include "ace/Service_Config.h" #include "ace/Arg_Shifter.h" #include "ace/Reactor.h" #include "ace/Argv_Type_Converter.h" @@ -188,7 +189,7 @@ CORBA::ORB::destroy (ACE_ENV_SINGLE_ARG_DECL) if (TAO_debug_level > 2) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("CORBA::ORB::destroy() has been called on ORB <%s>.\n"), + ACE_TEXT ("CORBA::ORB::destroy() called on ORB <%s>.\n"), ACE_TEXT_CHAR_TO_TCHAR (this->orb_core ()->orbid ()))); } @@ -1074,7 +1075,8 @@ CORBA::ORB::resolve_initial_references (const char *name, } else if (ACE_OS::strcmp (name, TAO_OBJID_POACURRENT) == 0) { - result = this->orb_core ()->resolve_poa_current (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_poa_current + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } else if (ACE_OS::strcmp (name, TAO_OBJID_POLICYMANAGER) == 0) @@ -1087,33 +1089,39 @@ CORBA::ORB::resolve_initial_references (const char *name, } else if (ACE_OS::strcmp (name, TAO_OBJID_IORMANIPULATION) == 0) { - result = this->orb_core ()->resolve_ior_manipulation (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_ior_manipulation + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } else if (ACE_OS::strcmp (name, TAO_OBJID_IORTABLE) == 0) { - result = this->orb_core ()->resolve_ior_table (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_ior_table + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } else if (ACE_OS::strcmp (name, TAO_OBJID_DYNANYFACTORY) == 0) { - result = this->orb_core ()->resolve_dynanyfactory (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_dynanyfactory + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } else if (ACE_OS::strcmp (name, TAO_OBJID_TYPECODEFACTORY) == 0) { - result = this->orb_core ()->resolve_typecodefactory (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_typecodefactory + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } else if (ACE_OS::strcmp (name, TAO_OBJID_CODECFACTORY) == 0) { - result = this->orb_core ()->resolve_codecfactory (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_codecfactory + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } #if TAO_HAS_INTERCEPTORS == 1 else if (ACE_OS::strcmp (name, TAO_OBJID_PICurrent) == 0) { - result = this->orb_core ()->resolve_picurrent (ACE_ENV_SINGLE_ARG_PARAMETER); + result = this->orb_core ()->resolve_picurrent + (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); } #endif @@ -1151,7 +1159,7 @@ CORBA::ORB::resolve_initial_references (const char *name, // Look for an environment variable called "<name>IOR". // CORBA::String_var ior_env_var_name = - CORBA::string_alloc (static_cast <CORBA::ULong> (ACE_OS::strlen (name) + 3)); + CORBA::string_alloc (static_cast<CORBA::ULong> (ACE_OS::strlen (name) + 3)); ACE_OS::strcpy (ior_env_var_name.inout (), name); @@ -1327,15 +1335,6 @@ CORBA::ORB_init (int &argc, char *argv[], const char *orb_name) { - // Make sure TAO's singleton manager is initialized. - // - // We need to initialize before TAO_default_environment() is called - // since that call instantiates a TAO_TSS_Singleton. - if (TAO_Singleton_Manager::instance ()->init () == -1) - { - return CORBA::ORB::_nil (); - } - return CORBA::ORB_init (argc, argv, orb_name, @@ -1366,6 +1365,8 @@ CORBA::ORB_init (int &argc, CORBA::ORB::_nil ())); // Make sure TAO's singleton manager is initialized. + // We need to initialize before TAO_default_environment() is called + // since that call instantiates a TAO_TSS_Singleton. if (TAO_Singleton_Manager::instance ()->init () == -1) { return CORBA::ORB::_nil (); @@ -1401,6 +1402,8 @@ CORBA::ORB_init (int &argc, CORBA::ORB::_nil ()); } + + if (orbid_string.length () == 0) { ACE_Arg_Shifter arg_shifter (command_line.get_argc (), @@ -1469,10 +1472,33 @@ CORBA::ORB_init (int &argc, oc.reset (tmp); } + + // Having the ORB's default static services be shared among all ORBs + // is tempting from the point of view of reducing the dynamic + // footprint. However, if the ORB in a DLL and the rest of that + // application most likely neither cares, nor wishes to know about + // them. Furthermore, if the ORB DLL gets unloaded, the static + // services it had registered globaly will no longer be accesible, + // which will have disastrous consequences at the process + // shutdown. Hence, the ACE_Service_Config_Guard ensures that for + // the current thread, any references to the global + // ACE_Service_Config will be forwarded to the ORB's. + + // Making sure the initialization process in the current thread uses + // the correct service repository (ours), instead of the global one. + ACE_Service_Config_Guard scg (oc->configuration ()); + + /* + * Currently I choose to make the ORB an owner of its configuration, + * which in general is not quite correct because it is very common ORBs to + * need to share the same configuration. + */ + // Initialize the Service Configurator. This must occur before the // ORBInitializer::pre_init() method is invoked on each registered // ORB initializer. - int result = TAO::ORB::open_services (command_line.get_argc (), + int result = TAO::ORB::open_services (oc->configuration (), + command_line.get_argc (), command_line.get_TCHAR_argv ()); // Check for errors returned from <TAO_Internal::open_services>. diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 652495aaa26..d65b89e9814 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -99,7 +99,8 @@ TAO_ORB_Core_Static_Resources* TAO_ORB_Core_Static_Resources::instance_ = 0; // Force an instance to be created at module initialization time, // since we do not want to worry about double checked locking and // the race condition to initialize the lock. -TAO_ORB_Core_Static_Resources* TAO_ORB_Core_Static_Resources::initialization_reference_ = +TAO_ORB_Core_Static_Resources* +TAO_ORB_Core_Static_Resources::initialization_reference_ = TAO_ORB_Core_Static_Resources::instance (); TAO_ORB_Core_Static_Resources* @@ -126,7 +127,9 @@ TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void) timeout_hook_ (0), connection_timeout_hook_ (0), endpoint_selector_factory_name_ ("Default_Endpoint_Selector_Factory"), - thread_lane_resources_manager_factory_name_ ("Default_Thread_Lane_Resources_Manager_Factory"), + thread_lane_resources_manager_factory_name_ + ("Default_Thread_Lane_Resources_Manager_Factory"), + collocation_resolver_name_ ("Default_Collocation_Resolver"), stub_factory_name_ ("Default_Stub_Factory"), resource_factory_name_ ("Resource_Factory"), @@ -136,7 +139,12 @@ TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void) iorinterceptor_adapter_factory_name_ ("IORInterceptor_Adapter_Factory"), valuetype_adapter_factory_name_ ("valuetype_Adapter_Factory"), poa_factory_name_ ("TAO_Object_Adapter_Factory"), - poa_factory_directive_ (ACE_TEXT_ALWAYS_CHAR (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", "TAO_PortableServer", "_make_TAO_Object_Adapter_Factory", ""))), + poa_factory_directive_ + (ACE_TEXT_ALWAYS_CHAR + (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", + "TAO_PortableServer", + "_make_TAO_Object_Adapter_Factory", + ""))), alt_connection_timeout_hook_ (0) { } @@ -253,6 +261,17 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid) // Initialize the default request dispatcher. ACE_NEW (this->request_dispatcher_, TAO_Request_Dispatcher); + + /* + * @TODO: Get rid of the "magic number" for the Service repository size. + * Can this be dynamic container instead? + */ + if (ACE_OS::strnlen (this->orbid_, 1) == 0) + // (re)use the default/global getsalt + ACE_NEW (this->config_, ACE_Service_Gestalt); + else + ACE_NEW (this->config_, + ACE_Service_Gestalt (ACE_Service_Gestalt::MAX_SERVICES / 4)); } TAO_ORB_Core::~TAO_ORB_Core (void) @@ -289,6 +308,9 @@ TAO_ORB_Core::~TAO_ORB_Core (void) orbinitializer_registry_ = 0; ::CORBA::release (this->orb_); + + delete this->config_; + this->config_ = 0; } int @@ -687,7 +709,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) (ACE_TEXT("-ORBDefaultInitRef")))) { // Set the list of prefixes from -ORBDefaultInitRef. - this->orb_params ()->default_init_ref (ACE_TEXT_ALWAYS_CHAR(current_arg)); + this->orb_params ()->default_init_ref + (ACE_TEXT_ALWAYS_CHAR(current_arg)); arg_shifter.consume_arg (); } @@ -746,7 +769,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (-1); - output_stream->open (ACE_TEXT_ALWAYS_CHAR (file_name), ios::out | ios::app); + output_stream->open (ACE_TEXT_ALWAYS_CHAR (file_name), + ios::out | ios::app); if (!output_stream->bad ()) { @@ -893,10 +917,11 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) ACE_CString lane (ACE_TEXT_ALWAYS_CHAR (current_arg)); arg_shifter.consume_arg (); - if(arg_shifter.is_option_next ()) + if (arg_shifter.is_option_next ()) return -1; - ACE_CString endpoints (ACE_TEXT_ALWAYS_CHAR (arg_shifter.get_current ())); + ACE_CString endpoints (ACE_TEXT_ALWAYS_CHAR + (arg_shifter.get_current ())); arg_shifter.consume_arg (); this->set_endpoint_helper (lane, @@ -991,7 +1016,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: Unknown \"-ORB\" option ") ACE_TEXT ("<%s>.\n"), - ((current_arg == 0) ? ACE_TEXT("<NULL>") : current_arg))); + ((current_arg == 0) ? ACE_TEXT("<NULL>") + : current_arg))); } ACE_THROW_RETURN (CORBA::BAD_PARAM ( @@ -1025,7 +1051,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) if (TAO_debug_level > 0) { ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ERROR: Environment variable TAO_ORBENDPOINT set to invalid value ") + ACE_TEXT ("ERROR: Environment variable ") + ACE_TEXT ("TAO_ORBENDPOINT set to invalid value ") ACE_TEXT ("<%s>.\n"), env_endpoint)); } @@ -1051,6 +1078,7 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) (void) ACE_OS::signal (SIGPIPE, (ACE_SignalHandler) SIG_IGN); #endif /* SIGPIPE */ + // Calling the open method here so that the svc.conf file is // opened and TAO_default_resource_factory::init () is called by the // time this method is called. @@ -1230,9 +1258,13 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) this->flushing_strategy_ = trf->create_flushing_strategy (); // Look in the service repository for an instance of the Protocol Hooks. + const ACE_CString &protocols_hooks_name = + TAO_ORB_Core_Static_Resources::instance ()->protocols_hooks_name_; + this->protocols_hooks_ = ACE_Dynamic_Service<TAO_Protocols_Hooks>::instance - (TAO_ORB_Core_Static_Resources::instance ()->protocols_hooks_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (protocols_hooks_name.c_str())); // Must have valid protocol hooks. if (this->protocols_hooks_ == 0) @@ -1317,7 +1349,7 @@ TAO_ORB_Core::fini (void) if (this->thread_lane_resources_manager_ != 0) this->thread_lane_resources_manager_->finalize (); - (void) TAO::ORB::close_services (); + (void) TAO::ORB::close_services (this->configuration ()); // Destroy the object_key table this->object_key_table_.destroy (); @@ -1439,9 +1471,13 @@ TAO_ORB_Core::resource_factory (void) } // Look in the service repository for an instance. + ACE_CString &resource_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_; + this->resource_factory_ = ACE_Dynamic_Service<TAO_Resource_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (resource_factory_name.c_str())); return this->resource_factory_; } @@ -1461,9 +1497,13 @@ TAO_ORB_Core::thread_lane_resources_manager (void) return *this->thread_lane_resources_manager_; // If not, lookup the corresponding factory and ask it to make one. + const ACE_CString &thread_lane_resources_manager_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->thread_lane_resources_manager_factory_name_; + TAO_Thread_Lane_Resources_Manager_Factory *factory = ACE_Dynamic_Service<TAO_Thread_Lane_Resources_Manager_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->thread_lane_resources_manager_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (thread_lane_resources_manager_factory_name.c_str())); this->thread_lane_resources_manager_ = factory->create_thread_lane_resources_manager (*this); @@ -1479,9 +1519,13 @@ TAO_ORB_Core::collocation_resolver (void) return *this->collocation_resolver_; // If not, lookup it up. + const ACE_CString &collocation_resolver_name = + TAO_ORB_Core_Static_Resources::instance ()->collocation_resolver_name_; + this->collocation_resolver_ = ACE_Dynamic_Service<TAO_Collocation_Resolver>::instance - (TAO_ORB_Core_Static_Resources::instance ()->collocation_resolver_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (collocation_resolver_name.c_str())); return *this->collocation_resolver_; } @@ -1491,18 +1535,21 @@ TAO_ORB_Core::policy_factory_registry_i (void) { TAO_PolicyFactory_Registry_Factory *loader = - ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance ( - "PolicyFactory_Loader"); + ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance + (this->configuration (), + ACE_TEXT ("PolicyFactory_Loader")); + if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("PolicyFactory_Loader", "TAO_PI", - "_make_PolicyFactory_Loader", + "_make_TAO_PolicyFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance ( - "PolicyFactory_Loader"); + ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance + (this->configuration (), + ACE_TEXT ("PolicyFactory_Loader")); } if (loader != 0) @@ -1520,7 +1567,8 @@ TAO_ORB_Core::orbinitializer_registry_i (void) // If not, lookup it up. this->orbinitializer_registry_ = ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance - ("ORBInitializer_Registry"); + (this->configuration (), + ACE_TEXT ("ORBInitializer_Registry")); #if !defined (TAO_AS_STATIC_LIBS) // In case we build shared, try to load the PI Client library, in a @@ -1528,14 +1576,15 @@ TAO_ORB_Core::orbinitializer_registry_i (void) // output an error then. if (orbinitializer_registry_ == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("ORBInitializer_Registry", "TAO_PI", "_make_ORBInitializer_Registry", "")); orbinitializer_registry_ = ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance - ("ORBInitializer_Registry"); + (this->configuration (), + ACE_TEXT ("ORBInitializer_Registry")); } #endif /* !TAO_AS_STATIC_LIBS */ @@ -1550,9 +1599,13 @@ TAO_ORB_Core::stub_factory (void) return this->stub_factory_; // If not, look in the service repository for an instance. + const ACE_CString &stub_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->stub_factory_name_; + this->stub_factory_ = ACE_Dynamic_Service<TAO_Stub_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->stub_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (stub_factory_name.c_str())); return this->stub_factory_; } @@ -1588,9 +1641,13 @@ TAO_ORB_Core::endpoint_selector_factory (void) return this->endpoint_selector_factory_; // If not, look in the service repository for an instance. + const ACE_CString &endpoint_selector_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->endpoint_selector_factory_name_; + this->endpoint_selector_factory_ = ACE_Dynamic_Service<TAO_Endpoint_Selector_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->endpoint_selector_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (endpoint_selector_factory_name.c_str())); return this->endpoint_selector_factory_; } @@ -1676,7 +1733,9 @@ TAO_ORB_Core::client_factory (void) { // Look in the service repository for an instance. this->client_factory_ = - ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance ("Client_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance + (this->configuration (), + ACE_TEXT ("Client_Strategy_Factory")); } return this->client_factory_; @@ -1689,7 +1748,9 @@ TAO_ORB_Core::server_factory (void) { // Look in the service repository for an instance. this->server_factory_ = - ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance ("Server_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance + (this->configuration (), + ACE_TEXT ("Server_Strategy_Factory")); } return this->server_factory_; @@ -1701,20 +1762,29 @@ TAO_ORB_Core::root_poa (ACE_ENV_SINGLE_ARG_DECL) // DCL .. if (CORBA::is_nil (this->root_poa_.in ())) { + + // Making sure the initialization process in the current thread uses + // the correct service repository (ours), instead of the global one. + ACE_Service_Config_Guard scg (this->configuration ()); + + TAO_ORB_Core_Static_Resources* static_resources = TAO_ORB_Core_Static_Resources::instance (); TAO_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ( + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), static_resources->poa_factory_name_.c_str()); if (factory == 0) { - ACE_Service_Config::process_directive ( + this->configuration()->process_directive ( ACE_TEXT_CHAR_TO_TCHAR ( static_resources->poa_factory_directive_.c_str())); + factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ( + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), static_resources->poa_factory_name_.c_str()); } @@ -1833,7 +1903,8 @@ TAO_ORB_Core::load_policy_validators (TAO_Policy_Validator &validator if (this->bidir_adapter_ == 0) { this->bidir_adapter_ = - ACE_Dynamic_Service<TAO_BiDir_Adapter>::instance ("BiDirGIOP_Loader"); + ACE_Dynamic_Service<TAO_BiDir_Adapter>::instance + (this->configuration (), ACE_TEXT ("BiDirGIOP_Loader")); } // Call the BiDir library if it has been loaded @@ -2017,6 +2088,8 @@ TAO_ORB_Core::run (ACE_Time_Value *tv, int perform_work ACE_ENV_ARG_DECL_NOT_USED) { + ACE_Service_Config_Guard guard (this->configuration()); + if (TAO_debug_level > 2) { ACE_DEBUG ((LM_DEBUG, @@ -2101,6 +2174,7 @@ TAO_ORB_Core::run (ACE_Time_Value *tv, // A timeout, terminate the loop... break; } + if (perform_work) { // This is running on behalf of a perform_work() call, @@ -2205,8 +2279,7 @@ TAO_ORB_Core::destroy (ACE_ENV_SINGLE_ARG_DECL) // // Shutdown the ORB and block until the shutdown is complete. - this->shutdown (1 - ACE_ENV_ARG_PARAMETER); + this->shutdown (1 ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Invoke Interceptor::destroy() on all registered interceptors. @@ -2235,7 +2308,6 @@ TAO_ORB_Core::check_shutdown (ACE_ENV_SINGLE_ARG_DECL) void TAO_ORB_Core::destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) { - ACE_TRY { ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); @@ -2298,19 +2370,28 @@ void TAO_ORB_Core::resolve_typecodefactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TypeCodeFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("TypeCodeFactory_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( - ACE_DYNAMIC_SERVICE_DIRECTIVE("TypeCodeFactory_Loader", + this->configuration ()->process_directive ( + ACE_DYNAMIC_SERVICE_DIRECTIVE("TypeCodeFactory", "TAO_TypeCodeFactory", "_make_TAO_TypeCodeFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TypeCodeFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("TypeCodeFactory_Loader")); + if (loader == 0) ACE_THROW (CORBA::ORB::InvalidName ()); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + this->typecode_factory_ = loader->create_object (this->orb_, 0, 0 ACE_ENV_ARG_PARAMETER); } @@ -2319,17 +2400,26 @@ void TAO_ORB_Core::resolve_codecfactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("CodecFactory_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( - ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory_Loader", + this->configuration()->process_directive ( + ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory", "TAO_CodecFactory", "_make_TAO_CodecFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("CodecFactory_Loader")); + } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->codec_factory_ = @@ -2342,17 +2432,29 @@ void TAO_ORB_Core::resolve_poa_current_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TAO_POA_Current_Factory"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration(), + ACE_TEXT ("TAO_POA_Current_Factory")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_POA_Current_Factory", "TAO_PortableServer", "_make_TAO_POA_Current_Factory", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TAO_POA_Current_Factory"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration(), + ACE_TEXT ("TAO_POA_Current_Factory")); } + + if (loader == 0) + ACE_THROW (CORBA::ORB::InvalidName ()); + +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->poa_current_ = @@ -2367,17 +2469,24 @@ void TAO_ORB_Core::resolve_picurrent_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("PICurrent_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("PICurrent_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("PICurrent_Loader", "TAO_PI", "_make_TAO_PICurrent_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("PICurrent_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("PICurrent_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (loader != 0) { @@ -2396,17 +2505,24 @@ void TAO_ORB_Core::resolve_dynanyfactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("DynamicAny_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("DynamicAny_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("DynamicAny_Loader", "TAO_DynamicAny", "_make_TAO_DynamicAny_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("DynamicAny_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("DynamicAny_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (loader != 0) { @@ -2420,18 +2536,25 @@ void TAO_ORB_Core::resolve_iormanipulation_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("IORManip_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("IORManip_Loader")); +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("IORManip_Loader", "TAO_IORManip", "_make_TAO_IORManip_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("IORManip_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("IORManip_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->ior_manip_factory_ = @@ -2444,29 +2567,39 @@ void TAO_ORB_Core::resolve_ior_table_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ("TAO_IORTable"); + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("TAO_IORTable")); + +#if !defined(TAO_AS_STATIC_LIBS) if (factory == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_IORTable", "TAO_IORTable", "_make_TAO_Table_Adapter_Factory", "")); factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ("TAO_IORTable"); + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("TAO_IORTable")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (factory != 0) { - // @@ Not exception safe - TAO_Adapter *iortable_adapter = factory->create (this); - this->adapter_registry_.insert (iortable_adapter ACE_ENV_ARG_PARAMETER); + ACE_Auto_Ptr <TAO_Adapter> iortable_adapter (factory->create (this)); + iortable_adapter->open (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - iortable_adapter->open (ACE_ENV_SINGLE_ARG_PARAMETER); + CORBA::Object_var tmp_root = iortable_adapter->root (); + + this->adapter_registry_.insert (iortable_adapter.get () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->ior_table_ = iortable_adapter->root (); + // It is now (exception) safe to release ownership from the auto pointers + this->ior_table_= tmp_root._retn (); + iortable_adapter.release (); } } @@ -2743,7 +2876,8 @@ TAO_ORB_Core::implrepo_service (void) ACE_TRY_NEW_ENV { - CORBA::Object_var temp = this->orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); + CORBA::Object_var temp = + this->orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::Object::_nil ()); @@ -2753,7 +2887,8 @@ TAO_ORB_Core::implrepo_service (void) } ACE_CATCHANY { - // Just make sure that we have a null pointer. Ignore the exception anyway. + // Just make sure that we have a null pointer. Ignore the exception + // anyway. this->implrepo_service_ = CORBA::Object::_nil (); } ACE_ENDTRY; @@ -3087,16 +3222,38 @@ TAO_ORB_Core::ior_interceptor_adapter (void) ACE_TRY { TAO_IORInterceptor_Adapter_Factory * ior_ap_factory = - ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance ( - TAO_ORB_Core::iorinterceptor_adapter_factory_name () - ); + ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (TAO_ORB_Core::iorinterceptor_adapter_factory_name ())); + +#if !defined (TAO_AS_STATIC_LIBS) + // In case we build shared, try to load the IOR_Interceptor factory. In a + // static build we just can't do this, so don't try it + if (ior_ap_factory == 0) + { + this->configuration()->process_directive + (ACE_DYNAMIC_SERVICE_DIRECTIVE("Concrete_IORInterceptor_Adapter_Factory", + "TAO_IORInterceptor", + "_make_TAO_IORInterceptor_Adapter_Factory_Impl", + "")); + ior_ap_factory = + ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance + (this->configuration (), ACE_TEXT("Concrete_IORInterceptor_Adapter_Factory")); + } +#endif /* !TAO_AS_STATIC_LIBS */ - if (ior_ap_factory) + if (ior_ap_factory == 0) { - this->ior_interceptor_adapter_ = - ior_ap_factory->create (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Unable to get a IORInterceptor factory\n")), + 0); + ACE_THROW (CORBA::INTERNAL ()); } + + this->ior_interceptor_adapter_ = + ior_ap_factory->create (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { @@ -3130,7 +3287,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Client Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Client Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3149,9 +3307,9 @@ TAO_ORB_Core::clientrequestinterceptor_adapter_i (void) if (this->client_request_interceptor_adapter_ == 0) { TAO_ClientRequestInterceptor_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_ClientRequestInterceptor_Adapter_Factory>::instance ( - "ClientRequestInterceptor_Adapter_Factory" - ); + ACE_Dynamic_Service<TAO_ClientRequestInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("ClientRequestInterceptor_Adapter_Factory")); if (factory) { @@ -3180,7 +3338,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Server Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Server Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3206,7 +3365,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Client Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Client Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3232,7 +3392,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Server Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Server Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3251,9 +3412,9 @@ TAO_ORB_Core::serverrequestinterceptor_adapter_i (void) if (this->server_request_interceptor_adapter_ == 0) { TAO_ServerRequestInterceptor_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_ServerRequestInterceptor_Adapter_Factory>::instance ( - "ServerRequestInterceptor_Adapter_Factory" - ); + ACE_Dynamic_Service<TAO_ServerRequestInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("ServerRequestInterceptor_Adapter_Factory")); if (factory) { @@ -3263,6 +3424,11 @@ TAO_ORB_Core::serverrequestinterceptor_adapter_i (void) } } + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Server request interceptor adapter list at %@\n"), + this->server_request_interceptor_adapter_)); + return this->server_request_interceptor_adapter_; } diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 5b2a3b7a1ae..b9a0581bf39 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -316,7 +316,7 @@ public: * Sets the value of gui_resource_factory in TSS. ORB_Core is responsible * for releasing this factory if needed. */ - static void set_gui_resource_factory (TAO::GUIResource_Factory *gui_resource_factory); + static void set_gui_resource_factory (TAO::GUIResource_Factory *gui_factory); /// Sets the value of TAO_ORB_Core::protocols_hooks_ static void set_protocols_hooks (const char *protocols_hooks_name); @@ -917,6 +917,9 @@ public: (const CORBA::Object_ptr obj, const TAO_Service_Context &service_context); + /// Configuration accessor method + ACE_Service_Gestalt* configuration () const; + /// Get outgoing fragmentation strategy. auto_ptr<TAO_GIOP_Fragmentation_Strategy> fragmentation_strategy (TAO_Transport * transport); @@ -1259,6 +1262,8 @@ protected: /// Code Set Manager - points to service object in the service repo TAO_Codeset_Manager *codeset_manager_; + /// ORB's service configuration + ACE_Service_Gestalt *config_; }; // **************************************************************** diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index b78066a39eb..3f5f53cd423 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -7,6 +7,12 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL +ACE_INLINE ACE_Service_Gestalt* +TAO_ORB_Core::configuration (void) const +{ + return this->config_; +} + ACE_INLINE CORBA::ULong TAO_ORB_Core::_incr_refcnt (void) { @@ -250,23 +256,6 @@ TAO_ORB_Core::orb_params(void) return &(this->orb_params_); } -ACE_INLINE TAO_Codeset_Manager * -TAO_ORB_Core::codeset_manager() -{ - if (this->orb_params()->negotiate_codesets() == 0) - return 0; - if (this->codeset_manager_ == 0) - { - // This causes a factory to be loaded which will call - // the codeset_manager setter in this thread. - this->codeset_manager_ = - this->resource_factory()->codeset_manager(); - if (this->codeset_manager_ == 0) - this->orb_params()->negotiate_codesets(false); - } - return this->codeset_manager_; -} - #define TAO_OC_RETRIEVE(member) \ ((this->member##_ == 0) \ ? (this->member##_ = this->resource_factory ()->get_##member ()) \ @@ -447,6 +436,23 @@ TAO_ORB_Core::server_id (void) const return this->server_id_.c_str(); } +ACE_INLINE TAO_Codeset_Manager * +TAO_ORB_Core::codeset_manager() +{ + if (this->orb_params()->negotiate_codesets() == 0) + return 0; + if (this->codeset_manager_ == 0) + { + // This causes a factory to be loaded which will call + // the codeset_manager setter in this thread. + this->codeset_manager_ = + this->resource_factory()->codeset_manager(); + if (this->codeset_manager_ == 0) + this->orb_params()->negotiate_codesets(false); + } + return this->codeset_manager_; +} + ACE_INLINE TAO::ORBInitializer_Registry_Adapter * TAO_ORB_Core::orbinitializer_registry () { diff --git a/TAO/tao/PI/ORBInitializer_Registry_Impl.cpp b/TAO/tao/PI/ORBInitializer_Registry_Impl.cpp index 919abb2706e..57834a96e38 100644 --- a/TAO/tao/PI/ORBInitializer_Registry_Impl.cpp +++ b/TAO/tao/PI/ORBInitializer_Registry_Impl.cpp @@ -1,6 +1,7 @@ #include "tao/PI/ORBInitializer_Registry_Impl.h" #include "tao/PI/ORBInitInfo.h" #include "tao/PI/PICurrent.h" +#include "tao/PI/PI_ORBInitializer.h" #include "tao/ORB_Core.h" #include "tao/ORB_Constants.h" @@ -10,6 +11,10 @@ #include "ace/Recursive_Thread_Mutex.h" #include "ace/Log_Msg.h" +#include "tao/PI/ClientRequestInterceptor_Factory_Impl.h" +#include "tao/PI/PICurrent_Loader.h" +#include "tao/PI/PolicyFactory_Loader.h" + ACE_RCSID (PI, ORBInitializer_Registry, "$Id$") @@ -24,6 +29,66 @@ TAO::ORBInitializer_Registry::ORBInitializer_Registry (void) } int +TAO::ORBInitializer_Registry::init (int, ACE_TCHAR *[]) +{ + ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + this->lock_, + -1); + +#if TAO_HAS_INTERCEPTORS == 1 + + ACE_Service_Config::process_directive + (ace_svc_desc_TAO_PolicyFactory_Loader); + + ACE_Service_Config::process_directive + (ace_svc_desc_TAO_ClientRequestInterceptor_Adapter_Factory_Impl); + + ACE_Service_Config::process_directive + (ace_svc_desc_TAO_PICurrent_Loader); + + PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + PortableInterceptor::ORBInitializer_var orb_initializer; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + /// Register the PI ORBInitializer. + + ACE_NEW_THROW_EX (temp_orb_initializer, + TAO_PI_ORBInitializer, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_TRY_CHECK; + + orb_initializer = temp_orb_initializer; + + this->register_orb_initializer (orb_initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "(%P | %t) Caught exception:"); + } + return -1; + } + ACE_ENDTRY; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + + return 0; +} + + +int TAO::ORBInitializer_Registry::fini (void) { ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, diff --git a/TAO/tao/PI/ORBInitializer_Registry_Impl.h b/TAO/tao/PI/ORBInitializer_Registry_Impl.h index edb5a2bfc26..1e4788a2602 100644 --- a/TAO/tao/PI/ORBInitializer_Registry_Impl.h +++ b/TAO/tao/PI/ORBInitializer_Registry_Impl.h @@ -76,6 +76,17 @@ namespace TAO PortableInterceptor::SlotId slotid ACE_ENV_ARG_DECL); + protected: + + // Added to provide registration for the several static service objects, + // brought in with this ORBInitializer_Registry implementation. Note that + // this is more reliable than using static initializers, since multiple + // copies of the dynamic service object will require their own (multiple) + // copies of the dependent static service objects. That is just impossible + // without registering those static services in the same repo, the dynamic + // SO is registered with. + virtual int init (int, ACE_TCHAR *[]); + private: // Prevent copying ORBInitializer_Registry (const ORBInitializer_Registry &); diff --git a/TAO/tao/PI/PI.cpp b/TAO/tao/PI/PI.cpp index 3e18928cf8c..ebec2effb3f 100644 --- a/TAO/tao/PI/PI.cpp +++ b/TAO/tao/PI/PI.cpp @@ -1,11 +1,4 @@ #include "tao/PI/PI.h" -#include "tao/PI/ORBInitializer_Registry_Impl.h" -#include "tao/PI/PolicyFactory_Loader.h" -#include "tao/PI/ClientRequestInterceptor_Factory_Impl.h" -#include "tao/PI/PICurrent_Loader.h" -#include "tao/PI/PI_ORBInitializer.h" -#include "tao/ORBInitializer_Registry.h" -#include "tao/ORB_Constants.h" ACE_RCSID (PI, PI, @@ -13,55 +6,4 @@ ACE_RCSID (PI, TAO_BEGIN_VERSIONED_NAMESPACE_DECL -int -TAO_PI_Init::Initializer (void) -{ -#if TAO_HAS_INTERCEPTORS == 1 - ACE_Service_Config::process_directive (ace_svc_desc_TAO_ClientRequestInterceptor_Adapter_Factory_Impl); - - ACE_Service_Config::process_directive (ace_svc_desc_TAO_PICurrent_Loader); -#endif /* TAO_HAS_INTERCEPTORS == 1 */ - - int status = ACE_Service_Config::process_directive ( - ace_svc_desc_ORBInitializer_Registry); -#if TAO_HAS_INTERCEPTORS == 1 - PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = - PortableInterceptor::ORBInitializer::_nil (); - - PortableInterceptor::ORBInitializer_var orb_initializer; - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - /// Register the PI ORBInitializer. - - ACE_NEW_THROW_EX (temp_orb_initializer, - TAO_PI_ORBInitializer, - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO::VMCID, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_TRY_CHECK; - - orb_initializer = temp_orb_initializer; - - PortableInterceptor::register_orb_initializer (orb_initializer.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - if (TAO_debug_level > 0) - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "(%P | %t) Caught exception:"); - } - return -1; - } - ACE_ENDTRY; -#endif /* TAO_HAS_INTERCEPTORS == 1 */ - return status; -} - TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PI/PI.h b/TAO/tao/PI/PI.h index da45315f182..6facdc7fc2d 100644 --- a/TAO/tao/PI/PI.h +++ b/TAO/tao/PI/PI.h @@ -25,22 +25,6 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL -/** - * @class TAO_PI_Init - * - */ -class TAO_PI_Export TAO_PI_Init -{ -public: - - /// Used to force the initialization of the ORB code. - static int Initializer (void); -}; - -static int -TAO_Requires_PI_Initializer = - TAO_PI_Init::Initializer (); - TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/TAO/tao/PI/PolicyFactory_Loader.cpp b/TAO/tao/PI/PolicyFactory_Loader.cpp index 3b8e49f062c..1e4f6e44d5a 100644 --- a/TAO/tao/PI/PolicyFactory_Loader.cpp +++ b/TAO/tao/PI/PolicyFactory_Loader.cpp @@ -14,9 +14,6 @@ #include "tao/PI/PolicyFactory_Loader.h" #include "tao/PI/PolicyFactory_Registry.h" -#include "tao/ORB.h" -#include "tao/debug.h" - ACE_RCSID (PI, PolicyFactory_Loader, "$Id$") @@ -33,12 +30,6 @@ TAO_PolicyFactory_Loader::create (void) return obj; } -int -TAO_PolicyFactory_Loader::Initializer (void) -{ - return ACE_Service_Config::process_directive (ace_svc_desc_TAO_PolicyFactory_Loader); -} - TAO_END_VERSIONED_NAMESPACE_DECL ACE_STATIC_SVC_DEFINE (TAO_PolicyFactory_Loader, diff --git a/TAO/tao/PI/PolicyFactory_Loader.h b/TAO/tao/PI/PolicyFactory_Loader.h index a25c378676e..4ee3c5a2c56 100644 --- a/TAO/tao/PI/PolicyFactory_Loader.h +++ b/TAO/tao/PI/PolicyFactory_Loader.h @@ -34,14 +34,8 @@ class TAO_PI_Export TAO_PolicyFactory_Loader public: /// Creates a Codec factory and returns it. virtual TAO::PolicyFactory_Registry_Adapter* create (void); - - /// Used to force the initialization of the ORB code. - static int Initializer (void); }; -static int -TAO_Requires_PolicyFactory_Initializer = TAO_PolicyFactory_Loader::Initializer (); - TAO_END_VERSIONED_NAMESPACE_DECL ACE_STATIC_SVC_DECLARE (TAO_PolicyFactory_Loader) diff --git a/TAO/tao/Parser_Registry.cpp b/TAO/tao/Parser_Registry.cpp index 1d873b9ae12..7b21273679e 100644 --- a/TAO/tao/Parser_Registry.cpp +++ b/TAO/tao/Parser_Registry.cpp @@ -49,7 +49,8 @@ TAO_Parser_Registry::open (TAO_ORB_Core *orb_core) for (size_t i = 0; i != this->size_; ++i) { this->parsers_[i] = - ACE_Dynamic_Service<TAO_IOR_Parser>::instance (names [i]); + ACE_Dynamic_Service<TAO_IOR_Parser>::instance (orb_core->configuration (), + names [i]); if (this->parsers_[i] == 0) { diff --git a/TAO/tao/PortableServer/Root_POA.cpp b/TAO/tao/PortableServer/Root_POA.cpp index b476ae8bec6..686e4759d51 100644 --- a/TAO/tao/PortableServer/Root_POA.cpp +++ b/TAO/tao/PortableServer/Root_POA.cpp @@ -2515,7 +2515,8 @@ TAO_Root_POA::find_servant_priority ( TAO::ORT_Adapter_Factory * TAO_Root_POA::ORT_adapter_factory (void) { - return ACE_Dynamic_Service<TAO::ORT_Adapter_Factory>::instance ( + return ACE_Dynamic_Service<TAO::ORT_Adapter_Factory>::instance + (orb_core_.configuration (), TAO_Root_POA::ort_adapter_factory_name ()); } diff --git a/TAO/tao/TAO_Internal.cpp b/TAO/tao/TAO_Internal.cpp index 0839cc1f048..65393f2a33e 100644 --- a/TAO/tao/TAO_Internal.cpp +++ b/TAO/tao/TAO_Internal.cpp @@ -48,33 +48,71 @@ ACE_RCSID (tao, namespace { + + /** + * Parses the supplied command-line arguments to extract any that + * apply to the process (globally) + * + * @brief Modifies the argc to reflect any arguments it has + * "consumed" + */ + int + parse_global_args_i (int &argc, + char **argv, + CORBA::StringSeq &svc_config_argv); + /** - * Initialize the ACE Service Configurator. This is a one-shot - * method, i.e., it can be called multiple times but it will only do - * its work once. It does, however, track the number of times it's - * called (see @c open_services()). It is fully thread-safe. + * Initialize the ACE Service Configurator with the process-global + * services (available to any ORB). * * @return @c 0 if successful, @c -1 with @c errno set if failure. * * @note You can provide your program a set of default `svc.conf' * entries by setting @a ignore_default_svc_conf_file to * non-zero and use @c default_svc_conf_entries() before - * calling @c open_services(). In addition, you can @a + * calling @c open_global_services(). In addition, you can @a * skip_service_config_open altogether, which used to be * important when the ORB is linked in via the - * ACE_Service_Configurator, since the - * ACE_Service_Configurator was non-reentrant. However, the - * ACE_Service_Configurator is now reentrant meaning that it - * is really no longer necessary to do so. + * ACE_Service_Config, since the ACE_Service_Config was + * non-reentrant. However, the ACE_Service_Config is now + * reentrant meaning that it is really no longer necessary to + * do so. + */ + void register_global_services_i (ACE_Service_Gestalt * pcfg); + int open_global_services_i (ACE_Service_Gestalt* theone, + int & argc, + char ** argv, + bool skip_service_config_open); + + /** + * Parses the supplied command-line arguments to extract any + * instance-specific ones. + * + * @brief Modifies the argc to reflect any arguments it has + * "consumed" + */ + int + parse_private_args_i (int &argc, + char **argv, + CORBA::StringSeq & svc_config_argv, + bool & skip_service_config_open); + + /** + * Initialize ORB-local (private) ACE Service Configurator + * repository. + * + * @return @c 0 if successful, @c -1 with @c errno set if failure. + * */ - int open_services_i (int & argc, - char ** argv, - bool ignore_default_svc_conf_file = false, - bool skip_service_config_open = false); + int open_private_services_i (ACE_Service_Gestalt* pcfg, + int & argc, + char ** argv, + bool skip_service_config_open = false); - /// Number of times open_services() has been called. Incremented by - /// open_services(), and decremented by close_services(). /** + * Number of times open_services() has been called. Incremented by + * open_global_services_i(), and decremented by close_services(). + * * @note In/decrement operations are atomic. */ long service_open_count = 0; @@ -90,7 +128,9 @@ namespace TAO_BEGIN_VERSIONED_NAMESPACE_DECL int -TAO::ORB::open_services (int &argc, ACE_TCHAR **argv) +TAO::ORB::open_services (ACE_Service_Gestalt* pcfg, + int &argc, + ACE_TCHAR **argv) { // Construct an argument vector specific to the Service // Configurator. @@ -105,7 +145,6 @@ TAO::ORB::open_services (int &argc, ACE_TCHAR **argv) argv0 = ACE_TEXT_ALWAYS_CHAR (argv[0]); } - CORBA::ULong len = 0; svc_config_argv.length (1); svc_config_argv[0] = argv0.c_str (); @@ -117,157 +156,66 @@ TAO::ORB::open_services (int &argc, ACE_TCHAR **argv) // -Ossama bool skip_service_config_open = false; -#if defined (TAO_DEBUG) && !defined (ACE_HAS_WINCE) - // Make it a little easier to debug programs using this code. + // Extract any ORB options from the argument vector. + if (parse_private_args_i (argc, + argv, + svc_config_argv, + skip_service_config_open) == -1) + return -1; + else { - TAO_debug_level = ACE_Env_Value<u_int> ("TAO_ORB_DEBUG", 0); + ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + *ACE_Static_Object_Lock::instance (), + -1)); - char * const value = ACE_OS::getenv ("TAO_ORB_DEBUG"); + service_open_count++; - if (value != 0) + ACE_Service_Gestalt * theone = ACE_Service_Config::global (); + if (pcfg != theone) + { + int status = open_global_services_i (theone, argc, argv, skip_service_config_open); + if (status == -1) { - TAO_debug_level = ACE_OS::atoi (value); - - if (TAO_debug_level <= 0) - { - TAO_debug_level = 1; - } - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO_debug_level == %d\n"), - TAO_debug_level)); + if (TAO_debug_level > 0) + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_LIB_TEXT ("TAO (%P|%t) Failed to ") + ACE_LIB_TEXT("open process-wide service configuration\n")), + -1); + return -1; } - } -#endif /* TAO_DEBUG && !ACE_HAS_WINCE */ - - // Extract the Service Configurator ORB options from the argument - // vector. - ACE_Arg_Shifter arg_shifter (argc, argv); + } - while (arg_shifter.is_anything_left ()) + int svc_config_argc = svc_config_argv.length (); + int status = + open_private_services_i (pcfg, + svc_config_argc, + svc_config_argv.get_buffer (), + skip_service_config_open); + if (status == -1) { - const ACE_TCHAR *current_arg = 0; - - // Start with the parameterless flags. - if (arg_shifter.cur_arg_strncasecmp - (ACE_TEXT ("-ORBSkipServiceConfigOpen")) == 0) - { - skip_service_config_open = true; - - arg_shifter.consume_arg (); - } - else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDebug")) == 0) - { - // later, replace all of these - // warning this turns on a daemon - ACE::debug (1); - arg_shifter.consume_arg (); - } - else if (0 != (current_arg = arg_shifter.get_the_parameter - (ACE_TEXT ("-ORBDebugLevel")))) - { - TAO_debug_level = - ACE_OS::atoi (current_arg); - - arg_shifter.consume_arg (); - } - else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDaemon")) == 0) - { - // Be a daemon - - len = svc_config_argv.length (); - svc_config_argv.length (len + 1); - - svc_config_argv[len] = CORBA::string_dup ("-b"); - - arg_shifter.consume_arg (); - } - // Continue with flags that accept parameters. - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConfDirective")))) - { - len = svc_config_argv.length (); - svc_config_argv.length (len + 2); // 2 arguments to add - - // This is used to pass arguments to the Service - // Configurator using the "command line" to provide - // configuration information rather than using a svc.conf - // file. Pass the "-S" to the service configurator. - svc_config_argv[len] = CORBA::string_dup ("-S"); - svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); - - arg_shifter.consume_arg (); - } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConf")))) - { - // Specify the name of the svc.conf file to be used. - - // Proceeds only if the configuration file exists. - FILE * const conf_file = ACE_OS::fopen (current_arg, ACE_TEXT ("r")); - - if (conf_file == 0) - { - // Assigning EINVAL to errno to make an exception - // thrown. calling code does not throw an exception if - // the errno is set to ENOENT for some reason. - errno = EINVAL; - - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) Service Configurator ") - ACE_TEXT ("unable to open file %s\n"), - current_arg), - -1); - - } - else - { - ACE_OS::fclose (conf_file); - } - - len = svc_config_argv.length (); - svc_config_argv.length (len + 2); // 2 arguments to add - - svc_config_argv[len] = CORBA::string_dup ("-f"); - svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); - - arg_shifter.consume_arg(); - } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBServiceConfigLoggerKey")))) - { - len = svc_config_argv.length (); - svc_config_argv.length (len + 2); // 2 arguments to add - - svc_config_argv[len] = CORBA::string_dup ("-k"); - svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); - - arg_shifter.consume_arg (); - } - // Can't interpret this argument. Move on to the next argument. - else - { - // Any arguments that don't match are ignored so that the - // caller can still use them. - arg_shifter.ignore_arg (); - } + if (TAO_debug_level > 0) + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_LIB_TEXT ("TAO (%P|%t) Failed to ") + ACE_LIB_TEXT("open orb service configuration\n")), + -1); + return -1; } - int svc_config_argc = svc_config_argv.length (); - return open_services_i (svc_config_argc, - svc_config_argv.get_buffer (), - 0, // @@ What about this argument? - skip_service_config_open); + return 0; + } } int -TAO::ORB::close_services (void) +TAO::ORB::close_services (ACE_Service_Gestalt* pcfg) { ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, guard, *ACE_Static_Object_Lock::instance (), -1)); + service_open_count--; - --service_open_count; - - return 0; + return pcfg->close (); } void @@ -285,32 +233,78 @@ TAO_END_VERSIONED_NAMESPACE_DECL // ----------------------------------------------------- namespace { + + /// + int - open_services_i (int & argc, - char ** argv, - bool ignore_default_svc_conf_file, - bool skip_service_config_open) + open_global_services_i (ACE_Service_Gestalt * theone, + int & argc, + ACE_TCHAR ** argv, + bool skip_service_config_open) + { + // Construct an argument vector specific to the process-wide + // (global) Service Configurator instance. + CORBA::StringSeq global_svc_config_argv; + + // Be certain to copy the program name so that service configurator + // has something to skip! + ACE_CString argv0 (""); + + if (argc > 0 && argv != 0) + { + argv0 = ACE_TEXT_ALWAYS_CHAR (argv[0]); + } + + global_svc_config_argv.length (1); + global_svc_config_argv[0] = argv0.c_str (); + + if (parse_global_args_i (argc, argv, global_svc_config_argv) == -1) + return -1; + + ACE_Service_Config_Guard guard (theone); + register_global_services_i (theone); + + int global_svc_config_argc = global_svc_config_argv.length (); + if (!skip_service_config_open) + { + return theone->open (global_svc_config_argc, + global_svc_config_argv.get_buffer ()); + } + return 0; + } + + + /// + + int + open_private_services_i (ACE_Service_Gestalt * pcfg, + int & argc, + ACE_TCHAR ** argv, + bool skip_service_config_open) { #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP) - ignore_default_svc_conf_file = true; + bool ignore_default_svc_conf_file = true; +#else + bool ignore_default_svc_conf_file = false; #endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */ - { - ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, - guard, - *ACE_Static_Object_Lock::instance (), - -1)); + if (skip_service_config_open) + return 0; - if (service_open_count++ != 0) // Atomic increment - return 0; - } + return pcfg->open (argc, + argv, + ACE_DEFAULT_LOGGER_KEY, + 0, // Don't ignore static services. + ignore_default_svc_conf_file); + } - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Resource_Factory); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Client_Strategy_Factory); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Server_Strategy_Factory); + /// @brief registers all process-wide (global) services, available to all ORBs + void + register_global_services_i (ACE_Service_Gestalt * pcfg) + { + pcfg->process_directive (ace_svc_desc_TAO_Default_Resource_Factory); + pcfg->process_directive (ace_svc_desc_TAO_Default_Client_Strategy_Factory); + pcfg->process_directive (ace_svc_desc_TAO_Default_Server_Strategy_Factory); // Configure the IIOP factory. You do *NOT* need modify this // code to add your own protocol, instead simply add the @@ -321,125 +315,273 @@ namespace // // where PN is the name of your protocol and LIB is the base // name of the shared library that implements the protocol. + #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0) - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_IIOP_Protocol_Factory); + pcfg->process_directive (ace_svc_desc_TAO_IIOP_Protocol_Factory); #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */ // add descriptor to list of static objects. - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_MCAST_Parser); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_CORBANAME_Parser); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_CORBALOC_Parser); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_FILE_Parser); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_DLL_Parser); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Stub_Factory); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Endpoint_Selector_Factory); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Protocols_Hooks); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Thread_Lane_Resources_Manager_Factory); - ACE_Service_Config::process_directive ( - ace_svc_desc_TAO_Default_Collocation_Resolver); - - int result = 0; - - if (!skip_service_config_open) - { - // Copy command line parameter not to use original. - ACE_Argv_Type_Converter command_line (argc, argv); - - result = - ACE_Service_Config::open (command_line.get_argc(), - command_line.get_TCHAR_argv(), - ACE_DEFAULT_LOGGER_KEY, - 0, // Don't ignore static services. - ignore_default_svc_conf_file); - } + pcfg->process_directive (ace_svc_desc_TAO_MCAST_Parser); + pcfg->process_directive (ace_svc_desc_TAO_CORBANAME_Parser); + pcfg->process_directive (ace_svc_desc_TAO_CORBALOC_Parser); + pcfg->process_directive (ace_svc_desc_TAO_FILE_Parser); + pcfg->process_directive (ace_svc_desc_TAO_DLL_Parser); + pcfg->process_directive (ace_svc_desc_TAO_Default_Stub_Factory); + pcfg->process_directive (ace_svc_desc_TAO_Default_Endpoint_Selector_Factory); + pcfg->process_directive (ace_svc_desc_TAO_Default_Protocols_Hooks); + pcfg->process_directive (ace_svc_desc_TAO_Default_Thread_Lane_Resources_Manager_Factory); + pcfg->process_directive (ace_svc_desc_TAO_Default_Collocation_Resolver); + + // @@ What the heck do these things do and do we need to avoid + // calling them if we're not invoking the svc.conf file? + // @@ They are needed for platforms that have no file system, + // like VxWorks. + if (resource_factory_args != 0) + { + pcfg->process_directive + (ACE_TEXT_CHAR_TO_TCHAR (resource_factory_args)); + } + + if (client_strategy_factory_args != 0) + { + pcfg->process_directive + (ACE_TEXT_CHAR_TO_TCHAR (client_strategy_factory_args)); + } + + if (server_strategy_factory_args != 0) + { + pcfg->process_directive + (ACE_TEXT_CHAR_TO_TCHAR (server_strategy_factory_args)); + } // If available, allow the Adapter Factory to setup. ACE_Service_Object *adapter_factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ( - TAO_ORB_Core::poa_factory_name ().c_str()); + ACE_Dynamic_Service<ACE_Service_Object>::instance + (pcfg, TAO_ORB_Core::poa_factory_name ().c_str()); if (adapter_factory != 0) - { - adapter_factory->init (0, 0); - } + { + adapter_factory->init (0, 0); + } ACE_Service_Object * const pi_server_loader = - ACE_Dynamic_Service<ACE_Service_Object>::instance ("PI_Server_Loader"); + ACE_Dynamic_Service<ACE_Service_Object>::instance (pcfg, "PI_Server_Loader"); if (pi_server_loader != 0) - { - pi_server_loader->init (0, 0); - } + { + pi_server_loader->init (0, 0); + } ACE_Service_Object * const bidir_loader = - ACE_Dynamic_Service<ACE_Service_Object>::instance ("BiDirGIOP_Loader"); + ACE_Dynamic_Service<ACE_Service_Object>::instance (pcfg, "BiDirGIOP_Loader"); if (bidir_loader != 0) - { - bidir_loader->init (0, 0); - } + { + bidir_loader->init (0, 0); + } ACE_Service_Object * const messaging_loader = - ACE_Dynamic_Service<ACE_Service_Object>::instance ("Messaging_Loader"); + ACE_Dynamic_Service<ACE_Service_Object>::instance (pcfg, "Messaging_Loader"); if (messaging_loader != 0) - { - messaging_loader->init (0, 0); - } + { + messaging_loader->init (0, 0); + } // Handle RTCORBA library special case. Since RTCORBA needs // its init method call to register several hooks, call it // here if it hasn't already been called. ACE_Service_Object * const rt_loader = - ACE_Dynamic_Service<ACE_Service_Object>::instance ("RT_ORB_Loader"); + ACE_Dynamic_Service<ACE_Service_Object>::instance (pcfg, "RT_ORB_Loader"); if (rt_loader != 0) - { - rt_loader->init (0, 0); - } + { + rt_loader->init (0, 0); + } ACE_Service_Object * const rtscheduler_loader = - ACE_Dynamic_Service<ACE_Service_Object>::instance ("RTScheduler_Loader"); + ACE_Dynamic_Service<ACE_Service_Object>::instance (pcfg, "RTScheduler_Loader"); if (rtscheduler_loader != 0) + { + rtscheduler_loader->init (0, 0); + } + + } /* register_additional_services_i */ + + + int + parse_private_args_i (int &argc, + char **argv, + CORBA::StringSeq &svc_config_argv, + bool & skip_service_config_open) + { + // Extract the Service Configurator ORB options from the argument + // vector. + ACE_Arg_Shifter arg_shifter (argc, argv); + + CORBA::ULong len = 0; + while (arg_shifter.is_anything_left ()) + { + const ACE_TCHAR *current_arg = 0; + + // Start with the parameterless flags. + if (arg_shifter.cur_arg_strncasecmp + (ACE_TEXT ("-ORBSkipServiceConfigOpen")) == 0) { - rtscheduler_loader->init (0, 0); + skip_service_config_open = true; + + arg_shifter.consume_arg (); } + // Continue with flags that accept parameters. + else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConfDirective")))) + { + len = svc_config_argv.length (); + svc_config_argv.length (len + 2); // 2 arguments to add - // @@ What the heck do these things do and do we need to avoid - // calling them if we're not invoking the svc.conf file? - // @@ They are needed for platforms that have no file system, - // like VxWorks. - if (resource_factory_args != 0) + // This is used to pass arguments to the Service + // Configurator using the "command line" to provide + // configuration information rather than using a svc.conf + // file. Pass the "-S" to the service configurator. + svc_config_argv[len] = CORBA::string_dup ("-S"); + svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); + + arg_shifter.consume_arg (); + } + else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConf")))) + { + // Specify the name of the svc.conf file to be used. + + // Proceeds only if the configuration file exists. + FILE * const conf_file = ACE_OS::fopen (current_arg, ACE_TEXT ("r")); + + if (conf_file == 0) + { + // Assigning EINVAL to errno to make an exception + // thrown. calling code does not throw an exception if + // the errno is set to ENOENT for some reason. + errno = EINVAL; + + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) Service Configurator ") + ACE_TEXT ("unable to open file %s\n"), + current_arg), + -1); + + } + else + { + ACE_OS::fclose (conf_file); + } + + len = svc_config_argv.length (); + svc_config_argv.length (len + 2); // 2 arguments to add + + svc_config_argv[len] = CORBA::string_dup ("-f"); + svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); + + arg_shifter.consume_arg(); + } + else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBServiceConfigLoggerKey")))) + { + len = svc_config_argv.length (); + svc_config_argv.length (len + 2); // 2 arguments to add + + svc_config_argv[len] = CORBA::string_dup ("-k"); + svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg)); + + arg_shifter.consume_arg (); + } + // Can't interpret this argument. Move on to the next argument. + else { - ACE_Service_Config::process_directive ( - ACE_TEXT_CHAR_TO_TCHAR (resource_factory_args)); + // Any arguments that don't match are ignored so that the + // caller can still use them. + arg_shifter.ignore_arg (); } + } - if (client_strategy_factory_args != 0) + return 0; + + } /* parse_private_args_i */ + + int + parse_global_args_i (int &argc, + char **argv, + CORBA::StringSeq &svc_config_argv) + { + +#if defined (TAO_DEBUG) && !defined (ACE_HAS_WINCE) + // Make it a little easier to debug programs using this code. + { + TAO_debug_level = ACE_Env_Value<u_int> ("TAO_ORB_DEBUG", 0); + + char * const value = ACE_OS::getenv ("TAO_ORB_DEBUG"); + + if (value != 0) { - ACE_Service_Config::process_directive ( - ACE_TEXT_CHAR_TO_TCHAR (client_strategy_factory_args)); + TAO_debug_level = ACE_OS::atoi (value); + + if (TAO_debug_level <= 0) + { + TAO_debug_level = 1; + } + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_debug_level == %d\n"), + TAO_debug_level)); } + } +#endif /* TAO_DEBUG && !ACE_HAS_WINCE */ - if (server_strategy_factory_args != 0) + + // Extract the Service Configurator ORB options from the argument + // vector. + ACE_Arg_Shifter arg_shifter (argc, argv); + CORBA::ULong len = 0; + + while (arg_shifter.is_anything_left ()) + { + const ACE_TCHAR *current_arg = 0; + if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDebug")) == 0) { - ACE_Service_Config::process_directive ( - ACE_TEXT_CHAR_TO_TCHAR (server_strategy_factory_args)); + // later, replace all of these + // warning this turns on a daemon + ACE::debug (1); + arg_shifter.consume_arg (); } + else if (0 != (current_arg = arg_shifter.get_the_parameter + (ACE_TEXT ("-ORBDebugLevel")))) + { + TAO_debug_level = + ACE_OS::atoi (current_arg); - return result; - } -} + arg_shifter.consume_arg (); + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDaemon")) == 0) + { + // Be a daemon + + len = svc_config_argv.length (); + svc_config_argv.length (len + 1); + + svc_config_argv[len] = CORBA::string_dup ("-b"); + arg_shifter.consume_arg (); + } + // Can't interpret this argument. Move on to the next argument. + else + { + // Any arguments that don't match are ignored so that the + // caller can still use them. + arg_shifter.ignore_arg (); + } + } + + return 0; + + } /* parse_global_args_i */ + + +} // TAO_BEGIN_VERSIONED_NAMESPACE_DECL -- ended prior to anonymous namespace. diff --git a/TAO/tao/TAO_Internal.h b/TAO/tao/TAO_Internal.h index e528980821c..3a40ef07bd6 100644 --- a/TAO/tao/TAO_Internal.h +++ b/TAO/tao/TAO_Internal.h @@ -24,6 +24,11 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +/// Forward declaration +class ACE_Service_Gestalt; +ACE_END_VERSIONED_NAMESPACE_DECL + TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO @@ -38,13 +43,14 @@ namespace TAO */ namespace ORB { - /// Extract ACE Service Configurator arguments from the given - /// argument vector, and initialize the ACE Service Configurator. /** + * Extract ACE Service Configurator arguments from the given + * argument vector, and initialize the ACE Service Configurator. + * * @note This method should be called before the ORB Core is * initialized, and before any ORBInitializers are invoked. */ - int open_services (int& argc, ACE_TCHAR** argv); + int open_services (ACE_Service_Gestalt* cfg, int& argc, ACE_TCHAR** argv); /** * The complement to @c open_services(), this will perform @@ -52,13 +58,16 @@ namespace TAO * should be called as many times as @c open_services(), and will * only actually close things down on the last call. It is fully * thread-safe. + * * @return @c 0 if successful, @c -1 with @c errno set if * failure. */ - int close_services (void); + int close_services (ACE_Service_Gestalt* pcfg); - /// Set default @c `svc.conf' content. This call has no effect if - /// This function must be called before first ORB initialization. + /** + * Set default @c `svc.conf' content. + * This function must be called before first ORB initialization. + */ void default_svc_conf_entries (char const * rf_args, char const * ssf_args, char const * csf_args); diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index b52665b7023..3de123a5310 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -62,11 +62,14 @@ TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) , wchar_codeset_descriptor_ (0) , resource_usage_strategy_ (TAO_Resource_Factory::TAO_EAGER) , drop_replies_ (true) + , principal_(0) { #if TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY == 1 this->resource_usage_strategy_ = TAO_Resource_Factory::TAO_LAZY; #endif /*TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY*/ + + } TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory (void) @@ -90,6 +93,8 @@ TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory (void) delete codeset_manager_; codeset_manager_ = 0; + + delete principal_; } int @@ -102,7 +107,8 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) // are useless if (this->factory_disabled_) { ACE_DEBUG ((LM_WARNING, - ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ignored\n") + ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ") + ACE_TEXT ("ignored\n") ACE_TEXT ("Default Resource Factory is disabled\n"))); return 0; } @@ -171,7 +177,8 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) -1); if (pset->insert (item) == -1) ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) Unable to add protocol factories for %s: %m\n"), + ACE_TEXT ("(%P|%t) Unable to add protocol factories ") + ACE_TEXT ("for %s: %m\n"), argv[curarg])); } } @@ -239,7 +246,8 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) // note is being written during 1.2.3 timeframe. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) This option would be deprecated \n") - ACE_TEXT ("(%P|%t) Please use -ORBConnectionPurgingStrategy instead \n"))); + ACE_TEXT ("(%P|%t) Please use -ORBConnectionPurgingStrategy ") + ACE_TEXT ("instead \n"))); if (curarg < argc) { @@ -1184,6 +1192,9 @@ TAO_Default_Resource_Factory::codeset_manager(void) "")); factory = ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); + + principal_ = new ACE_Dynamic_Service_Dependency (ACE_TEXT ("TAO_Codeset")); + #endif } if (factory == 0) diff --git a/TAO/tao/default_resource.h b/TAO/tao/default_resource.h index aef5e545fd7..8f022479fc5 100644 --- a/TAO/tao/default_resource.h +++ b/TAO/tao/default_resource.h @@ -17,6 +17,7 @@ #include /**/ "ace/pre.h" #include "ace/Service_Config.h" +#include "ace/Dynamic_Service_Dependency.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -257,6 +258,12 @@ private: /// Flag to indicate whether replies should be dropped during ORB /// shutdown. bool drop_replies_; + + // Makes a dependency on a specific dynamic service ("TAO_Codeset") explicit. + // It helps to keep the corresponding DLL around until the last instance + // is destroyed. Note that failure to delete the instances will "pin" the + // DLL in memory, preventing it from being unloaded on demand. + ACE_Dynamic_Service_Dependency *principal_; }; TAO_END_VERSIONED_NAMESPACE_DECL |