diff options
Diffstat (limited to 'TAO/tao/Strategies/advanced_resource.cpp')
-rw-r--r-- | TAO/tao/Strategies/advanced_resource.cpp | 289 |
1 files changed, 169 insertions, 120 deletions
diff --git a/TAO/tao/Strategies/advanced_resource.cpp b/TAO/tao/Strategies/advanced_resource.cpp index 029c6c1932b..7b64336690a 100644 --- a/TAO/tao/Strategies/advanced_resource.cpp +++ b/TAO/tao/Strategies/advanced_resource.cpp @@ -71,143 +71,159 @@ TAO_Advanced_Resource_Factory::init (int argc, char **argv) { ACE_TRACE ("TAO_Advanced_Resource_Factory::init"); + // If this factory has already been disabled then + // print a warning and exit because any options + // are useless + if (this->factory_disabled_) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ignored\n") + ACE_TEXT ("Default Resource Factory is disabled\n"))); + return 0; + } + this->options_processed_ = 1; + + // If the default resource factory exists, then disable it. + // This causes any directives for the "Resource_Factory" to + // report warnings. + // Note: this is also being done in init_protocol_factories() + // to cover the case where init() is not called. + TAO_Resource_Factory *default_resource_factory = + ACE_Dynamic_Service<TAO_Resource_Factory>::instance ("Resource_Factory"); + if (default_resource_factory != 0) + { + default_resource_factory->disable_factory(); + } + int curarg = 0; + int unused_argc = 0; + char* unused_argv[argc+1]; for (curarg = 0; curarg < argc; curarg++) - if (ACE_OS::strcasecmp (argv[curarg], - "-ORBReactorRegistry") == 0) - { - - curarg++; - if (curarg < argc) - { - char *name = argv[curarg]; - - if (ACE_OS::strcasecmp (name, - "single") == 0) - this->reactor_registry_type_ = TAO_SINGLE_REACTOR; - else if (ACE_OS::strcasecmp (name, - "per-priority") == 0) - this->reactor_registry_type_ = TAO_REACTOR_PER_PRIORITY; - else - ACE_DEBUG((LM_DEBUG, - ACE_TEXT ("TAO_Default_Factory - unknown argument") - ACE_TEXT (" <%s> for -ORBReactorRegistry\n"), name)); - } - } - - else if (ACE_OS::strcasecmp (argv[curarg], - "-ORBReactorLock") == 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO_Default_Resource obsolete -ORBReactorLock ") - ACE_TEXT ("option, please use -ORBReactorType\n"))); - curarg++; - if (curarg < argc) - { - char *name = argv[curarg]; - - if (ACE_OS::strcasecmp (name, "null") == 0) - this->reactor_type_ = TAO_REACTOR_SELECT_ST; - else if (ACE_OS::strcasecmp (name, "token") == 0) - this->reactor_type_= TAO_REACTOR_SELECT_MT; - } - } - - else if (ACE_OS::strcasecmp (argv[curarg], - "-ORBReactorType") == 0) - { - curarg++; - if (curarg < argc) - { - char *name = argv[curarg]; - - if (ACE_OS::strcasecmp (name, - "select_mt") == 0) - this->reactor_type_ = TAO_REACTOR_SELECT_MT; - else if (ACE_OS::strcasecmp (name, - "select_st") == 0) - this->reactor_type_ = TAO_REACTOR_SELECT_ST; - else if (ACE_OS::strcasecmp (name, - "fl") == 0) + { + if (ACE_OS::strcasecmp (argv[curarg], + "-ORBReactorRegistry") == 0) + { + + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "single") == 0) + this->reactor_registry_type_ = TAO_SINGLE_REACTOR; + else if (ACE_OS::strcasecmp (name, + "per-priority") == 0) + this->reactor_registry_type_ = TAO_REACTOR_PER_PRIORITY; + else + this->report_option_value_error ("-ORBReactorRegistry", name); + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBReactorLock") == 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Advanced_Resource_Factory - obsolete -ORBReactorLock ") + ACE_TEXT ("option, please use -ORBReactorType\n"))); + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, "null") == 0) + this->reactor_type_ = TAO_REACTOR_SELECT_ST; + else if (ACE_OS::strcasecmp (name, "token") == 0) + this->reactor_type_= TAO_REACTOR_SELECT_MT; + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBReactorType") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "select_mt") == 0) + this->reactor_type_ = TAO_REACTOR_SELECT_MT; + else if (ACE_OS::strcasecmp (name, + "select_st") == 0) + this->reactor_type_ = TAO_REACTOR_SELECT_ST; + else if (ACE_OS::strcasecmp (name, + "fl") == 0) #if defined(ACE_HAS_FL) - this->reactor_type_ = TAO_REACTOR_FL; + this->reactor_type_ = TAO_REACTOR_FL; #else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO_Advanced_Factory - FlReactor") - ACE_TEXT (" not supported on this platform\n"))); + this->report_unsupported_error ("FlReactor"); #endif /* ACE_HAS_FL */ - else if (ACE_OS::strcasecmp (name, "tk_reactor") == 0) + else if (ACE_OS::strcasecmp (name, "tk_reactor") == 0) #if defined(ACE_HAS_TK) - this->reactor_type_ = TAO_REACTOR_TK; + this->reactor_type_ = TAO_REACTOR_TK; #else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO_Advanced_Factory - TkReactor") - ACE_TEXT (" not supported on this platform\n"))); + this->report_unsupported_error ("TkReactor"); #endif /* ACE_HAS_TK */ - else if (ACE_OS::strcasecmp (name, + else if (ACE_OS::strcasecmp (name, "wfmo") == 0) #if defined(ACE_WIN32) - this->reactor_type_ = TAO_REACTOR_WFMO; + this->reactor_type_ = TAO_REACTOR_WFMO; #else - ACE_DEBUG ((LM_DEBUG, - "TAO_Advanced_Factory - WFMO Reactor" - " not supported on this platform\n")); + this->report_unsupported_error ("WFMO Reactor"); #endif /* ACE_WIN32 */ - else if (ACE_OS::strcasecmp (name, - "msg_wfmo") == 0) + else if (ACE_OS::strcasecmp (name, + "msg_wfmo") == 0) #if defined(ACE_WIN32) - this->reactor_type_ = TAO_REACTOR_MSGWFMO; + this->reactor_type_ = TAO_REACTOR_MSGWFMO; #else - ACE_DEBUG ((LM_DEBUG, - "TAO_Advanced_Factory - MsgWFMO Reactor" - " not supported on this platform\n")); + this->report_unsupported_error ("MsgWFMO Reactor"); #endif /* ACE_WIN32 */ - else if (ACE_OS::strcasecmp (name, - "tp") == 0) - this->reactor_type_ = TAO_REACTOR_TP; - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO_Advanced_Factory - unknown argument") - ACE_TEXT (" <%s> for -ORBreactortype\n"), name)); - } - } - - else if (ACE_OS::strcasecmp (argv[curarg], - "-ORBInputCDRAllocator") == 0) - { - curarg++; - if (curarg < argc) - { - char *name = argv[curarg]; - - if (ACE_OS::strcasecmp (name, - "null") == 0) - { - this->cdr_allocator_type_ = TAO_ALLOCATOR_NULL_LOCK; - this->use_locked_data_blocks_ = 0; - } - else if (ACE_OS::strcasecmp (name, - "thread") == 0) - { - this->cdr_allocator_type_ = TAO_ALLOCATOR_THREAD_LOCK; - this->use_locked_data_blocks_ = 1; - } - } - } - else - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_ERROR, - ACE_TEXT ("TAO_Advanced_Factory: Unknown option ") - ACE_TEXT ("<%s>.\n"), - argv[curarg])); - } - } - - this->TAO_Default_Resource_Factory::init (argc, argv); + else if (ACE_OS::strcasecmp (name, + "tp") == 0) + this->reactor_type_ = TAO_REACTOR_TP; + else + this->report_option_value_error ("-ORBReactorType", name); + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBInputCDRAllocator") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "null") == 0) + { + this->cdr_allocator_type_ = TAO_ALLOCATOR_NULL_LOCK; + this->use_locked_data_blocks_ = 0; + } + else if (ACE_OS::strcasecmp (name, + "thread") == 0) + { + this->cdr_allocator_type_ = TAO_ALLOCATOR_THREAD_LOCK; + this->use_locked_data_blocks_ = 1; + } + else + { + this->report_option_value_error ("-ORBInputCDRAllocator", name); + } + } + } + else + { + unused_argv[unused_argc] = argv[curarg]; + unused_argc++; + } + } + + unused_argv[unused_argc] = 0; + + this->TAO_Default_Resource_Factory::init (unused_argc, unused_argv); return 0; } @@ -229,6 +245,18 @@ TAO_Advanced_Resource_Factory::load_default_protocols (void) int TAO_Advanced_Resource_Factory::init_protocol_factories (void) { + // If the default resource factory exists, then disable it. + // This causes any directives for the "Resource_Factory" to + // report warnings. + // This is needed to ensure warnings when no static directive + // for this factory is used (and init() is not called). + TAO_Resource_Factory *default_resource_factory = + ACE_Dynamic_Service<TAO_Resource_Factory>::instance ("Resource_Factory"); + if (default_resource_factory != 0) + { + default_resource_factory->disable_factory(); + } + TAO_ProtocolFactorySetItor end = protocol_factories_.end (); TAO_ProtocolFactorySetItor factory = protocol_factories_.begin (); @@ -691,6 +719,27 @@ TAO_Advanced_Resource_Factory::create_lf_strategy (void) return strategy; } +void +TAO_Advanced_Resource_Factory::report_option_value_error ( + const char* option_name, + const char* option_value) +{ + ACE_DEBUG((LM_DEBUG, + ACE_TEXT ("Advanced_Resource_Factory - unknown argument") + ACE_TEXT (" <%s> for <%s>\n"), + option_value, option_name)); +} + +void +TAO_Advanced_Resource_Factory::report_unsupported_error ( + const char* option_name) +{ + ACE_DEBUG((LM_DEBUG, + ACE_TEXT ("Advanced_Resource_Factory - <%s>") + ACE_TEXT (" not supported on this platform\n"), + option_name)); +} + // **************************************************************** ACE_STATIC_SVC_DEFINE (TAO_Advanced_Resource_Factory, |