00001
00002 #include "ace/Service_Config.h"
00003 #include "tao/Strategies/advanced_resource.h"
00004
00005 #include "tao/Strategies/UIOP_Factory.h"
00006 #include "tao/Strategies/SHMIOP_Factory.h"
00007 #include "tao/Strategies/DIOP_Factory.h"
00008 #include "tao/Strategies/SCIOP_Factory.h"
00009 #include "tao/Strategies/COIOP_Factory.h"
00010
00011 #include "tao/Strategies/LFU_Connection_Purging_Strategy.h"
00012 #include "tao/Strategies/FIFO_Connection_Purging_Strategy.h"
00013 #include "tao/Strategies/NULL_Connection_Purging_Strategy.h"
00014
00015 #include "tao/Strategies/LF_Strategy_Null.h"
00016
00017 #include "tao/debug.h"
00018 #include "tao/LRU_Connection_Purging_Strategy.h"
00019 #include "tao/LF_Strategy_Complete.h"
00020 #include "tao/LF_Follower.h"
00021 #include "tao/Leader_Follower.h"
00022 #include "tao/StringSeqC.h"
00023 #include "tao/ORB_Core.h"
00024 #include "tao/Load_Protocol_Factory_T.h"
00025
00026 #include "ace/Arg_Shifter.h"
00027 #include "ace/Service_Config.h"
00028 #include "ace/Select_Reactor.h"
00029 #include "ace/WFMO_Reactor.h"
00030 #include "ace/Msg_WFMO_Reactor.h"
00031 #include "ace/TP_Reactor.h"
00032 #include "ace/Dev_Poll_Reactor.h"
00033 #include "ace/Malloc_T.h"
00034 #include "ace/Local_Memory_Pool.h"
00035 #include "ace/Null_Mutex.h"
00036 #include "ace/OS_NS_strings.h"
00037
00038 ACE_RCSID(Strategies, advanced_resource, "$Id: advanced_resource.cpp 84281 2009-01-30 15:01:17Z wotte $")
00039
00040 #if !defined (TAO_DEFAULT_REACTOR_TYPE)
00041 #define TAO_DEFAULT_REACTOR_TYPE TAO_REACTOR_TP
00042 #endif
00043
00044 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00045
00046 TAO_Resource_Factory_Changer::TAO_Resource_Factory_Changer (void)
00047 {
00048
00049 TAO_ORB_Core::set_resource_factory ("Advanced_Resource_Factory");
00050 ACE_Service_Config::process_directive (ace_svc_desc_TAO_Advanced_Resource_Factory);
00051
00052 #if TAO_HAS_UIOP == 1
00053 ACE_Service_Config::process_directive (ace_svc_desc_TAO_UIOP_Protocol_Factory);
00054 #endif
00055
00056 #if TAO_HAS_SHMIOP == 1
00057 ACE_Service_Config::process_directive (ace_svc_desc_TAO_SHMIOP_Protocol_Factory);
00058 #endif
00059
00060 #if TAO_HAS_DIOP == 1
00061 ACE_Service_Config::process_directive (ace_svc_desc_TAO_DIOP_Protocol_Factory);
00062 #endif
00063
00064 #if TAO_HAS_SCIOP == 1
00065 ACE_Service_Config::process_directive (ace_svc_desc_TAO_SCIOP_Protocol_Factory);
00066 #endif
00067
00068 #if TAO_HAS_COIOP == 1
00069 ACE_Service_Config::process_directive (ace_svc_desc_TAO_COIOP_Protocol_Factory);
00070 #endif
00071 }
00072
00073 TAO_Advanced_Resource_Factory::TAO_Advanced_Resource_Factory (void)
00074 : reactor_type_ (TAO_DEFAULT_REACTOR_TYPE),
00075 threadqueue_type_ (TAO_THREAD_QUEUE_NOT_SET),
00076 cdr_allocator_type_ (TAO_ALLOCATOR_THREAD_LOCK),
00077 amh_response_handler_allocator_lock_type_ (TAO_ALLOCATOR_THREAD_LOCK),
00078 ami_response_handler_allocator_lock_type_ (TAO_ALLOCATOR_THREAD_LOCK)
00079 {
00080
00081 }
00082
00083 TAO_Advanced_Resource_Factory::~TAO_Advanced_Resource_Factory (void)
00084 {
00085
00086 TAO_ProtocolFactorySetItor end = this->protocol_factories_.end ();
00087
00088 for (TAO_ProtocolFactorySetItor iterator =
00089 this->protocol_factories_.begin ();
00090 iterator != end;
00091 ++iterator)
00092 delete *iterator;
00093
00094 this->protocol_factories_.reset ();
00095 }
00096
00097 int
00098 TAO_Advanced_Resource_Factory::init (int argc, ACE_TCHAR** argv)
00099 {
00100 ACE_TRACE ("TAO_Advanced_Resource_Factory::init");
00101
00102
00103
00104
00105 if (this->factory_disabled_)
00106 {
00107 ACE_DEBUG ((LM_WARNING,
00108 ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ignored\n")
00109 ACE_TEXT ("Advanced Resource Factory is disabled\n")));
00110 return 0;
00111 }
00112 this->options_processed_ = 1;
00113
00114
00115
00116
00117
00118
00119
00120 TAO_Resource_Factory *default_resource_factory =
00121 ACE_Dynamic_Service<TAO_Resource_Factory>::instance ("Resource_Factory");
00122 if (default_resource_factory != 0)
00123 {
00124 default_resource_factory->disable_factory ();
00125 }
00126
00127 ACE_Arg_Shifter arg_shifter (argc, argv);
00128
00129
00130 const ACE_TCHAR *current_arg = 0;
00131 while (arg_shifter.is_anything_left ())
00132 {
00133 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ORBReactorRegistry")) == 0)
00134 {
00135 ACE_ERROR_RETURN ((LM_ERROR,
00136 ACE_TEXT("TAO_Advanced_Resource_Factory::init - ")
00137 ACE_TEXT("-ORBReactorRegistry no longer supported\n")),
00138 -1);
00139
00140 }
00141 else if (0 != (current_arg = arg_shifter.get_the_parameter
00142 (ACE_TEXT("-ORBReactorLock"))))
00143 {
00144 ACE_DEBUG ((LM_DEBUG,
00145 ACE_TEXT("TAO_Advanced_Resource_Factory - obsolete -ORBReactorLock ")
00146 ACE_TEXT("option, please use -ORBReactorType\n")));
00147
00148 if (ACE_OS::strcasecmp (current_arg, ACE_TEXT("null")) == 0)
00149 this->reactor_type_ = TAO_REACTOR_SELECT_ST;
00150 else if (ACE_OS::strcasecmp (current_arg, ACE_TEXT("token")) == 0)
00151 this->reactor_type_= TAO_REACTOR_SELECT_MT;
00152
00153 arg_shifter.consume_arg ();
00154 }
00155 else if (0 != (current_arg = arg_shifter.get_the_parameter
00156 (ACE_TEXT("-ORBReactorType"))))
00157 {
00158 if (ACE_OS::strcasecmp (current_arg,
00159 ACE_TEXT("select_mt")) == 0)
00160 this->reactor_type_ = TAO_REACTOR_SELECT_MT;
00161 else if (ACE_OS::strcasecmp (current_arg,
00162 ACE_TEXT("select_st")) == 0)
00163 this->reactor_type_ = TAO_REACTOR_SELECT_ST;
00164 else if (ACE_OS::strcasecmp (current_arg,
00165 ACE_TEXT("wfmo")) == 0)
00166 #if defined(ACE_WIN32)
00167 this->reactor_type_ = TAO_REACTOR_WFMO;
00168 #else
00169 this->report_unsupported_error (ACE_TEXT("WFMO Reactor"));
00170 #endif
00171 else if (ACE_OS::strcasecmp (current_arg,
00172 ACE_TEXT("msg_wfmo")) == 0)
00173 #if defined(ACE_WIN32) && !defined (ACE_LACKS_MSG_WFMO)
00174 this->reactor_type_ = TAO_REACTOR_MSGWFMO;
00175 #else
00176 this->report_unsupported_error (ACE_TEXT("MsgWFMO Reactor"));
00177 #endif
00178
00179 else if (ACE_OS::strcasecmp (current_arg,
00180 ACE_TEXT("tp")) == 0)
00181 this->reactor_type_ = TAO_REACTOR_TP;
00182
00183 else if (ACE_OS::strcasecmp (current_arg,
00184 ACE_TEXT("dev_poll")) == 0)
00185 {
00186 #if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
00187 this->reactor_type_ = TAO_REACTOR_DEV_POLL;
00188 #else
00189 this->report_unsupported_error (ACE_TEXT ("Dev_Poll Reactor"));
00190 #endif
00191 }
00192
00193 else if (ACE_OS::strcasecmp (current_arg,
00194 ACE_TEXT("fl")) == 0)
00195 this->report_option_value_error (
00196 ACE_TEXT("FlReactor not supported by Advanced_Resources_Factory. Please use TAO_FlResource_Loader instead."),
00197 current_arg);
00198 else if (ACE_OS::strcasecmp (current_arg,
00199 ACE_TEXT("tk")) == 0)
00200 this->report_option_value_error (
00201 ACE_TEXT("TkReactor not supported by Advanced_Resources_Factory. Please use TAO_TkResource_Loader instead."),
00202 current_arg);
00203 else
00204 this->report_option_value_error (ACE_TEXT("-ORBReactorType"), current_arg);
00205
00206 arg_shifter.consume_arg ();
00207 }
00208 else if (0 != (current_arg = arg_shifter.get_the_parameter
00209 (ACE_TEXT("-ORBInputCDRAllocator"))))
00210 {
00211 if (ACE_OS::strcasecmp (current_arg,
00212 ACE_TEXT("null")) == 0)
00213 {
00214 this->cdr_allocator_type_ = TAO_ALLOCATOR_NULL_LOCK;
00215 this->use_locked_data_blocks_ = 0;
00216 }
00217 else if (ACE_OS::strcasecmp (current_arg,
00218 ACE_TEXT("thread")) == 0)
00219 {
00220 this->cdr_allocator_type_ = TAO_ALLOCATOR_THREAD_LOCK;
00221 this->use_locked_data_blocks_ = 1;
00222 }
00223 else
00224 {
00225 this->report_option_value_error (ACE_TEXT("-ORBInputCDRAllocator"), current_arg);
00226 }
00227
00228 arg_shifter.consume_arg ();
00229 }
00230 else if (0 != (current_arg = arg_shifter.get_the_parameter
00231 (ACE_TEXT("-ORBAMHResponseHandlerAllocator"))))
00232 {
00233 if (ACE_OS::strcasecmp (current_arg,
00234 ACE_TEXT("null")) == 0)
00235 {
00236 this->amh_response_handler_allocator_lock_type_ = TAO_ALLOCATOR_NULL_LOCK;
00237 }
00238 else if (ACE_OS::strcasecmp (current_arg,
00239 ACE_TEXT("thread")) == 0)
00240 {
00241 this->amh_response_handler_allocator_lock_type_ = TAO_ALLOCATOR_THREAD_LOCK;
00242 }
00243 else
00244 {
00245 this->report_option_value_error (ACE_TEXT("-ORBAMHResponseHandlerAllocator"), current_arg);
00246 }
00247
00248 arg_shifter.consume_arg ();
00249 }
00250 else if (0 != (current_arg = arg_shifter.get_the_parameter
00251 (ACE_TEXT("-ORBAMIResponseHandlerAllocator"))))
00252 {
00253 if (ACE_OS::strcasecmp (current_arg,
00254 ACE_TEXT("null")) == 0)
00255 {
00256 this->ami_response_handler_allocator_lock_type_ = TAO_ALLOCATOR_NULL_LOCK;
00257 }
00258 else if (ACE_OS::strcasecmp (current_arg,
00259 ACE_TEXT("thread")) == 0)
00260 {
00261 this->ami_response_handler_allocator_lock_type_ = TAO_ALLOCATOR_THREAD_LOCK;
00262 }
00263 else
00264 {
00265 this->report_option_value_error (ACE_TEXT("-ORBAMIResponseHandlerAllocator"), current_arg);
00266 }
00267
00268 arg_shifter.consume_arg ();
00269 }
00270 else if (0 != (current_arg = arg_shifter.get_the_parameter
00271 (ACE_TEXT("-ORBReactorThreadQueue"))))
00272 {
00273 if (ACE_OS::strcasecmp (current_arg,
00274 ACE_TEXT ("LIFO")) == 0)
00275 this->threadqueue_type_ = TAO_THREAD_QUEUE_LIFO;
00276 else if (ACE_OS::strcasecmp (current_arg,
00277 ACE_TEXT ("FIFO")) == 0)
00278 this->threadqueue_type_ = TAO_THREAD_QUEUE_FIFO;
00279 else
00280 this->report_option_value_error (ACE_TEXT ("-ORBReactorThreadQueue"),
00281 current_arg);
00282
00283 arg_shifter.consume_arg ();
00284 }
00285 else
00286
00287
00288 arg_shifter.ignore_arg ();
00289 }
00290
00291
00292
00293
00294 if (this->threadqueue_type_ != TAO_THREAD_QUEUE_NOT_SET &&
00295 this->reactor_type_ != TAO_REACTOR_TP)
00296 ACE_DEBUG ((LM_DEBUG,
00297 ACE_TEXT ("TAO_Advanced_Resource_Factory: -ORBReactorThreadQueue ")
00298 ACE_TEXT ("option can only be used with -ORBReactorType ")
00299 ACE_TEXT ("tp.\n")));
00300
00301 else if (this->threadqueue_type_ == TAO_THREAD_QUEUE_NOT_SET)
00302 this->threadqueue_type_ = TAO_THREAD_QUEUE_LIFO;
00303
00304 return this->TAO_Default_Resource_Factory::init (argc, argv);
00305 }
00306
00307 int
00308 TAO_Advanced_Resource_Factory::load_default_protocols (void)
00309 {
00310 int const r =
00311 this->TAO_Default_Resource_Factory::load_default_protocols ();
00312
00313 this->protocol_factories_ =
00314 this->TAO_Default_Resource_Factory::protocol_factories_;
00315
00316 this->TAO_Default_Resource_Factory::protocol_factories_.reset ();
00317
00318 if (r == -1)
00319 return -1;
00320
00321
00322 return 0;
00323 }
00324
00325
00326 int
00327 TAO_Advanced_Resource_Factory::init_protocol_factories (void)
00328 {
00329
00330
00331
00332
00333
00334 TAO_Resource_Factory *default_resource_factory =
00335 ACE_Dynamic_Service<TAO_Resource_Factory>::instance ("Resource_Factory");
00336 if (default_resource_factory != 0)
00337 {
00338 default_resource_factory->disable_factory();
00339 }
00340
00341 TAO_ProtocolFactorySetItor end = protocol_factories_.end ();
00342 TAO_ProtocolFactorySetItor factory = protocol_factories_.begin ();
00343
00344 if (factory == end)
00345 {
00346 int const r = this->load_default_protocols ();
00347
00348 if (r == -1)
00349 return -1;
00350
00351 #if TAO_HAS_UIOP == 1
00352 if (TAO::details::load_protocol_factory <TAO_UIOP_Protocol_Factory> (
00353 this->protocol_factories_, "UIOP_Factory") == -1)
00354 return -1;
00355 #endif
00356
00357 #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0)
00358 if (TAO::details::load_protocol_factory <TAO_SHMIOP_Protocol_Factory> (
00359 this->protocol_factories_, "SHMIOP_Factory") == -1)
00360 return -1;
00361 #endif
00362
00363 #if defined (TAO_HAS_DIOP) && (TAO_HAS_DIOP != 0)
00364 if (TAO::details::load_protocol_factory <TAO_DIOP_Protocol_Factory> (
00365 this->protocol_factories_, "DIOP_Factory") == -1)
00366 return -1;
00367 #endif
00368
00369 #if defined (TAO_HAS_SCIOP) && (TAO_HAS_SCIOP != 0)
00370 if (TAO::details::load_protocol_factory <TAO_SCIOP_Protocol_Factory> (
00371 this->protocol_factories_, "SCIOP_Factory") == -1)
00372 return -1;
00373 #endif
00374
00375 #if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
00376 if (TAO::details::load_protocol_factory <TAO_COIOP_Protocol_Factory> (
00377 this->protocol_factories_, "COIOP_Factory") == -1)
00378 return -1;
00379 #endif
00380
00381 return 0;
00382
00383 }
00384
00385 for (; factory != end; factory++)
00386 {
00387 const ACE_CString &name = (*factory)->protocol_name ();
00388
00389 (*factory)->factory (
00390 ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (name.c_str ()));
00391 if ((*factory)->factory () == 0)
00392 {
00393 ACE_ERROR_RETURN ((LM_ERROR,
00394 ACE_TEXT("TAO (%P|%t) Unable to load ")
00395 ACE_TEXT("protocol <%C>, %m\n"),
00396 name.c_str ()),
00397 -1);
00398 }
00399
00400 if (TAO_debug_level > 0)
00401 {
00402 ACE_DEBUG ((LM_DEBUG,
00403 ACE_TEXT("TAO (%P|%t) Loaded protocol <%C>\n"),
00404 name.c_str ()));
00405 }
00406 }
00407 return 0;
00408 }
00409
00410
00411
00412 TAO_ProtocolFactorySet *
00413 TAO_Advanced_Resource_Factory::get_protocol_factories (void)
00414 {
00415 return &protocol_factories_;
00416 }
00417
00418 ACE_Reactor_Impl *
00419 TAO_Advanced_Resource_Factory::allocate_reactor_impl (void) const
00420 {
00421 ACE_Reactor_Impl *impl = 0;
00422
00423
00424
00425
00426
00427 switch (this->reactor_type_)
00428 {
00429 case TAO_REACTOR_SELECT_MT:
00430 ACE_NEW_RETURN (impl,
00431 TAO_REACTOR ((ACE_Sig_Handler*)0,
00432 (ACE_Timer_Queue*)0,
00433 0,
00434 (ACE_Reactor_Notify*)0,
00435 this->reactor_mask_signals_),
00436 0);
00437 break;
00438
00439 case TAO_REACTOR_SELECT_ST:
00440 ACE_NEW_RETURN (impl,
00441 TAO_NULL_LOCK_REACTOR ((ACE_Sig_Handler*)0,
00442 (ACE_Timer_Queue*)0,
00443 0,
00444 (ACE_Reactor_Notify*)0,
00445 this->reactor_mask_signals_),
00446 0);
00447 break;
00448
00449 case TAO_REACTOR_WFMO:
00450 #if defined(ACE_WIN32)
00451 ACE_NEW_RETURN (impl, ACE_WFMO_Reactor, 0);
00452 #endif
00453 break;
00454
00455 #if defined(ACE_WIN32) \
00456 && !defined (ACE_LACKS_MSG_WFMO) \
00457 && !defined (ACE_HAS_WINCE) \
00458 && !defined (ACE_HAS_PHARLAP)
00459 case TAO_REACTOR_MSGWFMO:
00460 ACE_NEW_RETURN (impl, ACE_Msg_WFMO_Reactor, 0);
00461 break;
00462 #endif
00463
00464 #if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
00465 case TAO_REACTOR_DEV_POLL:
00466 ACE_NEW_RETURN (impl,
00467 ACE_Dev_Poll_Reactor (ACE::max_handles (),
00468 1,
00469 (ACE_Sig_Handler*)0,
00470 (ACE_Timer_Queue*)0,
00471 0,
00472 0,
00473 this->reactor_mask_signals_,
00474 ACE_Select_Reactor_Token::LIFO),
00475 0);
00476 break;
00477 #endif
00478
00479 default:
00480 case TAO_REACTOR_TP:
00481 ACE_NEW_RETURN (impl,
00482 ACE_TP_Reactor (ACE::max_handles (),
00483 1,
00484 (ACE_Sig_Handler*)0,
00485 (ACE_Timer_Queue*)0,
00486 this->reactor_mask_signals_,
00487 this->threadqueue_type_ == TAO_THREAD_QUEUE_FIFO ?
00488 ACE_Select_Reactor_Token::FIFO :
00489 ACE_Select_Reactor_Token::LIFO),
00490 0);
00491 break;
00492 }
00493
00494
00495
00496 return impl;
00497 }
00498
00499 typedef ACE_Malloc<ACE_LOCAL_MEMORY_POOL,ACE_Null_Mutex> NULL_LOCK_MALLOC;
00500 typedef ACE_Allocator_Adapter<NULL_LOCK_MALLOC> NULL_LOCK_ALLOCATOR;
00501
00502 ACE_Allocator *
00503 TAO_Advanced_Resource_Factory::input_cdr_dblock_allocator (void)
00504 {
00505 ACE_Allocator *allocator = 0;
00506 switch (this->cdr_allocator_type_)
00507 {
00508 case TAO_ALLOCATOR_NULL_LOCK:
00509 ACE_NEW_RETURN (allocator,
00510 NULL_LOCK_ALLOCATOR,
00511 0);
00512 break;
00513 default:
00514 return
00515 this->TAO_Default_Resource_Factory::input_cdr_dblock_allocator();
00516 }
00517
00518 return allocator;
00519 }
00520
00521 ACE_Allocator *
00522 TAO_Advanced_Resource_Factory::input_cdr_buffer_allocator (void)
00523 {
00524 ACE_Allocator *allocator = 0;
00525 switch (this->cdr_allocator_type_)
00526 {
00527 case TAO_ALLOCATOR_NULL_LOCK:
00528 ACE_NEW_RETURN (allocator,
00529 NULL_LOCK_ALLOCATOR,
00530 0);
00531 break;
00532 default:
00533 return
00534 this->TAO_Default_Resource_Factory::input_cdr_buffer_allocator();
00535 }
00536 return allocator;
00537 }
00538
00539 ACE_Allocator *
00540 TAO_Advanced_Resource_Factory::input_cdr_msgblock_allocator (void)
00541 {
00542 ACE_Allocator *allocator = 0;
00543 switch (this->cdr_allocator_type_)
00544 {
00545 case TAO_ALLOCATOR_NULL_LOCK:
00546 ACE_NEW_RETURN (allocator,
00547 NULL_LOCK_ALLOCATOR,
00548 0);
00549 break;
00550 default:
00551 return
00552 this->TAO_Default_Resource_Factory::input_cdr_msgblock_allocator();
00553 }
00554
00555 return allocator;
00556 }
00557
00558 ACE_Allocator *
00559 TAO_Advanced_Resource_Factory::amh_response_handler_allocator (void)
00560 {
00561 ACE_Allocator *allocator = 0;
00562 switch (this->amh_response_handler_allocator_lock_type_)
00563 {
00564 case TAO_ALLOCATOR_NULL_LOCK:
00565 ACE_NEW_RETURN (allocator,
00566 NULL_LOCK_ALLOCATOR,
00567 0);
00568 break;
00569 default:
00570 return
00571 this->TAO_Default_Resource_Factory::amh_response_handler_allocator();
00572 }
00573
00574 return allocator;
00575 }
00576
00577 ACE_Allocator *
00578 TAO_Advanced_Resource_Factory::ami_response_handler_allocator (void)
00579 {
00580 ACE_Allocator *allocator = 0;
00581 switch (this->ami_response_handler_allocator_lock_type_)
00582 {
00583 case TAO_ALLOCATOR_NULL_LOCK:
00584 ACE_NEW_RETURN (allocator,
00585 NULL_LOCK_ALLOCATOR,
00586 0);
00587 break;
00588 default:
00589 return
00590 this->TAO_Default_Resource_Factory::ami_response_handler_allocator();
00591 }
00592
00593 return allocator;
00594 }
00595
00596 int
00597 TAO_Advanced_Resource_Factory::input_cdr_allocator_type_locked (void)
00598 {
00599 return this->cdr_allocator_type_ == TAO_ALLOCATOR_NULL_LOCK ? 0 : 1;
00600 }
00601
00602 TAO_Connection_Purging_Strategy *
00603 TAO_Advanced_Resource_Factory::create_purging_strategy (void)
00604 {
00605 TAO_Connection_Purging_Strategy *strategy = 0;
00606
00607 switch(this->connection_purging_type_)
00608 {
00609 case TAO_Resource_Factory::LFU:
00610 ACE_NEW_RETURN (strategy,
00611 TAO_LFU_Connection_Purging_Strategy (
00612 this->cache_maximum ()),
00613 0);
00614 break;
00615 case TAO_Resource_Factory::FIFO:
00616 ACE_NEW_RETURN (strategy,
00617 TAO_FIFO_Connection_Purging_Strategy (
00618 this->cache_maximum ()),
00619 0);
00620 break;
00621 case TAO_Resource_Factory::NOOP:
00622 ACE_NEW_RETURN (strategy,
00623 TAO_NULL_Connection_Purging_Strategy (
00624 this->cache_maximum ()),
00625 0);
00626 break;
00627 case TAO_Resource_Factory::LRU:
00628 ACE_NEW_RETURN (strategy,
00629 TAO_LRU_Connection_Purging_Strategy (
00630 this->cache_maximum ()),
00631 0);
00632 break;
00633 default:
00634 ACE_ERROR ((LM_ERROR,
00635 ACE_TEXT("TAO (%P|%t) - ")
00636 ACE_TEXT("Unknown connection purging strategy ")
00637 ACE_TEXT("type was found.\n")));
00638 }
00639
00640 return strategy;
00641 }
00642
00643 TAO_LF_Strategy *
00644 TAO_Advanced_Resource_Factory::create_lf_strategy (void)
00645 {
00646 TAO_LF_Strategy *strategy = 0;
00647
00648 if (this->reactor_type_ == TAO_REACTOR_SELECT_ST)
00649 {
00650 ACE_NEW_RETURN (strategy,
00651 TAO_LF_Strategy_Null,
00652 0);
00653 }
00654 else
00655 {
00656 ACE_NEW_RETURN (strategy,
00657 TAO_LF_Strategy_Complete,
00658 0);
00659 }
00660 return strategy;
00661 }
00662
00663 void
00664 TAO_Advanced_Resource_Factory::report_option_value_error (
00665 const ACE_TCHAR* option_name,
00666 const ACE_TCHAR* option_value)
00667 {
00668 ACE_DEBUG((LM_DEBUG,
00669 ACE_TEXT("Advanced_Resource_Factory - unknown argument")
00670 ACE_TEXT(" <%s> for <%s>\n"),
00671 option_value,
00672 option_name));
00673 }
00674
00675 void
00676 TAO_Advanced_Resource_Factory::report_unsupported_error (
00677 const ACE_TCHAR* option_name)
00678 {
00679 ACE_DEBUG((LM_DEBUG,
00680 ACE_TEXT("Advanced_Resource_Factory - <%s>")
00681 ACE_TEXT(" not supported on this platform\n"),
00682 option_name));
00683 }
00684
00685
00686
00687
00688 ACE_STATIC_SVC_DEFINE (TAO_Advanced_Resource_Factory,
00689 ACE_TEXT("Advanced_Resource_Factory"),
00690 ACE_SVC_OBJ_T,
00691 &ACE_SVC_NAME (TAO_Advanced_Resource_Factory),
00692 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00693 0)
00694 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_Advanced_Resource_Factory)
00695
00696
00697 TAO_END_VERSIONED_NAMESPACE_DECL