diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-07-20 11:37:05 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-07-20 11:37:05 +0000 |
commit | 22ba8ae094282a92328bfdec369fd594e1931b7a (patch) | |
tree | 376d55f00963fc1655c92dc4ffc25e6294f8e872 /TAO/tao | |
parent | 7eb36a581f927efcae141921765b83342addeb6f (diff) | |
download | ATCD-22ba8ae094282a92328bfdec369fd594e1931b7a.tar.gz |
ChangeLogTag: Thu Jul 20 10:24:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/Load_Protocol_Factory_T.h | 114 | ||||
-rw-r--r-- | TAO/tao/Strategies/advanced_resource.cpp | 270 | ||||
-rw-r--r-- | TAO/tao/default_resource.cpp | 83 | ||||
-rw-r--r-- | TAO/tao/tao.mpc | 1 |
4 files changed, 134 insertions, 334 deletions
diff --git a/TAO/tao/Load_Protocol_Factory_T.h b/TAO/tao/Load_Protocol_Factory_T.h new file mode 100644 index 00000000000..bd28f612e42 --- /dev/null +++ b/TAO/tao/Load_Protocol_Factory_T.h @@ -0,0 +1,114 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Load_Protocol_Factory_T.h + * + * $Id$ + * + * Function templates to load a protocol factory. + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef TAO_LOAD_PROTOCOL_FACTORY_T_H +#define TAO_LOAD_PROTOCOL_FACTORY_T_H + +#include /**/ "ace/pre.h" + +#include "tao/Protocol_Factory.h" +#include "ace/Auto_Ptr.h" +#include "ace/Dynamic_Service.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace details + { + template<typename T> + int + load_protocol_factory (TAO_ProtocolFactorySet protocol_set, + const ACE_TCHAR *name) + { + TAO_Protocol_Factory *protocol_factory = 0; + auto_ptr<TAO_Protocol_Factory> safe_protocol_factory; + + TAO_Protocol_Item *item = 0; + + // If a protocol factory is obtained from the Service + // Configurator then do not transfer ownership to the + // TAO_Protocol_Item. + bool transfer_ownership = false; + + protocol_factory = + ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (name); + + if (protocol_factory == 0) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_WARNING, + ACE_TEXT("(%P|%t) WARNING - No <%s> found in Service") + ACE_TEXT(" Repository. Using default instance.\n"), + name)); + + ACE_NEW_RETURN (protocol_factory, + T, + -1); + + ACE_AUTO_PTR_RESET (safe_protocol_factory, + protocol_factory, + TAO_Protocol_Factory); + + transfer_ownership = true; + } + else + { + transfer_ownership = false; + } + + ACE_NEW_RETURN (item, TAO_Protocol_Item (name), -1); + // If the TAO_Protocol_Item retains ownership of the + // TAO_Protocol_Factory then we used an auto_ptr<> above, so + // release the TAO_Protocol_Factory from it. Otherwise, we + // obtained the TAO_Protocol_Factory from the Service + // Configurator so an auto_ptr<> wasn't used since the Service + // Configurator retains ownership, hence there was no need to + // use an auto_ptr<> in this method. + item->factory ((transfer_ownership ? + safe_protocol_factory.release () : + protocol_factory), + transfer_ownership); + + if (protocol_set.insert (item) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT("TAO (%P|%t) Unable to add ") + ACE_TEXT("<%s> to protocol factory set.\n"), + ACE_TEXT_CHAR_TO_TCHAR(item->protocol_name ().c_str ()))); + + delete item; + + if (transfer_ownership == false) + delete protocol_factory; + + return -1; + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("TAO (%P|%t) Loaded default ") + ACE_TEXT("protocol <%s>\n"), + name)); + } + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_LOAD_PROTOCOL_FACTORY_T_H*/ diff --git a/TAO/tao/Strategies/advanced_resource.cpp b/TAO/tao/Strategies/advanced_resource.cpp index dc6c0a5886f..57d5fd5cdaa 100644 --- a/TAO/tao/Strategies/advanced_resource.cpp +++ b/TAO/tao/Strategies/advanced_resource.cpp @@ -20,11 +20,9 @@ #include "tao/Leader_Follower.h" #include "tao/StringSeqC.h" #include "tao/ORB_Core.h" -#include "tao/Protocol_Factory.h" +#include "tao/Load_Protocol_Factory_T.h" #include "ace/Arg_Shifter.h" -#include "ace/Auto_Ptr.h" -#include "ace/Dynamic_Service.h" #include "ace/Service_Config.h" #include "ace/Select_Reactor.h" #include "ace/WFMO_Reactor.h" @@ -60,7 +58,6 @@ TAO_Resource_Factory_Changer::TAO_Resource_Factory_Changer (void) #if TAO_HAS_SCIOP == 1 ACE_Service_Config::process_directive (ace_svc_desc_TAO_SCIOP_Protocol_Factory); #endif /* TAO_HAS_SCIOP == 1 */ - } TAO_Advanced_Resource_Factory::TAO_Advanced_Resource_Factory (void) @@ -303,6 +300,7 @@ TAO_Advanced_Resource_Factory::load_default_protocols (void) return 0; } + int TAO_Advanced_Resource_Factory::init_protocol_factories (void) { @@ -324,271 +322,33 @@ TAO_Advanced_Resource_Factory::init_protocol_factories (void) if (factory == end) { - TAO_Protocol_Factory *protocol_factory = 0; - auto_ptr<TAO_Protocol_Factory> safe_protocol_factory; - - TAO_Protocol_Item *item = 0; - - // If a protocol factory is obtained from the Service - // Configurator then do not transfer ownership to the - // TAO_Protocol_Item. - int transfer_ownership = 0; - - int r = this->load_default_protocols (); + int const r = this->load_default_protocols (); if (r == -1) return -1; #if TAO_HAS_UIOP == 1 - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("UIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_WARNING, - ACE_TEXT("(%P|%t) WARNING - No %s found in Service Repository.") - ACE_TEXT(" Using default instance.\n"), - ACE_TEXT("UIOP Protocol Factory"))); - - ACE_NEW_RETURN (protocol_factory, - TAO_UIOP_Protocol_Factory, - -1); - - ACE_AUTO_PTR_RESET (safe_protocol_factory, - protocol_factory, - TAO_Protocol_Factory); - - transfer_ownership = 1; - } - else - { - transfer_ownership = 0; - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("UIOP_Factory"), -1); - // If the TAO_Protocol_Item retains ownership of the - // TAO_Protocol_Factory then we used an auto_ptr<> above, so - // release the TAO_Protocol_Factory from it. Otherwise, we - // obtained the TAO_Protocol_Factory from the Service - // Configurator so an auto_ptr<> wasn't used since the Service - // Configurator retains ownership, hence there was no need to - // use an auto_ptr<> in this method. - item->factory ((transfer_ownership ? - safe_protocol_factory.release () : - protocol_factory), - transfer_ownership); - - if (this->protocol_factories_.insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("TAO (%P|%t) Unable to add ") - ACE_TEXT("<%s> to protocol factory set.\n"), - ACE_TEXT_CHAR_TO_TCHAR(item->protocol_name ().c_str ()))); - - delete item; - - if (transfer_ownership == 0) - delete protocol_factory; - - return -1; - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("TAO (%P|%t) Loaded default ") - ACE_TEXT("protocol <UIOP_Factory>\n"))); - } + if (TAO::details::load_protocol_factory <TAO_UIOP_Protocol_Factory> ( + this->protocol_factories_, "UIOP_Factory") == -1) + return -1; #endif /* TAO_HAS_UIOP == 1 */ #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0) - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("SHMIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_WARNING, - ACE_TEXT("(%P|%t) WARNING - No %s found in Service Repository.") - ACE_TEXT(" Using default instance.\n"), - ACE_TEXT("SHMIOP Protocol Factory"))); - - ACE_NEW_RETURN (protocol_factory, - TAO_SHMIOP_Protocol_Factory, - -1); - - ACE_AUTO_PTR_RESET (safe_protocol_factory, - protocol_factory, - TAO_Protocol_Factory); - - transfer_ownership = 1; - } - else - { - transfer_ownership = 0; - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("SHMIOP_Factory"), -1); - // If the TAO_Protocol_Item retains ownership of the - // TAO_Protocol_Factory then we used an auto_ptr<> above, so - // release the TAO_Protocol_Factory from it. Otherwise, we - // obtained the TAO_Protocol_Factory from the Service - // Configurator so an auto_ptr<> wasn't used since the Service - // Configurator retains ownership, hence there was no need to - // use an auto_ptr<> in this method. - item->factory ((transfer_ownership ? - safe_protocol_factory.release () : - protocol_factory), - transfer_ownership); - - if (this->protocol_factories_.insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("TAO (%P|%t) Unable to add ") - ACE_TEXT("<%s> to protocol factory set.\n"), - ACE_TEXT_CHAR_TO_TCHAR(item->protocol_name ().c_str ()))); - - delete item; - - if (transfer_ownership == 0) - delete protocol_factory; - - return -1; - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("TAO (%P|%t) Loaded default ") - ACE_TEXT("protocol <SHMIOP_Factory>\n"))); - } + if (TAO::details::load_protocol_factory <TAO_SHMIOP_Protocol_Factory> ( + this->protocol_factories_, "SHMIOP_Factory") == -1) + return -1; #endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */ #if defined (TAO_HAS_DIOP) && (TAO_HAS_DIOP != 0) - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("DIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_WARNING, - ACE_TEXT("(%P|%t) WARNING - No %s found in Service Repository.") - ACE_TEXT(" Using default instance.\n"), - ACE_TEXT("DIOP Protocol Factory"))); - - ACE_NEW_RETURN (protocol_factory, - TAO_DIOP_Protocol_Factory, - -1); - - ACE_AUTO_PTR_RESET (safe_protocol_factory, - protocol_factory, - TAO_Protocol_Factory); - - transfer_ownership = 1; - } - else - { - transfer_ownership = 0; - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("DIOP_Factory"), -1); - // If the TAO_Protocol_Item retains ownership of the - // TAO_Protocol_Factory then we used an auto_ptr<> above, so - // release the TAO_Protocol_Factory from it. Otherwise, we - // obtained the TAO_Protocol_Factory from the Service - // Configurator so an auto_ptr<> wasn't used since the Service - // Configurator retains ownership, hence there was no need to - // use an auto_ptr<> in this method. - item->factory ((transfer_ownership ? - safe_protocol_factory.release () : - protocol_factory), - transfer_ownership); - - if (this->protocol_factories_.insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("TAO (%P|%t) Unable to add ") - ACE_TEXT("<%s> to protocol factory set.\n"), - ACE_TEXT_CHAR_TO_TCHAR(item->protocol_name ().c_str ()))); - - delete item; - - if (transfer_ownership == 0) - delete protocol_factory; - - return -1; - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("TAO (%P|%t) Loaded default ") - ACE_TEXT("protocol <DIOP_Factory>\n"))); - } + if (TAO::details::load_protocol_factory <TAO_DIOP_Protocol_Factory> ( + this->protocol_factories_, "DIOP_Factory") == -1) + return -1; #endif /* TAO_HAS_DIOP && TAO_HAS_DIOP != 0 */ #if defined (TAO_HAS_SCIOP) && (TAO_HAS_SCIOP != 0) - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("SCIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_WARNING, - ACE_TEXT("(%P|%t) WARNING - No %s found in Service Repository.") - ACE_TEXT(" Using default instance.\n"), - ACE_TEXT("SCIOP Protocol Factory"))); - - ACE_NEW_RETURN (protocol_factory, - TAO_SCIOP_Protocol_Factory, - -1); - - ACE_AUTO_PTR_RESET (safe_protocol_factory, - protocol_factory, - TAO_Protocol_Factory); - - transfer_ownership = 1; - } - else - { - transfer_ownership = 0; - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("SCIOP_Factory"), -1); - // If the TAO_Protocol_Item retains ownership of the - // TAO_Protocol_Factory then we used an auto_ptr<> above, so - // release the TAO_Protocol_Factory from it. Otherwise, we - // obtained the TAO_Protocol_Factory from the Service - // Configurator so an auto_ptr<> wasn't used since the Service - // Configurator retains ownership, hence there was no need to - // use an auto_ptr<> in this method. - item->factory ((transfer_ownership ? - safe_protocol_factory.release () : - protocol_factory), - transfer_ownership); - - if (this->protocol_factories_.insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("TAO (%P|%t) Unable to add ") - ACE_TEXT("<%s> to protocol factory set.\n"), - ACE_TEXT_CHAR_TO_TCHAR(item->protocol_name ().c_str ()))); - - delete item; - - if (transfer_ownership == 0) - delete protocol_factory; - - return -1; - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("TAO (%P|%t) Loaded default ") - ACE_TEXT("protocol <SCIOP_Factory>\n"))); - } + if (TAO::details::load_protocol_factory <TAO_SCIOP_Protocol_Factory> ( + this->protocol_factories_, "SCIOP_Factory") == -1) + return -1; #endif /* TAO_HAS_SCIOP && TAO_HAS_SCIOP != 0 */ return 0; diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index 86385720c98..e77480caef3 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -4,7 +4,6 @@ #include "tao/debug.h" #include "tao/IIOP_Factory.h" -#include "tao/Protocol_Factory.h" #include "tao/Acceptor_Registry.h" #include "tao/Connector_Registry.h" #include "tao/Reactive_Flushing_Strategy.h" @@ -18,11 +17,10 @@ #include "tao/Null_Fragmentation_Strategy.h" #include "tao/On_Demand_Fragmentation_Strategy.h" #include "tao/MMAP_Allocator.h" +#include "tao/Load_Protocol_Factory_T.h" #include "ace/TP_Reactor.h" -#include "ace/Dynamic_Service.h" #include "ace/Malloc.h" -#include "ace/Auto_Ptr.h" #include "ace/Reactor.h" #include "ace/Malloc_T.h" #include "ace/Local_Memory_Pool.h" @@ -635,82 +633,9 @@ TAO_Default_Resource_Factory::load_default_protocols (void) // the `/etc/ld.so.conf' file on some UNIX systems. Remember to // run "ldconfig" if you modify `/etc/ld.so.conf'. - TAO_Protocol_Factory *protocol_factory = 0; - auto_ptr<TAO_Protocol_Factory> safe_protocol_factory; - - TAO_Protocol_Item *item = 0; - - // If a protocol factory is obtained from the Service - // Configurator then do not transfer ownership to the - // TAO_Protocol_Item. - bool transfer_ownership = false; - - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("IIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_WARNING, - ACE_TEXT ("TAO (%P|%t) No %s found in ") - ACE_TEXT ("Service Repository. ") - ACE_TEXT ("Using default instance IIOP ") - ACE_TEXT ("Protocol Factory.\n"), - ACE_TEXT ("IIOP Protocol Factory"))); - - ACE_NEW_RETURN (protocol_factory, - TAO_IIOP_Protocol_Factory, - -1); - - ACE_AUTO_PTR_RESET (safe_protocol_factory, - protocol_factory, - TAO_Protocol_Factory); - - transfer_ownership = true; - - } - else - { - transfer_ownership = false; - } - - ACE_NEW_RETURN (item, - TAO_Protocol_Item ("IIOP_Factory"), - -1); - // If the TAO_Protocol_Item retains ownership of the - // TAO_Protocol_Factory then we used an auto_ptr<> above, so - // release the TAO_Protocol_Factory from it. Otherwise, we - // obtained the TAO_Protocol_Factory from the Service - // Configurator so an auto_ptr<> wasn't used since the Service - // Configurator retains ownership, hence there was no need to - // use an auto_ptr<> in this method. - item->factory ((transfer_ownership ? - safe_protocol_factory.release () : - protocol_factory), - transfer_ownership); - - if (this->protocol_factories_.insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("TAO (%P|%t) Unable to add ") - ACE_TEXT ("<%s> to protocol factory set.\n"), - ACE_TEXT_CHAR_TO_TCHAR (item->protocol_name ().c_str ()))); - - delete item; - - if (transfer_ownership == 0) - delete protocol_factory; - - return -1; - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) Loaded default ") - ACE_TEXT ("protocol <IIOP_Factory>\n"))); - } - + if (TAO::details::load_protocol_factory <TAO_IIOP_Protocol_Factory> ( + this->protocol_factories_, "IIOP_Factory") == -1) + return -1; #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */ return 0; diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index fc0b5ee650d..0e27e192668 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -389,6 +389,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core, tao_vers LF_Invocation_Event.h LF_Strategy_Complete.h LF_Strategy.h + Load_Protocol_Factory_T.h LocalObject.h LocateRequest_Invocation_Adapter.h LocateRequest_Invocation.h |