00001
00002
00003 #include "tao/default_resource.h"
00004
00005 #include "tao/debug.h"
00006 #include "tao/IIOP_Factory.h"
00007 #include "tao/Acceptor_Registry.h"
00008 #include "tao/Connector_Registry.h"
00009 #include "tao/Reactive_Flushing_Strategy.h"
00010 #include "tao/Block_Flushing_Strategy.h"
00011 #include "tao/Leader_Follower_Flushing_Strategy.h"
00012 #include "tao/LRU_Connection_Purging_Strategy.h"
00013 #include "tao/LF_Strategy_Complete.h"
00014 #include "tao/Codeset_Descriptor_Base.h"
00015 #include "tao/Codeset_Manager_Factory_Base.h"
00016 #include "tao/Codeset_Manager.h"
00017 #include "tao/Null_Fragmentation_Strategy.h"
00018 #include "tao/On_Demand_Fragmentation_Strategy.h"
00019 #include "tao/MMAP_Allocator.h"
00020 #include "tao/Load_Protocol_Factory_T.h"
00021
00022 #include "ace/TP_Reactor.h"
00023 #include "ace/Malloc.h"
00024 #include "ace/Reactor.h"
00025 #include "ace/Malloc_T.h"
00026 #include "ace/Local_Memory_Pool.h"
00027 #include "ace/OS_NS_string.h"
00028 #include "ace/OS_NS_strings.h"
00029
00030 ACE_RCSID (tao,
00031 default_resource,
00032 "$Id: default_resource.cpp 80609 2008-02-12 12:11:38Z johnnyw $")
00033
00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00035
00036 TAO_Codeset_Parameters::TAO_Codeset_Parameters (void)
00037 : translators_ ()
00038 , native_ (0)
00039 {
00040 }
00041
00042 TAO_Codeset_Parameters::~TAO_Codeset_Parameters (void)
00043 {
00044 for (TAO_Codeset_Parameters::iterator i =
00045 this->translators ();
00046 !i.done ();
00047 i.advance ())
00048 {
00049 ACE_TCHAR** element = 0;
00050 if (i.next (element))
00051 ACE_OS::free (*element);
00052 }
00053
00054 ACE_OS::free (this->native_);
00055 }
00056
00057 const ACE_TCHAR*
00058 TAO_Codeset_Parameters::native (void)
00059 {
00060 return (this->native_);
00061 }
00062
00063 void
00064 TAO_Codeset_Parameters::apply_to (TAO_Codeset_Descriptor_Base *csd)
00065 {
00066 if (csd == 0)
00067 return;
00068
00069 if (this->native () != 0)
00070 csd->ncs (this->native ());
00071
00072 ACE_TCHAR** element = 0;
00073 for (TAO_Codeset_Parameters::iterator i = this->translators ();
00074 !i.done ();
00075 i.advance ())
00076 {
00077 if (i.next (element))
00078 csd->add_translator (*element);
00079 }
00080 }
00081
00082 void
00083 TAO_Codeset_Parameters::native (const ACE_TCHAR* n)
00084 {
00085 ACE_OS::free (this->native_);
00086 this->native_ = ACE_OS::strdup (n);
00087 }
00088
00089 void
00090 TAO_Codeset_Parameters::add_translator (const ACE_TCHAR*name)
00091 {
00092 this->translators_.enqueue_tail (ACE_OS::strdup (name));
00093 }
00094
00095 TAO_Codeset_Parameters::iterator
00096 TAO_Codeset_Parameters::translators (void)
00097 {
00098 return this->translators_.begin ();
00099 }
00100
00101 TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void)
00102 : use_locked_data_blocks_ (1)
00103 , parser_names_count_ (0)
00104 , parser_names_ (0)
00105 , protocol_factories_ ()
00106 , connection_purging_type_ (TAO_CONNECTION_PURGING_STRATEGY)
00107 , cache_maximum_ (TAO_CONNECTION_CACHE_MAXIMUM)
00108 , purge_percentage_ (TAO_PURGE_PERCENT)
00109 , max_muxed_connections_ (0)
00110 , reactor_mask_signals_ (1)
00111 , dynamically_allocated_reactor_ (false)
00112 , options_processed_ (0)
00113 , factory_disabled_ (0)
00114 #if TAO_USE_OUTPUT_CDR_MMAP_MEMORY_POOL == 1
00115 , output_cdr_allocator_type_ (MMAP_ALLOCATOR)
00116 #else
00117 , output_cdr_allocator_type_ (DEFAULT)
00118 #endif
00119 #if TAO_USE_LOCAL_MEMORY_POOL == 1
00120 , use_local_memory_pool_ (true)
00121 #else
00122 , use_local_memory_pool_ (false)
00123 #endif
00124 , cached_connection_lock_type_ (TAO_THREAD_LOCK)
00125 , object_key_table_lock_type_ (TAO_THREAD_LOCK)
00126 , corba_object_lock_type_ (TAO_THREAD_LOCK)
00127 , flushing_strategy_type_ (TAO_LEADER_FOLLOWER_FLUSHING)
00128 , char_codeset_parameters_ ()
00129 , wchar_codeset_parameters_ ()
00130 , resource_usage_strategy_ (TAO_Resource_Factory::TAO_EAGER)
00131 , drop_replies_ (true)
00132 {
00133 #if TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY == 1
00134 this->resource_usage_strategy_ =
00135 TAO_Resource_Factory::TAO_LAZY;
00136 #endif
00137
00138
00139 }
00140
00141 TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory (void)
00142 {
00143 const TAO_ProtocolFactorySetItor end = this->protocol_factories_.end ();
00144
00145 for (TAO_ProtocolFactorySetItor iterator =
00146 this->protocol_factories_.begin ();
00147 iterator != end;
00148 ++iterator)
00149 {
00150 delete *iterator;
00151 }
00152
00153 this->protocol_factories_.reset ();
00154
00155 for (int i = 0; i < this->parser_names_count_; ++i)
00156 CORBA::string_free (this->parser_names_[i]);
00157
00158 delete [] this->parser_names_;
00159 }
00160
00161
00162 int
00163 TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[])
00164 {
00165 ACE_TRACE ("TAO_Default_Resource_Factory::init");
00166
00167
00168
00169
00170 if (this->factory_disabled_) {
00171 ACE_DEBUG ((LM_WARNING,
00172 ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ")
00173 ACE_TEXT ("ignored\n")
00174 ACE_TEXT ("Default Resource Factory is disabled\n")));
00175 return 0;
00176 }
00177 this->options_processed_ = 1;
00178
00179 this->parser_names_count_ = 0;
00180
00181 int curarg = 0;
00182
00183 for (curarg = 0; curarg < argc; ++curarg)
00184 {
00185
00186 if (ACE_OS::strcasecmp (argv[curarg],
00187 ACE_TEXT("-ORBIORParser")) == 0)
00188 ++this->parser_names_count_;
00189
00190 ++curarg;
00191
00192 if (curarg == (argc-1) && this->parser_names_count_ != 0)
00193 {
00194
00195 ACE_NEW_RETURN (this->parser_names_,
00196 char *[this->parser_names_count_],
00197 -1);
00198
00199 for (int i = 0;
00200 i < this->parser_names_count_;
00201 ++i)
00202 this->parser_names_[i] = 0;
00203
00204 this->index_ = 0;
00205 }
00206 }
00207
00208 for (curarg = 0; curarg < argc; ++curarg)
00209 {
00210 if (ACE_OS::strcasecmp (argv[curarg],
00211 ACE_TEXT("-ORBReactorMaskSignals")) == 0)
00212 {
00213 ++curarg;
00214 if (curarg < argc)
00215 {
00216 ACE_TCHAR* name = argv[curarg];
00217
00218 if (ACE_OS::strcasecmp (name, ACE_TEXT("0")) == 0)
00219 this->reactor_mask_signals_ = 0;
00220 else if (ACE_OS::strcasecmp (name, ACE_TEXT("1")) == 0)
00221 this->reactor_mask_signals_= 1;
00222 else
00223 this->report_option_value_error (ACE_TEXT("-ORBReactorMaskSignals"), name);
00224 }
00225 }
00226
00227 else if (ACE_OS::strcasecmp (argv[curarg],
00228 ACE_TEXT("-ORBProtocolFactory")) == 0)
00229 {
00230 TAO_ProtocolFactorySet *pset = this->get_protocol_factories ();
00231 ++curarg;
00232 if (curarg < argc)
00233 {
00234 TAO_Protocol_Item *item = 0;
00235 ACE_NEW_RETURN (item,
00236 TAO_Protocol_Item (ACE_TEXT_ALWAYS_CHAR(argv[curarg])),
00237 -1);
00238 if (pset->insert (item) == -1)
00239 ACE_ERROR ((LM_ERROR,
00240 ACE_TEXT ("(%P|%t) Unable to add protocol factories ")
00241 ACE_TEXT ("for %s: %m\n"),
00242 argv[curarg]));
00243 }
00244 }
00245
00246
00247 else if (ACE_OS::strcasecmp (argv[curarg],
00248 ACE_TEXT("-ORBNativeCharCodeSet")) == 0)
00249 {
00250 ++curarg;
00251 if (curarg < argc)
00252 this->char_codeset_parameters_.native (argv[curarg]);
00253 }
00254
00255 else if (ACE_OS::strcasecmp (argv[curarg],
00256 ACE_TEXT("-ORBNativeWCharCodeSet")) == 0)
00257 {
00258 ++curarg;
00259 if (curarg < argc)
00260 this->wchar_codeset_parameters_.native (argv[curarg]);
00261 }
00262
00263 else if (ACE_OS::strcasecmp (argv[curarg],
00264 ACE_TEXT("-ORBCharCodesetTranslator")) == 0)
00265 {
00266 ++curarg;
00267 if (curarg < argc)
00268 this->char_codeset_parameters_.add_translator (argv[curarg]);
00269 }
00270
00271
00272 else if (ACE_OS::strcasecmp (argv[curarg],
00273 ACE_TEXT("-ORBWCharCodesetTranslator")) == 0)
00274 {
00275 ++curarg;
00276 if (curarg < argc)
00277 this->wchar_codeset_parameters_.add_translator (argv[curarg]);
00278 }
00279
00280 else if (ACE_OS::strcasecmp (argv[curarg],
00281 ACE_TEXT("-ORBConnectionCachingStrategy")) == 0)
00282 {
00283 ++curarg;
00284
00285
00286
00287 ACE_DEBUG ((LM_DEBUG,
00288 ACE_TEXT ("(%P|%t) This option would be deprecated \n")
00289 ACE_TEXT ("(%P|%t) Please use -ORBConnectionPurgingStrategy ")
00290 ACE_TEXT ("instead \n")));
00291
00292 if (curarg < argc)
00293 {
00294 ACE_TCHAR* name = argv[curarg];
00295
00296 if (ACE_OS::strcasecmp (name,
00297 ACE_TEXT ("lru")) == 0)
00298 this->connection_purging_type_ =
00299 TAO_Resource_Factory::LRU;
00300 else if (ACE_OS::strcasecmp (name,
00301 ACE_TEXT ("lfu")) == 0)
00302 this->connection_purging_type_ =
00303 TAO_Resource_Factory::LFU;
00304 else if (ACE_OS::strcasecmp (name,
00305 ACE_TEXT ("fifo")) == 0)
00306 this->connection_purging_type_ =
00307 TAO_Resource_Factory::FIFO;
00308 else if (ACE_OS::strcasecmp (name,
00309 ACE_TEXT ("null")) == 0)
00310 this->connection_purging_type_ =
00311 TAO_Resource_Factory::NOOP;
00312 else
00313 this->report_option_value_error (ACE_TEXT ("-ORBConnectionCachingStrategy"), name);
00314 }
00315 }
00316 else if (ACE_OS::strcasecmp (argv[curarg],
00317 ACE_TEXT("-ORBConnectionPurgingStrategy")) == 0)
00318 {
00319 ++curarg;
00320
00321 if (curarg < argc)
00322 {
00323 ACE_TCHAR* name = argv[curarg];
00324
00325 if (ACE_OS::strcasecmp (name,
00326 ACE_TEXT("lru")) == 0)
00327 this->connection_purging_type_ =
00328 TAO_Resource_Factory::LRU;
00329 else if (ACE_OS::strcasecmp (name,
00330 ACE_TEXT("lfu")) == 0)
00331 this->connection_purging_type_ =
00332 TAO_Resource_Factory::LFU;
00333 else if (ACE_OS::strcasecmp (name,
00334 ACE_TEXT("fifo")) == 0)
00335 this->connection_purging_type_ =
00336 TAO_Resource_Factory::FIFO;
00337 else if (ACE_OS::strcasecmp (name,
00338 ACE_TEXT("null")) == 0)
00339 this->connection_purging_type_ =
00340 TAO_Resource_Factory::NOOP;
00341 else
00342 this->report_option_value_error (ACE_TEXT("-ORBConnectionPurgingStrategy"), name);
00343 }
00344 }
00345 else if (ACE_OS::strcasecmp (argv[curarg],
00346 ACE_TEXT("-ORBConnectionCacheMax")) == 0)
00347 {
00348 ++curarg;
00349 if (curarg < argc)
00350 this->cache_maximum_ = ACE_OS::atoi (argv[curarg]);
00351 else
00352 this->report_option_value_error (ACE_TEXT("-ORBConnectionCacheMax"), argv[curarg]);
00353 }
00354
00355 else if (ACE_OS::strcasecmp (argv[curarg],
00356 ACE_TEXT("-ORBConnectionCachePurgePercentage")) == 0)
00357 {
00358 ++curarg;
00359 if (curarg < argc)
00360 this->purge_percentage_ = ACE_OS::atoi (argv[curarg]);
00361 else
00362 this->report_option_value_error (ACE_TEXT("-ORBConnectionCachePurgePercentage"),
00363 argv[curarg]);
00364 }
00365 else if (ACE_OS::strcasecmp (argv[curarg],
00366 ACE_TEXT("-ORBIORParser")) == 0)
00367 {
00368 ++curarg;
00369
00370 if (curarg < argc)
00371 {
00372 this->add_to_ior_parser_names (ACE_TEXT_ALWAYS_CHAR(argv[curarg]));
00373 }
00374 }
00375
00376 else if (ACE_OS::strcasecmp (argv[curarg],
00377 ACE_TEXT("-ORBConnectionCacheLock")) == 0)
00378 {
00379 ++curarg;
00380 if (curarg < argc)
00381 {
00382 ACE_TCHAR* name = argv[curarg];
00383
00384 if (ACE_OS::strcasecmp (name,
00385 ACE_TEXT("thread")) == 0)
00386 this->cached_connection_lock_type_ = TAO_THREAD_LOCK;
00387 else if (ACE_OS::strcasecmp (name,
00388 ACE_TEXT("null")) == 0)
00389 {
00390
00391
00392
00393 this->use_locked_data_blocks_ = 0;
00394 this->cached_connection_lock_type_ = TAO_NULL_LOCK;
00395 }
00396 else
00397 this->report_option_value_error (ACE_TEXT("-ORBConnectionCacheLock"), name);
00398 }
00399 }
00400 else if (ACE_OS::strcasecmp (argv[curarg],
00401 ACE_TEXT("-ORBObjectKeyTableLock")) == 0)
00402 {
00403 ++curarg;
00404 if (curarg < argc)
00405 {
00406 ACE_TCHAR* name = argv[curarg];
00407
00408 if (ACE_OS::strcasecmp (name,
00409 ACE_TEXT("thread")) == 0)
00410 this->object_key_table_lock_type_ = TAO_THREAD_LOCK;
00411 else if (ACE_OS::strcasecmp (name,
00412 ACE_TEXT("null")) == 0)
00413 {
00414
00415
00416
00417 this->object_key_table_lock_type_ = TAO_NULL_LOCK;
00418 }
00419 else
00420 this->report_option_value_error (ACE_TEXT("-ORBObjectKeyTableLock"), name);
00421 }
00422 }
00423 else if (ACE_OS::strcasecmp (argv[curarg],
00424 ACE_TEXT("-ORBCorbaObjectLock")) == 0)
00425 {
00426 ++curarg;
00427 if (curarg < argc)
00428 {
00429 ACE_TCHAR* name = argv[curarg];
00430
00431 if (ACE_OS::strcasecmp (name,
00432 ACE_TEXT("thread")) == 0)
00433 this->corba_object_lock_type_ = TAO_THREAD_LOCK;
00434 else if (ACE_OS::strcasecmp (name,
00435 ACE_TEXT("null")) == 0)
00436 {
00437
00438
00439
00440 this->corba_object_lock_type_ = TAO_NULL_LOCK;
00441 }
00442 else
00443 this->report_option_value_error (ACE_TEXT("-ORBCorbaObjectLock"), name);
00444 }
00445 }
00446 else if (ACE_OS::strcasecmp (argv[curarg],
00447 ACE_TEXT("-ORBResourceUsage")) == 0)
00448 {
00449 ++curarg;
00450 if (curarg < argc)
00451 {
00452 ACE_TCHAR* name = argv[curarg];
00453
00454 if (ACE_OS::strcasecmp (name,
00455 ACE_TEXT("eager")) == 0)
00456 this->resource_usage_strategy_ = TAO_EAGER;
00457 else if (ACE_OS::strcasecmp (name,
00458 ACE_TEXT("lazy")) == 0)
00459 {
00460 this->resource_usage_strategy_ = TAO_LAZY;
00461 }
00462 else
00463 this->report_option_value_error (ACE_TEXT("-ORBResourceUsage"), name);
00464 }
00465 }
00466 else if (ACE_OS::strcasecmp (argv[curarg],
00467 ACE_TEXT("-ORBFlushingStrategy")) == 0)
00468 {
00469 ++curarg;
00470
00471
00472
00473
00474 if (curarg < argc)
00475 {
00476 ACE_TCHAR* name = argv[curarg];
00477
00478 if (ACE_OS::strcasecmp (name,
00479 ACE_TEXT("leader_follower")) == 0)
00480 this->flushing_strategy_type_ = TAO_LEADER_FOLLOWER_FLUSHING;
00481 else if (ACE_OS::strcasecmp (name,
00482 ACE_TEXT("reactive")) == 0)
00483 this->flushing_strategy_type_ = TAO_REACTIVE_FLUSHING;
00484 else if (ACE_OS::strcasecmp (name,
00485 ACE_TEXT("blocking")) == 0)
00486 this->flushing_strategy_type_ = TAO_BLOCKING_FLUSHING;
00487 else
00488 this->report_option_value_error (ACE_TEXT("-ORBFlushingStrategy"), name);
00489 }
00490
00491 }
00492 else if (ACE_OS::strcasecmp (argv[curarg],
00493 ACE_TEXT ("-ORBMuxedConnectionMax")) == 0)
00494 {
00495 ++curarg;
00496 if (curarg < argc)
00497 this->max_muxed_connections_ =
00498 ACE_OS::atoi (argv[curarg]);
00499 else
00500 this->report_option_value_error (ACE_TEXT("-ORBMuxedConnectionMax"),
00501 argv[curarg]);
00502 }
00503 else if (ACE_OS::strcasecmp (argv[curarg],
00504 ACE_TEXT("-ORBDropRepliesDuringShutdown")) == 0)
00505 {
00506 ++curarg;
00507 if (curarg < argc)
00508 {
00509 int tmp = ACE_OS::atoi (argv[curarg]);
00510
00511 if (tmp == 0)
00512 this->drop_replies_ = false;
00513 else
00514 this->drop_replies_ = true;
00515 }
00516 else
00517 this->report_option_value_error (ACE_TEXT("-ORBDropRepliesDuringShutdown"),
00518 argv[curarg]);
00519 }
00520 else if (0 == ACE_OS::strcasecmp (argv[curarg],
00521 ACE_TEXT("-ORBOutputCDRAllocator")))
00522 {
00523 ++curarg;
00524
00525 if (curarg < argc)
00526 {
00527 ACE_TCHAR const * const current_arg = argv[curarg];
00528
00529 if (ACE_OS::strcasecmp (current_arg,
00530 ACE_TEXT("mmap")) == 0)
00531 {
00532 #if TAO_HAS_SENDFILE == 1
00533 this->output_cdr_allocator_type_ = MMAP_ALLOCATOR;
00534 #else
00535 ACE_DEBUG ((LM_WARNING,
00536 ACE_TEXT ("MMAP allocator unsupport on this platform")));
00537 #endif
00538 }
00539 else if (ACE_OS::strcasecmp (current_arg,
00540 ACE_TEXT("local_memory_pool")) == 0
00541 && this->output_cdr_allocator_type_ != DEFAULT)
00542 {
00543 this->output_cdr_allocator_type_ = LOCAL_MEMORY_POOL;
00544 }
00545 else if (ACE_OS::strcasecmp (current_arg,
00546 ACE_TEXT("default")) == 0)
00547 {
00548 this->output_cdr_allocator_type_ = DEFAULT;
00549 }
00550 else
00551 {
00552 this->report_option_value_error (
00553 ACE_TEXT("-ORBOutputCDRAllocator"), current_arg);
00554 }
00555 }
00556 }
00557 else if (0 == ACE_OS::strcasecmp (argv[curarg],
00558 ACE_TEXT("-ORBZeroCopyWrite")))
00559 {
00560 #if TAO_HAS_SENDFILE == 1
00561 this->output_cdr_allocator_type_ = MMAP_ALLOCATOR;
00562 #else
00563 ACE_DEBUG ((LM_WARNING,
00564 ACE_TEXT ("Zero copy writes unsupported on this platform\n")));
00565 #endif
00566 }
00567 else if (ACE_OS::strncmp (argv[curarg],
00568 ACE_TEXT ("-ORB"),
00569 4) == 0)
00570 {
00571
00572
00573 ACE_ERROR ((LM_ERROR,
00574 ACE_TEXT ("Default_Resource_Factory - ")
00575 ACE_TEXT ("unknown option <%s>\n"),
00576 argv[curarg]));
00577 }
00578 else
00579 {
00580 ACE_DEBUG ((LM_DEBUG,
00581 ACE_TEXT ("Default_Resource_Factory - ")
00582 ACE_TEXT ("ignoring option <%s>\n"),
00583 argv[curarg]));
00584 }
00585 }
00586
00587 return 0;
00588 }
00589
00590 int
00591 TAO_Default_Resource_Factory::get_parser_names (char **&names,
00592 int &number_of_names)
00593 {
00594 if (this->parser_names_count_ != 0)
00595 {
00596
00597 names = this->parser_names_;
00598 number_of_names = this->parser_names_count_;
00599
00600 return 0;
00601 }
00602
00603 this->parser_names_count_ = 0;
00604 #if (TAO_HAS_DDL_PARSER == 1)
00605 ++this->parser_names_count_;
00606 #endif
00607 #if (TAO_HAS_FILE_PARSER == 1)
00608 ++this->parser_names_count_;
00609 #endif
00610 #if (TAO_HAS_CORBALOC_PARSER == 1)
00611 ++this->parser_names_count_;
00612 #endif
00613 #if (TAO_HAS_CORBANAME_PARSER == 1)
00614 ++this->parser_names_count_;
00615 #endif
00616 #if (TAO_HAS_HTTP_PARSER == 1)
00617 ++this->parser_names_count_;
00618 #endif
00619 #if (TAO_HAS_MCAST_PARSER == 1)
00620 ++this->parser_names_count_;
00621 #endif
00622 ACE_NEW_RETURN (this->parser_names_,
00623 char *[this->parser_names_count_],
00624 -1);
00625
00626 CORBA::ULong index = 0;
00627
00628 #if (TAO_HAS_DDL_PARSER == 1)
00629 this->parser_names_[index] = CORBA::string_dup ("DLL_Parser");
00630 ++index;
00631 #endif
00632
00633 #if (TAO_HAS_FILE_PARSER == 1)
00634 this->parser_names_[index] = CORBA::string_dup ("FILE_Parser");
00635 ++index;
00636 #endif
00637
00638 #if (TAO_HAS_CORBALOC_PARSER == 1)
00639 this->parser_names_[index] = CORBA::string_dup ("CORBALOC_Parser");
00640 ++index;
00641 #endif
00642
00643 #if (TAO_HAS_CORBANAME_PARSER == 1)
00644 this->parser_names_[index] = CORBA::string_dup ("CORBANAME_Parser");
00645 ++index;
00646 #endif
00647
00648 #if (TAO_HAS_MCAST_PARSER == 1)
00649 this->parser_names_[index] = CORBA::string_dup ("MCAST_Parser");
00650 ++index;
00651 #endif
00652
00653 #if (TAO_HAS_HTTP_PARSER == 1)
00654 this->parser_names_[index] = CORBA::string_dup ("HTTP_Parser");
00655 ++index;
00656 #endif
00657
00658 names = this->parser_names_;
00659
00660 number_of_names = index;
00661
00662 return 0;
00663 }
00664
00665 int
00666 TAO_Default_Resource_Factory::add_to_ior_parser_names (const char *curarg)
00667 {
00668 this->parser_names_[this->index_] = CORBA::string_dup (curarg);
00669
00670 ++this->index_;
00671
00672 return 0;
00673 }
00674
00675
00676
00677 int
00678 TAO_Default_Resource_Factory::load_default_protocols (void)
00679 {
00680 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 if (TAO::details::load_protocol_factory <TAO_IIOP_Protocol_Factory> (
00709 this->protocol_factories_, "IIOP_Factory") == -1)
00710 return -1;
00711 #endif
00712
00713 return 0;
00714 }
00715
00716 int
00717 TAO_Default_Resource_Factory::init_protocol_factories (void)
00718 {
00719 const TAO_ProtocolFactorySetItor end = protocol_factories_.end ();
00720 TAO_ProtocolFactorySetItor factory = protocol_factories_.begin ();
00721
00722 if (factory == end)
00723 {
00724 return this->load_default_protocols ();
00725 }
00726
00727 for (; factory != end; ++factory)
00728 {
00729 const ACE_CString &name = (*factory)->protocol_name ();
00730 (*factory)->factory (
00731 ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (name.c_str ()));
00732 if ((*factory)->factory () == 0)
00733 {
00734 ACE_ERROR_RETURN ((LM_ERROR,
00735 ACE_TEXT ("TAO (%P|%t) Unable to load ")
00736 ACE_TEXT ("protocol <%s>, %p\n"),
00737 ACE_TEXT_CHAR_TO_TCHAR(name.c_str ()),
00738 ACE_TEXT ("")),
00739 -1);
00740 }
00741
00742 if (TAO_debug_level > 0)
00743 {
00744 ACE_DEBUG ((LM_DEBUG,
00745 ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"),
00746 ACE_TEXT_CHAR_TO_TCHAR(name.c_str ())));
00747 }
00748 }
00749
00750 return 0;
00751 }
00752
00753 int
00754 TAO_Default_Resource_Factory::use_locked_data_blocks (void) const
00755 {
00756 return this->use_locked_data_blocks_;
00757 }
00758
00759 TAO_ProtocolFactorySet *
00760 TAO_Default_Resource_Factory::get_protocol_factories (void)
00761 {
00762 return &protocol_factories_;
00763 }
00764
00765 TAO_Acceptor_Registry *
00766 TAO_Default_Resource_Factory::get_acceptor_registry (void)
00767 {
00768 TAO_Acceptor_Registry *ar = 0;
00769
00770 ACE_NEW_RETURN(ar,
00771 TAO_Acceptor_Registry,
00772 0);
00773
00774 return ar;
00775 }
00776
00777 TAO_Connector_Registry *
00778 TAO_Default_Resource_Factory::get_connector_registry (void)
00779 {
00780 TAO_Connector_Registry *cr = 0;
00781
00782 ACE_NEW_RETURN(cr,
00783 TAO_Connector_Registry,
00784 0);
00785
00786 return cr;
00787 }
00788
00789 ACE_Reactor_Impl*
00790 TAO_Default_Resource_Factory::allocate_reactor_impl (void) const
00791 {
00792 ACE_Reactor_Impl *impl = 0;
00793
00794
00795
00796
00797 ACE_NEW_RETURN (impl,
00798 ACE_TP_Reactor (ACE::max_handles (),
00799 1,
00800 (ACE_Sig_Handler*)0,
00801 (ACE_Timer_Queue*)0,
00802 this->reactor_mask_signals_,
00803 ACE_Select_Reactor_Token::LIFO),
00804 0);
00805
00806 return impl;
00807 }
00808
00809 ACE_Reactor *
00810 TAO_Default_Resource_Factory::get_reactor (void)
00811 {
00812 ACE_Reactor *reactor = 0;
00813 ACE_NEW_RETURN (reactor,
00814 ACE_Reactor (this->allocate_reactor_impl (), 1),
00815 0);
00816
00817 if (reactor->initialized () == 0)
00818 {
00819 delete reactor;
00820 reactor = 0;
00821 }
00822 else
00823 this->dynamically_allocated_reactor_ = true;
00824
00825 return reactor;
00826 }
00827
00828 void
00829 TAO_Default_Resource_Factory::reclaim_reactor (ACE_Reactor *reactor)
00830 {
00831 if (this->dynamically_allocated_reactor_)
00832 delete reactor;
00833 }
00834
00835
00836 typedef ACE_Malloc<ACE_LOCAL_MEMORY_POOL,TAO_SYNCH_MUTEX> LOCKED_MALLOC;
00837 typedef ACE_Allocator_Adapter<LOCKED_MALLOC> LOCKED_ALLOCATOR_POOL;
00838 typedef ACE_New_Allocator LOCKED_ALLOCATOR_NO_POOL;
00839
00840 void
00841 TAO_Default_Resource_Factory::use_local_memory_pool (bool flag)
00842 {
00843 this->use_local_memory_pool_ = flag;
00844
00845 if (this->output_cdr_allocator_type_ == DEFAULT)
00846 this->output_cdr_allocator_type_ = LOCAL_MEMORY_POOL;
00847 }
00848
00849 ACE_Allocator *
00850 TAO_Default_Resource_Factory::input_cdr_dblock_allocator (void)
00851 {
00852 ACE_Allocator *allocator = 0;
00853 if (use_local_memory_pool_)
00854 {
00855 ACE_NEW_RETURN (allocator,
00856 LOCKED_ALLOCATOR_POOL,
00857 0);
00858 }
00859 else
00860 {
00861 ACE_NEW_RETURN (allocator,
00862 LOCKED_ALLOCATOR_NO_POOL,
00863 0);
00864 }
00865
00866 return allocator;
00867 }
00868
00869 ACE_Allocator *
00870 TAO_Default_Resource_Factory::input_cdr_buffer_allocator (void)
00871 {
00872 ACE_Allocator *allocator = 0;
00873 if (use_local_memory_pool_)
00874 {
00875 ACE_NEW_RETURN (allocator,
00876 LOCKED_ALLOCATOR_POOL,
00877 0);
00878 }
00879 else
00880 {
00881 ACE_NEW_RETURN (allocator,
00882 LOCKED_ALLOCATOR_NO_POOL,
00883 0);
00884 }
00885
00886 return allocator;
00887 }
00888
00889 ACE_Allocator *
00890 TAO_Default_Resource_Factory::input_cdr_msgblock_allocator (void)
00891 {
00892 ACE_Allocator *allocator = 0;
00893 if (use_local_memory_pool_)
00894 {
00895 ACE_NEW_RETURN (allocator,
00896 LOCKED_ALLOCATOR_POOL,
00897 0);
00898 }
00899 else
00900 {
00901 ACE_NEW_RETURN (allocator,
00902 LOCKED_ALLOCATOR_NO_POOL,
00903 0);
00904 }
00905
00906 return allocator;
00907 }
00908
00909 int
00910 TAO_Default_Resource_Factory::input_cdr_allocator_type_locked (void)
00911 {
00912 return 1;
00913 }
00914
00915 ACE_Allocator*
00916 TAO_Default_Resource_Factory::output_cdr_dblock_allocator (void)
00917 {
00918 ACE_Allocator *allocator = 0;
00919 if (use_local_memory_pool_)
00920 {
00921 ACE_NEW_RETURN (allocator,
00922 LOCKED_ALLOCATOR_POOL,
00923 0);
00924 }
00925 else
00926 {
00927 ACE_NEW_RETURN (allocator,
00928 LOCKED_ALLOCATOR_NO_POOL,
00929 0);
00930 }
00931
00932 return allocator;
00933 }
00934
00935 ACE_Allocator *
00936 TAO_Default_Resource_Factory::output_cdr_buffer_allocator (void)
00937 {
00938 ACE_Allocator *allocator = 0;
00939
00940 switch (this->output_cdr_allocator_type_)
00941 {
00942 case LOCAL_MEMORY_POOL:
00943 ACE_NEW_RETURN (allocator,
00944 LOCKED_ALLOCATOR_POOL,
00945 0);
00946
00947 break;
00948
00949 #if TAO_HAS_SENDFILE == 1
00950 case MMAP_ALLOCATOR:
00951 ACE_NEW_RETURN (allocator,
00952 TAO_MMAP_Allocator,
00953 0);
00954
00955 break;
00956 #endif
00957
00958 case DEFAULT:
00959 default:
00960 ACE_NEW_RETURN (allocator,
00961 LOCKED_ALLOCATOR_NO_POOL,
00962 0);
00963
00964 break;
00965 }
00966
00967 return allocator;
00968 }
00969
00970 ACE_Allocator*
00971 TAO_Default_Resource_Factory::output_cdr_msgblock_allocator (void)
00972 {
00973 ACE_Allocator *allocator = 0;
00974 if (use_local_memory_pool_)
00975 {
00976 ACE_NEW_RETURN (allocator,
00977 LOCKED_ALLOCATOR_POOL,
00978 0);
00979 }
00980 else
00981 {
00982 ACE_NEW_RETURN (allocator,
00983 LOCKED_ALLOCATOR_NO_POOL,
00984 0);
00985 }
00986
00987 return allocator;
00988 }
00989
00990 ACE_Allocator*
00991 TAO_Default_Resource_Factory::amh_response_handler_allocator (void)
00992 {
00993 ACE_Allocator *allocator = 0;
00994 if (use_local_memory_pool_)
00995 {
00996 ACE_NEW_RETURN (allocator,
00997 LOCKED_ALLOCATOR_POOL,
00998 0);
00999 }
01000 else
01001 {
01002 ACE_NEW_RETURN (allocator,
01003 LOCKED_ALLOCATOR_NO_POOL,
01004 0);
01005 }
01006
01007 return allocator;
01008 }
01009
01010 ACE_Allocator*
01011 TAO_Default_Resource_Factory::ami_response_handler_allocator (void)
01012 {
01013 ACE_Allocator *allocator = 0;
01014 if (use_local_memory_pool_)
01015 {
01016 ACE_NEW_RETURN (allocator,
01017 LOCKED_ALLOCATOR_POOL,
01018 0);
01019 }
01020 else
01021 {
01022 ACE_NEW_RETURN (allocator,
01023 LOCKED_ALLOCATOR_NO_POOL,
01024 0);
01025 }
01026
01027 return allocator;
01028 }
01029
01030 int
01031 TAO_Default_Resource_Factory::cache_maximum (void) const
01032 {
01033 return this->cache_maximum_;
01034 }
01035
01036 int
01037 TAO_Default_Resource_Factory::purge_percentage (void) const
01038 {
01039 return this->purge_percentage_;
01040 }
01041
01042 int
01043 TAO_Default_Resource_Factory::max_muxed_connections (void) const
01044 {
01045 return this->max_muxed_connections_;
01046 }
01047
01048
01049 ACE_Lock *
01050 TAO_Default_Resource_Factory::create_cached_connection_lock (void)
01051 {
01052 ACE_Lock *the_lock = 0;
01053
01054 if (this->cached_connection_lock_type_ == TAO_NULL_LOCK)
01055 ACE_NEW_RETURN (the_lock,
01056 ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX>,
01057 0);
01058 else
01059 ACE_NEW_RETURN (the_lock,
01060 ACE_Lock_Adapter<TAO_SYNCH_MUTEX>,
01061 0);
01062
01063 return the_lock;
01064 }
01065
01066 int
01067 TAO_Default_Resource_Factory::locked_transport_cache (void)
01068 {
01069 if (this->cached_connection_lock_type_ == TAO_NULL_LOCK)
01070 return 0;
01071
01072 return 1;
01073 }
01074
01075
01076 ACE_Lock *
01077 TAO_Default_Resource_Factory::create_object_key_table_lock (void)
01078 {
01079 ACE_Lock *the_lock = 0;
01080
01081 if (this->object_key_table_lock_type_ == TAO_NULL_LOCK)
01082 ACE_NEW_RETURN (the_lock,
01083 ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX>,
01084 0);
01085 else
01086 ACE_NEW_RETURN (the_lock,
01087 ACE_Lock_Adapter<TAO_SYNCH_MUTEX>,
01088 0);
01089
01090 return the_lock;
01091 }
01092
01093 ACE_Lock *
01094 TAO_Default_Resource_Factory::create_corba_object_lock (void)
01095 {
01096 ACE_Lock *the_lock = 0;
01097
01098 if (this->corba_object_lock_type_ == TAO_NULL_LOCK)
01099 ACE_NEW_RETURN (the_lock,
01100 ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX>,
01101 0);
01102 else
01103 ACE_NEW_RETURN (the_lock,
01104 ACE_Lock_Adapter<TAO_SYNCH_MUTEX>,
01105 0);
01106
01107 return the_lock;
01108 }
01109
01110 TAO_Configurable_Refcount
01111 TAO_Default_Resource_Factory::create_corba_object_refcount (void)
01112 {
01113 switch (this->corba_object_lock_type_)
01114 {
01115 case TAO_NULL_LOCK:
01116 return TAO_Configurable_Refcount (
01117 TAO_Configurable_Refcount::TAO_NULL_LOCK);
01118 case TAO_THREAD_LOCK:
01119 default:
01120 return TAO_Configurable_Refcount (
01121 TAO_Configurable_Refcount::TAO_THREAD_LOCK);
01122 }
01123 }
01124
01125 TAO_Flushing_Strategy *
01126 TAO_Default_Resource_Factory::create_flushing_strategy (void)
01127 {
01128 TAO_Flushing_Strategy *strategy = 0;
01129 if (this->flushing_strategy_type_ == TAO_LEADER_FOLLOWER_FLUSHING)
01130 ACE_NEW_RETURN (strategy,
01131 TAO_Leader_Follower_Flushing_Strategy,
01132 0);
01133 else if (this->flushing_strategy_type_ == TAO_REACTIVE_FLUSHING)
01134 ACE_NEW_RETURN (strategy,
01135 TAO_Reactive_Flushing_Strategy,
01136 0);
01137 else
01138 ACE_NEW_RETURN (strategy,
01139 TAO_Block_Flushing_Strategy,
01140 0);
01141 return strategy;
01142 }
01143
01144 TAO_Connection_Purging_Strategy *
01145 TAO_Default_Resource_Factory::create_purging_strategy (void)
01146 {
01147 TAO_Connection_Purging_Strategy *strategy = 0;
01148
01149 if (this->connection_purging_type_ == TAO_Resource_Factory::LRU)
01150 {
01151 ACE_NEW_RETURN (strategy,
01152 TAO_LRU_Connection_Purging_Strategy (
01153 this->cache_maximum ()),
01154 0);
01155 }
01156 else
01157 {
01158 ACE_ERROR ((LM_ERROR,
01159 ACE_TEXT ("TAO (%P|%t) - ")
01160 ACE_TEXT ("no usable purging strategy ")
01161 ACE_TEXT ("was found.\n")));
01162 }
01163
01164 return strategy;
01165 }
01166
01167 TAO_LF_Strategy *
01168 TAO_Default_Resource_Factory::create_lf_strategy (void)
01169 {
01170 TAO_LF_Strategy *strategy = 0;
01171
01172 ACE_NEW_RETURN (strategy,
01173 TAO_LF_Strategy_Complete,
01174 0);
01175
01176 return strategy;
01177 }
01178
01179 auto_ptr<TAO_GIOP_Fragmentation_Strategy>
01180 TAO_Default_Resource_Factory::create_fragmentation_strategy (
01181 TAO_Transport * transport,
01182 CORBA::ULong max_message_size) const
01183 {
01184 auto_ptr<TAO_GIOP_Fragmentation_Strategy> strategy (0);
01185
01186 TAO_GIOP_Fragmentation_Strategy * tmp = 0;
01187
01188
01189
01190
01191
01192
01193
01194 static CORBA::ULong const min_message_size = 24;
01195
01196
01197
01198
01199 if (transport)
01200 {
01201 if (max_message_size < min_message_size
01202 || (TAO_DEF_GIOP_MAJOR == 1 && TAO_DEF_GIOP_MINOR < 2))
01203 {
01204
01205 ACE_NEW_RETURN (tmp,
01206 TAO_Null_Fragmentation_Strategy,
01207 strategy);
01208
01209 }
01210 else
01211 {
01212 ACE_NEW_RETURN (tmp,
01213 TAO_On_Demand_Fragmentation_Strategy (
01214 transport,
01215 max_message_size),
01216 strategy);
01217 }
01218 }
01219
01220 ACE_AUTO_PTR_RESET (strategy,
01221 tmp,
01222 TAO_GIOP_Fragmentation_Strategy);
01223
01224 return strategy;
01225 }
01226
01227 void
01228 TAO_Default_Resource_Factory::report_option_value_error (
01229 const ACE_TCHAR* option_name,
01230 const ACE_TCHAR* option_value)
01231 {
01232 ACE_DEBUG((LM_DEBUG,
01233 ACE_TEXT ("Default_Resource_Factory - unknown argument")
01234 ACE_TEXT (" <%s> for <%s>\n"),
01235 option_value, option_name));
01236 }
01237
01238 void
01239 TAO_Default_Resource_Factory::disable_factory (void)
01240 {
01241 this->factory_disabled_ = 1;
01242 if (this->options_processed_)
01243 {
01244 ACE_DEBUG ((LM_WARNING,
01245 ACE_TEXT ("TAO (%P|%t) Warning: Resource_Factory options ignored\n")
01246 ACE_TEXT ("Default Resource Factory is disabled\n")));
01247 }
01248 }
01249
01250 TAO_Codeset_Manager *
01251 TAO_Default_Resource_Factory::codeset_manager(void)
01252 {
01253 TAO_Codeset_Manager_Factory_Base *factory =
01254 ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset");
01255
01256 if (factory == 0)
01257 {
01258 if (TAO_debug_level >= 2)
01259 ACE_DEBUG ((LM_DEBUG,
01260 ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory")
01261 ACE_TEXT (" - unable to find codeset manager factory.\n")));
01262 return 0;
01263 }
01264
01265 TAO_Codeset_Manager* mgr = factory->create ();
01266
01267 if (mgr == 0)
01268 {
01269 if (TAO_debug_level >= 2)
01270 ACE_DEBUG ((LM_INFO,
01271 ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory")
01272 ACE_TEXT (" - unable to create codeset manager.\n")));
01273 return 0;
01274 }
01275
01276
01277 ACE_Auto_Ptr<TAO_Codeset_Manager> safemgr (mgr);
01278
01279 if (TAO_debug_level >= 1)
01280 ACE_DEBUG ((LM_DEBUG,
01281 ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory - codeset manager=%@\n"),
01282 mgr));
01283
01284 this->char_codeset_parameters_.apply_to (mgr->char_codeset_descriptor());
01285 this->wchar_codeset_parameters_.apply_to (mgr->wchar_codeset_descriptor());
01286
01287 return safemgr.release ();
01288
01289 }
01290
01291 TAO_Resource_Factory::Resource_Usage
01292 TAO_Default_Resource_Factory::resource_usage_strategy (void) const
01293 {
01294 return this->resource_usage_strategy_;
01295 }
01296
01297 bool
01298 TAO_Default_Resource_Factory::drop_replies_during_shutdown (void) const
01299 {
01300 return this->drop_replies_;
01301 }
01302
01303 TAO_END_VERSIONED_NAMESPACE_DECL
01304
01305
01306
01307 ACE_STATIC_SVC_DEFINE (TAO_Default_Resource_Factory,
01308 ACE_TEXT ("Resource_Factory"),
01309 ACE_SVC_OBJ_T,
01310 &ACE_SVC_NAME (TAO_Default_Resource_Factory),
01311 ACE_Service_Type::DELETE_THIS
01312 | ACE_Service_Type::DELETE_OBJ,
01313 0)
01314 ACE_FACTORY_DEFINE (TAO, TAO_Default_Resource_Factory)