00001
00002
00003 #include "tao/ORB_Core.h"
00004 #include "tao/ORB_Core_TSS_Resources.h"
00005 #include "tao/ORB_Table.h"
00006 #include "tao/TAO_Internal.h"
00007 #include "tao/default_server.h"
00008 #include "tao/Profile.h"
00009 #include "tao/Stub.h"
00010 #include "tao/LF_Follower.h"
00011 #include "tao/Leader_Follower.h"
00012 #include "tao/LF_Event_Loop_Thread_Helper.h"
00013 #include "tao/Connector_Registry.h"
00014 #include "tao/Transport_Queueing_Strategies.h"
00015 #include "tao/Object_Loader.h"
00016 #include "tao/ObjectIdListC.h"
00017 #include "tao/BiDir_Adapter.h"
00018 #include "tao/ZIOP_Adapter.h"
00019 #include "tao/Collocation_Resolver.h"
00020 #include "tao/Flushing_Strategy.h"
00021 #include "tao/Request_Dispatcher.h"
00022 #include "tao/Stub_Factory.h"
00023 #include "tao/Thread_Lane_Resources.h"
00024 #include "tao/Thread_Lane_Resources_Manager.h"
00025 #include "tao/TSS_Resources.h"
00026 #include "tao/Protocols_Hooks.h"
00027 #include "tao/Network_Priority_Protocols_Hooks.h"
00028 #include "tao/IORInterceptor_Adapter.h"
00029 #include "tao/IORInterceptor_Adapter_Factory.h"
00030 #include "tao/debug.h"
00031 #include "tao/TAOC.h"
00032 #include "tao/Endpoint_Selector_Factory.h"
00033 #include "tao/Client_Strategy_Factory.h"
00034 #include "tao/Adapter_Factory.h"
00035 #include "tao/Adapter.h"
00036 #include "tao/GUIResource_Factory.h"
00037 #include "tao/PolicyFactory_Registry_Adapter.h"
00038 #include "tao/PolicyFactory_Registry_Factory.h"
00039 #include "tao/ORBInitializer_Registry_Adapter.h"
00040 #include "tao/Codeset_Manager.h"
00041 #include "tao/GIOP_Fragmentation_Strategy.h"
00042 #include "tao/SystemException.h"
00043
00044 #include "tao/Valuetype_Adapter.h"
00045 #include "tao/Valuetype_Adapter_Factory.h"
00046
00047 #if (TAO_HAS_CORBA_MESSAGING == 1)
00048 #include "tao/Policy_Manager.h"
00049 #include "tao/Policy_Current.h"
00050 #endif
00051
00052 #include "ace/Reactor.h"
00053 #include "ace/Dynamic_Service.h"
00054 #include "ace/Arg_Shifter.h"
00055 #include "ace/Argv_Type_Converter.h"
00056 #include "ace/Static_Object_Lock.h"
00057 #include "ace/Auto_Ptr.h"
00058 #include "ace/CORBA_macros.h"
00059 #include "ace/Logging_Strategy.h"
00060
00061 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
00062
00063
00064 # include "ace/streams.h"
00065 #endif
00066
00067 #include "ace/OS_NS_strings.h"
00068 #include "ace/OS_NS_string.h"
00069 #include "ace/Message_Block.h"
00070
00071 #if TAO_HAS_INTERCEPTORS == 1
00072 # include "tao/ClientRequestInterceptor_Adapter.h"
00073 # include "tao/ClientRequestInterceptor_Adapter_Factory.h"
00074 # include "tao/ServerRequestInterceptor_Adapter.h"
00075 # include "tao/ServerRequestInterceptor_Adapter_Factory.h"
00076 #endif
00077
00078
00079 #if !defined (__ACE_INLINE__)
00080 # include "tao/ORB_Core.inl"
00081 #endif
00082
00083 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00084
00085 ACE_RCSID (tao,
00086 ORB_Core,
00087 "$Id: ORB_Core.cpp 91153 2010-07-21 10:04:02Z vzykov $")
00088
00089 ACE_STATIC_SVC_DEFINE(TAO_ORB_Core_Static_Resources,
00090 ACE_TEXT ("TAO_ORB_Core_Static_Resources"),
00091 ACE_SVC_OBJ_T,
00092 &ACE_SVC_NAME (TAO_ORB_Core_Static_Resources),
00093 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00094 0)
00095 ACE_FACTORY_DEFINE (TAO, TAO_ORB_Core_Static_Resources)
00096
00097
00098
00099 CORBA::Environment&
00100 TAO_default_environment (void)
00101 {
00102 return *TAO_TSS_Resources::instance ()->default_environment_;
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 TAO_ORB_Core_Static_Resources*
00116 TAO_ORB_Core_Static_Resources::initialization_reference_ =
00117 TAO_ORB_Core_Static_Resources::instance ();
00118
00119 TAO_ORB_Core_Static_Resources*
00120 TAO_ORB_Core_Static_Resources::instance (void)
00121 {
00122 ACE_Service_Gestalt *current = ACE_Service_Config::current();
00123 TAO_ORB_Core_Static_Resources* tocsr =
00124 ACE_Dynamic_Service<TAO_ORB_Core_Static_Resources>::instance
00125 (current, "TAO_ORB_Core_Static_Resources", true);
00126
00127 if (tocsr == 0)
00128 {
00129
00130
00131
00132
00133
00134 current->process_directive(ace_svc_desc_TAO_ORB_Core_Static_Resources);
00135 tocsr = ACE_Dynamic_Service<TAO_ORB_Core_Static_Resources>::instance
00136 (current, "TAO_ORB_Core_Static_Resources", true);
00137
00138 ACE_Service_Gestalt *global = ACE_Service_Config::global();
00139 if (current != global)
00140 {
00141 TAO_ORB_Core_Static_Resources* global_tocsr =
00142 ACE_Dynamic_Service<TAO_ORB_Core_Static_Resources>::instance
00143 (global,"TAO_ORB_Core_Static_Resources");
00144
00145 if (global_tocsr != 0)
00146 *tocsr = *global_tocsr;
00147 }
00148 }
00149
00150 return tocsr;
00151 }
00152
00153 TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void)
00154 : network_priority_protocols_hooks_name_ (
00155 "Network_Priority_Protocols_Hooks"),
00156 connection_timeout_hook_ (0),
00157 resource_factory_name_ ("Resource_Factory"),
00158 dynamic_adapter_name_ ("Dynamic_Adapter"),
00159 ifr_client_adapter_name_ ("IFR_Client_Adapter"),
00160 typecodefactory_adapter_name_ ("TypeCodeFactory_Adapter"),
00161 iorinterceptor_adapter_factory_name_ ("IORInterceptor_Adapter_Factory"),
00162 valuetype_adapter_factory_name_ ("Valuetype_Adapter_Factory"),
00163 alt_connection_timeout_hook_ (0)
00164 {
00165 }
00166
00167 TAO_ORB_Core_Static_Resources&
00168 TAO_ORB_Core_Static_Resources::operator=(const TAO_ORB_Core_Static_Resources& other)
00169 {
00170 this->network_priority_protocols_hooks_name_ =
00171 other.network_priority_protocols_hooks_name_;
00172 this->connection_timeout_hook_ = other.connection_timeout_hook_;
00173 this->resource_factory_name_ = other.resource_factory_name_;
00174 this->dynamic_adapter_name_ = other.dynamic_adapter_name_;
00175 this->ifr_client_adapter_name_ = other.ifr_client_adapter_name_;
00176 this->typecodefactory_adapter_name_ = other.typecodefactory_adapter_name_;
00177 this->iorinterceptor_adapter_factory_name_ =
00178 other.iorinterceptor_adapter_factory_name_;
00179 this->valuetype_adapter_factory_name_ =
00180 other.valuetype_adapter_factory_name_;
00181 this->alt_connection_timeout_hook_ = other.alt_connection_timeout_hook_;
00182 return *this;
00183 }
00184
00185
00186
00187 TAO_ORB_Core::TAO_ORB_Core (const char *orbid,
00188 ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> gestalt)
00189 : protocols_hooks_ (0),
00190 network_priority_protocols_hooks_ (0),
00191 #if TAO_USE_LOCAL_MEMORY_POOL == 1
00192 use_local_memory_pool_ (true),
00193 #else
00194 use_local_memory_pool_ (false),
00195 #endif
00196 lock_ (),
00197 thread_lane_resources_manager_ (0),
00198 collocation_resolver_ (0),
00199 stub_factory_ (0),
00200 protocol_factories_ (0),
00201 implrepo_service_ (CORBA::Object::_nil ()),
00202 use_implrepo_ (0),
00203 imr_endpoints_in_ior_ (1),
00204 typecode_factory_ (CORBA::Object::_nil ()),
00205 codec_factory_ (CORBA::Object::_nil ()),
00206 compression_manager_ (CORBA::Object::_nil ()),
00207 dynany_factory_ (CORBA::Object::_nil ()),
00208 ior_manip_factory_ (CORBA::Object::_nil ()),
00209 ior_table_ (CORBA::Object::_nil ()),
00210 monitor_ (CORBA::Object::_nil ()),
00211 orb_ (CORBA::ORB::_nil ()),
00212 root_poa_ (),
00213 orb_params_ (),
00214 init_ref_map_ (TAO_DEFAULT_OBJECT_REF_TABLE_SIZE),
00215 object_ref_table_ (),
00216 object_key_table_ (),
00217 orbid_ (ACE_OS::strdup (orbid ? orbid : "")),
00218 resource_factory_ (0),
00219 client_factory_ (0),
00220 server_factory_ (0),
00221 ft_send_extended_sc_ (false),
00222 opt_for_collocation_ (true),
00223 use_global_collocation_ (true),
00224 collocation_strategy_ (THRU_POA),
00225
00226 #if (TAO_HAS_CORBA_MESSAGING == 1)
00227
00228 policy_manager_ (0),
00229 default_policies_ (0),
00230 policy_current_ (0),
00231
00232 #endif
00233
00234 poa_current_ (),
00235 adapter_registry_ (this),
00236 poa_adapter_ (0),
00237 tm_ (),
00238 tss_cleanup_funcs_ (),
00239 tss_resources_ (),
00240 has_shutdown_ (true),
00241
00242
00243
00244
00245 thread_per_connection_use_timeout_ (1),
00246 open_lock_ (),
00247 endpoint_selector_factory_ (0),
00248 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00249 eager_transport_queueing_strategy_ (0),
00250 delayed_transport_queueing_strategy_ (0),
00251 flush_transport_queueing_strategy_ (0),
00252 #endif
00253 refcount_ (1),
00254 policy_factory_registry_ (0),
00255 orbinitializer_registry_ (0),
00256 #if (TAO_HAS_INTERCEPTORS == 1)
00257 pi_current_ (CORBA::Object::_nil ()),
00258 client_request_interceptor_adapter_ (0),
00259 server_request_interceptor_adapter_ (0),
00260 #endif
00261 ior_interceptor_adapter_ (0),
00262 valuetype_adapter_ (0),
00263 parser_registry_ (),
00264 bidir_adapter_ (0),
00265 bidir_giop_policy_ (0),
00266 ziop_adapter_ (0),
00267 ziop_enabled_ (false),
00268 flushing_strategy_ (0),
00269 codeset_manager_ (0),
00270 config_ (gestalt),
00271 sync_scope_hook_ (0),
00272 timeout_hook_ (0)
00273 {
00274 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00275
00276 ACE_NEW (this->flush_transport_queueing_strategy_,
00277 TAO::Flush_Transport_Queueing_Strategy);
00278
00279 #endif
00280
00281 #if (TAO_HAS_CORBA_MESSAGING == 1)
00282
00283 ACE_NEW (this->policy_manager_,
00284 TAO_Policy_Manager);
00285
00286 ACE_NEW (this->default_policies_,
00287 TAO_Policy_Set (TAO_POLICY_ORB_SCOPE));
00288
00289 ACE_NEW (this->policy_current_,
00290 TAO_Policy_Current);
00291
00292 #endif
00293
00294
00295 ACE_NEW (this->request_dispatcher_,
00296 TAO_Request_Dispatcher);
00297
00298 this->set_sync_scope_hook (TAO_ORB_Core::default_sync_scope_hook);
00299 }
00300
00301 TAO_ORB_Core::~TAO_ORB_Core (void)
00302 {
00303 delete this->thread_lane_resources_manager_;
00304
00305 delete this->flushing_strategy_;
00306
00307 ACE_OS::free (this->orbid_);
00308
00309 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00310
00311 delete this->eager_transport_queueing_strategy_;
00312 delete this->delayed_transport_queueing_strategy_;
00313 delete this->flush_transport_queueing_strategy_;
00314
00315 #endif
00316
00317 #if (TAO_HAS_CORBA_MESSAGING == 1)
00318
00319 ::CORBA::release (this->policy_manager_);
00320 delete this->default_policies_;
00321 ::CORBA::release (this->policy_current_);
00322
00323 #endif
00324
00325 delete this->request_dispatcher_;
00326
00327 delete this->policy_factory_registry_;
00328
00329
00330 orbinitializer_registry_ = 0;
00331
00332 ::CORBA::release (this->orb_);
00333
00334 delete this->codeset_manager_;
00335 this->codeset_manager_ = 0;
00336
00337
00338 (void) TAO::ORB::close_services (this->config_);
00339
00340 }
00341
00342 int
00343 TAO_ORB_Core::init (int &argc, char *argv[] )
00344 {
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 bool use_ior = true;
00360 int cdr_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF;
00361
00362
00363
00364
00365
00366 unsigned short ns_port = 0;
00367
00368
00369 unsigned short ts_port = 0;
00370
00371
00372 unsigned short ir_port = 0;
00373
00374
00375
00376
00377
00378 int rcv_sock_size = -1;
00379 int snd_sock_size = -1;
00380
00381
00382 int nodelay = 1;
00383
00384
00385 int so_keepalive = 0;
00386
00387
00388 int so_dontroute = 0;
00389
00390
00391 int ip_hoplimit = -1;
00392
00393
00394 int ip_multicastloop = 1;
00395
00396
00397
00398
00399
00400 #if (TAO_USE_DOTTED_DECIMAL_ADDRESSES == 1)
00401 int dotted_decimal_addresses = 1;
00402 #else
00403 int dotted_decimal_addresses = 0;
00404 #endif
00405
00406
00407 int no_server_side_name_lookups = 0;
00408
00409 #if defined (TAO_STD_PROFILE_COMPONENTS)
00410 bool std_profile_components = true;
00411 #else
00412 bool std_profile_components = false;
00413 #endif
00414
00415 int linger = TAO_SO_LINGER;
00416 time_t accept_error_delay = TAO_ACCEPT_ERROR_DELAY;
00417 bool use_parallel_connects = TAO_USE_PARALLEL_CONNECT;
00418
00419
00420 ACE_Argv_Type_Converter command_line (argc, argv);
00421
00422 ACE_Arg_Shifter arg_shifter (command_line.get_argc (),
00423 command_line.get_TCHAR_argv ());
00424
00425 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00426 monitor,
00427 this->lock_,
00428 -1);
00429
00430 #if (TAO_NEGOTIATE_CODESETS == 1)
00431 bool negotiate_codesets = true;
00432 #else
00433 bool negotiate_codesets = false;
00434 #endif
00435
00436
00437
00438
00439
00440 char* const use_IMR_env_var_value = ACE_OS::getenv ("TAO_USE_IMR") ;
00441 if (use_IMR_env_var_value != 0)
00442 {
00443 this->use_implrepo_ = ACE_OS::atoi (use_IMR_env_var_value) ;
00444 }
00445
00446
00447 while (arg_shifter.is_anything_left ())
00448 {
00449 const ACE_TCHAR *current_arg = 0;
00450
00451
00452
00453
00454 if (0 != (current_arg = arg_shifter.get_the_parameter
00455 (ACE_TEXT("-ORBDottedDecimalAddresses"))))
00456 {
00457
00458
00459 dotted_decimal_addresses =
00460 ACE_OS::atoi (current_arg);
00461
00462 arg_shifter.consume_arg ();
00463 }
00464 else if (0 != (current_arg = arg_shifter.get_the_parameter
00465 (ACE_TEXT("-ORBNoServerSideNameLookups"))))
00466 {
00467
00468 no_server_side_name_lookups =
00469 ACE_OS::atoi (current_arg);
00470
00471 arg_shifter.consume_arg ();
00472 }
00473 else if (0 != (current_arg = arg_shifter.get_the_parameter
00474 (ACE_TEXT("-ORBNameServicePort"))))
00475 {
00476
00477
00478
00479 ns_port = static_cast <CORBA::UShort> (ACE_OS::atoi (current_arg));
00480
00481 arg_shifter.consume_arg ();
00482 }
00483 else if (0 != (current_arg = arg_shifter.get_the_parameter
00484 (ACE_TEXT("-ORBMulticastDiscoveryEndpoint"))))
00485 {
00486
00487
00488
00489
00490
00491 this->orb_params ()->mcast_discovery_endpoint (
00492 ACE_TEXT_ALWAYS_CHAR(current_arg));
00493
00494 arg_shifter.consume_arg ();
00495 }
00496 else if (0 != (current_arg = arg_shifter.get_the_parameter
00497 (ACE_TEXT("-ORBNodelay"))))
00498 {
00499
00500 nodelay =
00501 ACE_OS::atoi (current_arg);
00502
00503 arg_shifter.consume_arg ();
00504 }
00505 else if (0 != (current_arg = arg_shifter.get_the_parameter
00506 (ACE_TEXT("-ORBKeepalive"))))
00507 {
00508
00509 so_keepalive =
00510 ACE_OS::atoi (current_arg);
00511
00512 arg_shifter.consume_arg ();
00513 }
00514 else if (0 != (current_arg = arg_shifter.get_the_parameter
00515 (ACE_TEXT("-ORBDontRoute"))))
00516 {
00517
00518 so_dontroute =
00519 ACE_OS::atoi (current_arg);
00520
00521 arg_shifter.consume_arg ();
00522 }
00523 else if (0 != (current_arg = arg_shifter.get_the_parameter
00524 (ACE_TEXT("-ORBIPHopLimit"))))
00525 {
00526
00527 ip_hoplimit =
00528 ACE_OS::atoi (current_arg);
00529
00530 arg_shifter.consume_arg ();
00531 }
00532 else if (0 != (current_arg = arg_shifter.get_the_parameter
00533 (ACE_TEXT("-ORBIPMulticastLoop"))))
00534 {
00535
00536 ip_multicastloop =
00537 ACE_OS::atoi (current_arg);
00538
00539 arg_shifter.consume_arg ();
00540 }
00541 else if (0 != (current_arg = arg_shifter.get_the_parameter
00542 (ACE_TEXT("-ORBTradingServicePort"))))
00543 {
00544
00545
00546 ts_port = static_cast <CORBA::UShort> (ACE_OS::atoi (current_arg));
00547
00548 arg_shifter.consume_arg ();
00549 }
00550 else if (0 != (current_arg = arg_shifter.get_the_parameter
00551 (ACE_TEXT("-ORBImplRepoServicePort"))))
00552 {
00553
00554
00555 ir_port = static_cast <CORBA::UShort> (ACE_OS::atoi (current_arg));
00556
00557 arg_shifter.consume_arg ();
00558 }
00559 else if (0 != (current_arg = arg_shifter.get_the_parameter
00560 (ACE_TEXT("-ORBRcvSock"))))
00561 {
00562
00563
00564
00565
00566
00567
00568 rcv_sock_size = ACE_OS::atoi (current_arg);
00569
00570 arg_shifter.consume_arg ();
00571 }
00572 else if (0 != (current_arg = arg_shifter.get_the_parameter
00573 (ACE_TEXT("-ORBSndSock"))))
00574 {
00575
00576
00577
00578
00579
00580 snd_sock_size = ACE_OS::atoi (current_arg);
00581
00582 arg_shifter.consume_arg ();
00583 }
00584 else if (0 != (current_arg = arg_shifter.get_the_parameter
00585 (ACE_TEXT("-ORBObjRefStyle"))))
00586 {
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606 const ACE_TCHAR *opt = current_arg;
00607 if (ACE_OS::strcasecmp (opt, ACE_TEXT("URL")) == 0)
00608 use_ior = false;
00609 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("IOR")) == 0)
00610 use_ior = true;
00611
00612 arg_shifter.consume_arg ();
00613 }
00614 else if (0 != (current_arg = arg_shifter.get_the_parameter
00615 (ACE_TEXT("-ORBCollocationStrategy"))))
00616 {
00617
00618 const ACE_TCHAR *opt = current_arg;
00619 if (ACE_OS::strcasecmp (opt, ACE_TEXT("thru_poa")) == 0)
00620 this->collocation_strategy_ = THRU_POA;
00621 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("direct")) == 0)
00622 this->collocation_strategy_ = DIRECT;
00623
00624 arg_shifter.consume_arg ();
00625 }
00626 else if (0 != (current_arg = arg_shifter.get_the_parameter
00627 (ACE_TEXT("-ORBCollocation"))))
00628 {
00629
00630
00631
00632
00633 const ACE_TCHAR *opt = current_arg;
00634 if (ACE_OS::strcasecmp (opt, ACE_TEXT("global")) == 0)
00635 {
00636 this->opt_for_collocation_ = true;
00637 this->use_global_collocation_ = true;
00638 }
00639 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("NO")) == 0)
00640 {
00641 this->opt_for_collocation_ = false;
00642 this->use_global_collocation_ = false;
00643 }
00644 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("per-orb")) == 0)
00645 {
00646 this->opt_for_collocation_ = true;
00647 this->use_global_collocation_ = false;
00648 }
00649 else
00650 {
00651 ACE_DEBUG ((LM_WARNING,
00652 ACE_TEXT ("WARNING: Unknown option to ")
00653 ACE_TEXT ("'-ORBCollocation': %s\n"), opt));
00654 }
00655
00656 arg_shifter.consume_arg ();
00657 }
00658 else if (0 != (current_arg = arg_shifter.get_the_parameter
00659 (ACE_TEXT("-ORBPreferredInterfaces"))))
00660 {
00661 if (this->orb_params ()->preferred_interfaces (
00662 ACE_TEXT_ALWAYS_CHAR (current_arg)) == false)
00663 throw ::CORBA::INTERNAL (
00664 CORBA::SystemException::_tao_minor_code (
00665 TAO_ORB_CORE_INIT_LOCATION_CODE,
00666 0),
00667 CORBA::COMPLETED_NO);
00668
00669 arg_shifter.consume_arg ();
00670 }
00671 else if (0 != (current_arg = arg_shifter.get_the_parameter
00672 (ACE_TEXT("-ORBEnforcePreferredInterfaces"))))
00673 {
00674 int enforce_pref_interfaces = ACE_OS::atoi (current_arg);
00675 if (enforce_pref_interfaces)
00676 this->orb_params ()->enforce_pref_interfaces (false);
00677 else
00678 this->orb_params ()->enforce_pref_interfaces (true);
00679
00680 arg_shifter.consume_arg ();
00681 }
00682 #if defined (ACE_HAS_IPV6)
00683 else if (0 != (current_arg = arg_shifter.get_the_parameter
00684 (ACE_TEXT("-ORBPreferIPV6Interfaces"))))
00685 {
00686 int prefer_ipv6_interfaces = ACE_OS::atoi (current_arg);
00687 if (prefer_ipv6_interfaces)
00688 this->orb_params ()->prefer_ipv6_interfaces (true);
00689 else
00690 this->orb_params ()->prefer_ipv6_interfaces (false);
00691
00692 arg_shifter.consume_arg ();
00693 }
00694 else if (0 != (current_arg = arg_shifter.get_the_parameter
00695 (ACE_TEXT("-ORBConnectIPV6Only"))))
00696 {
00697 int connect_ipv6_only = ACE_OS::atoi (current_arg);
00698 if (connect_ipv6_only)
00699 this->orb_params ()->connect_ipv6_only (true);
00700 else
00701 this->orb_params ()->connect_ipv6_only (false);
00702
00703 arg_shifter.consume_arg ();
00704 }
00705 else if ((current_arg = arg_shifter.get_the_parameter
00706 (ACE_TEXT("-ORBUseIPV6LinkLocal"))))
00707 {
00708 int use_ipv6_link_local = ACE_OS::atoi (current_arg);
00709 if (use_ipv6_link_local)
00710 this->orb_params ()->use_ipv6_link_local (true);
00711 else
00712 this->orb_params ()->use_ipv6_link_local (false);
00713
00714 arg_shifter.consume_arg ();
00715 }
00716 #endif
00717 else if (0 != (current_arg = arg_shifter.get_the_parameter
00718 (ACE_TEXT("-ORBCDRTradeoff"))))
00719 {
00720 cdr_tradeoff = ACE_OS::atoi (current_arg);
00721
00722 arg_shifter.consume_arg ();
00723 }
00724
00725
00726
00727
00728 else if (0 != (current_arg = arg_shifter.get_the_parameter
00729 (ACE_TEXT("-ORBInitRef"))))
00730 {
00731 const ACE_TCHAR *pos = ACE_OS::strchr (current_arg, '=');
00732 if (pos == 0)
00733 {
00734 ACE_ERROR ((LM_ERROR,
00735 ACE_TEXT ("Invalid ORBInitRef argument '%s'")
00736 ACE_TEXT ("format is ObjectID=IOR\n"),
00737 current_arg));
00738 throw ::CORBA::INTERNAL (
00739 CORBA::SystemException::_tao_minor_code (
00740 TAO_ORB_CORE_INIT_LOCATION_CODE,
00741 0),
00742 CORBA::COMPLETED_NO);
00743 }
00744 ACE_CString object_id (ACE_TEXT_ALWAYS_CHAR(current_arg),
00745 pos - current_arg);
00746 ACE_CString IOR (ACE_TEXT_ALWAYS_CHAR(pos + 1));
00747 if (!this->init_ref_map_.insert (
00748 std::make_pair (InitRefMap::key_type (object_id),
00749 InitRefMap::data_type (IOR))).second)
00750 {
00751 ACE_ERROR ((LM_ERROR,
00752 ACE_TEXT ("Duplicate -ORBInitRef ")
00753 ACE_TEXT ("argument '%s'\n"),
00754 current_arg));
00755 throw ::CORBA::INTERNAL (
00756 CORBA::SystemException::_tao_minor_code (
00757 TAO_ORB_CORE_INIT_LOCATION_CODE,
00758 0),
00759 CORBA::COMPLETED_NO);
00760 }
00761 arg_shifter.consume_arg ();
00762 }
00763 else if (0 != (current_arg = arg_shifter.get_the_parameter
00764 (ACE_TEXT("-ORBDefaultInitRef"))))
00765 {
00766
00767 this->orb_params ()->default_init_ref
00768 (ACE_TEXT_ALWAYS_CHAR(current_arg));
00769
00770 arg_shifter.consume_arg ();
00771 }
00772 else if (0 != (current_arg = arg_shifter.get_the_parameter
00773 (ACE_TEXT("-ORBStdProfileComponents"))))
00774 {
00775 std_profile_components =
00776 ACE_OS::atoi (current_arg);
00777 arg_shifter.consume_arg ();
00778 }
00779 else if (0 != (current_arg = arg_shifter.get_the_parameter
00780 (ACE_TEXT("-ORBAMICollocation"))))
00781 {
00782 int ami_collocation = ACE_OS::atoi (current_arg);
00783 if (ami_collocation)
00784 this->orb_params ()->ami_collication (true);
00785 else
00786 this->orb_params ()->ami_collication (false);
00787
00788 arg_shifter.consume_arg ();
00789 }
00790 else if (0 != (current_arg = arg_shifter.get_the_parameter
00791 (ACE_TEXT("-ORBResources"))))
00792 {
00793 ACE_DEBUG ((LM_WARNING,
00794 ACE_TEXT ("\"-ORBResources\" has been ")
00795 ACE_TEXT ("deprecated.\n")));
00796
00797 arg_shifter.consume_arg ();
00798 }
00799 else if (0 != (current_arg = arg_shifter.get_the_parameter
00800 (ACE_TEXT("-ORBLogFile"))))
00801 {
00802
00803
00804
00805
00806
00807 const ACE_TCHAR *file_name = current_arg;
00808 arg_shifter.consume_arg ();
00809
00810
00811
00812
00813
00814 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
00815
00816 FILE* output_stream = ACE_OS::fopen (file_name, ACE_TEXT ("a"));
00817
00818 ACE_LOG_MSG->msg_ostream (output_stream, 1);
00819
00820 #else
00821
00822 ofstream* output_stream = 0;
00823
00824
00825
00826
00827
00828
00829 ACE_NEW_THROW_EX (output_stream,
00830 ofstream (),
00831 CORBA::NO_MEMORY (
00832 CORBA::SystemException::_tao_minor_code (
00833 TAO_ORB_CORE_INIT_LOCATION_CODE,
00834 ENOMEM),
00835 CORBA::COMPLETED_NO));
00836
00837 output_stream->open (ACE_TEXT_ALWAYS_CHAR (file_name),
00838 ios::out | ios::app);
00839
00840 if (!output_stream->bad ())
00841 {
00842 ACE_LOG_MSG->msg_ostream (output_stream, 1);
00843 }
00844
00845 #endif
00846
00847 ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER);
00848 ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
00849 }
00850 else if (0 != (current_arg = arg_shifter.get_the_parameter
00851 (ACE_TEXT("-ORBVerboseLogging"))))
00852 {
00853 unsigned long const verbose_logging = ACE_OS::atoi (current_arg);
00854
00855 arg_shifter.consume_arg ();
00856
00857 typedef void (ACE_Log_Msg::*PTMF)(u_long);
00858 PTMF flagop = &ACE_Log_Msg::set_flags;
00859 u_long value;
00860
00861 switch (verbose_logging)
00862 {
00863 case 0:
00864 flagop = &ACE_Log_Msg::clr_flags;
00865 value = ACE_Log_Msg::VERBOSE | ACE_Log_Msg::VERBOSE_LITE;
00866 break;
00867 case 1:
00868 value = ACE_Log_Msg::VERBOSE_LITE; break;
00869 default:
00870 value = ACE_Log_Msg::VERBOSE; break;
00871 }
00872
00873 (ACE_LOG_MSG->*flagop)(value);
00874 }
00875 else if ((current_arg = arg_shifter.get_the_parameter
00876 (ACE_TEXT("-ORBHandleLoggingStrategyEvents"))))
00877 {
00878 ACE_Logging_Strategy *logging_strategy =
00879 dynamic_cast<ACE_Logging_Strategy*> (
00880 ACE_Dynamic_Service<ACE_Service_Object>::instance (current_arg));
00881
00882 if (logging_strategy != 0)
00883 {
00884 logging_strategy->reactor (this->reactor ());
00885 }
00886
00887 arg_shifter.consume_arg ();
00888 }
00889 else if (0 != (current_arg = arg_shifter.get_the_parameter
00890 (ACE_TEXT("-ORBUseIMR"))))
00891 {
00892
00893 this->use_implrepo_ = ACE_OS::atoi (current_arg);
00894
00895 arg_shifter.consume_arg ();
00896 }
00897 else if (0 != (current_arg = arg_shifter.get_the_parameter
00898 (ACE_TEXT("-ORBIMREndpointsInIOR"))))
00899 {
00900 this->imr_endpoints_in_ior_ = ACE_OS::atoi (current_arg);
00901
00902 arg_shifter.consume_arg ();
00903 }
00904 else if (0 != (current_arg = arg_shifter.get_the_parameter
00905 (ACE_TEXT("-ORBid"))))
00906 {
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921 arg_shifter.consume_arg ();
00922 }
00923 else if (0 != (current_arg = arg_shifter.get_the_parameter
00924 (ACE_TEXT("-ORBServerId"))))
00925 {
00926
00927
00928
00929 this->server_id_.set(ACE_TEXT_ALWAYS_CHAR(current_arg));
00930
00931 arg_shifter.consume_arg ();
00932 }
00933 else if (0 != (current_arg = arg_shifter.get_the_parameter
00934 (ACE_TEXT("-ORBLingerTimeout"))))
00935 {
00936 linger = ACE_OS::atoi (current_arg);
00937
00938 arg_shifter.consume_arg ();
00939 }
00940 else if (0 != (current_arg = arg_shifter.get_the_parameter
00941 (ACE_TEXT("-ORBAcceptErrorDelay"))))
00942 {
00943 accept_error_delay = ACE_OS::atoi (current_arg);
00944
00945 arg_shifter.consume_arg ();
00946 }
00947 else if (0 != (current_arg = arg_shifter.get_the_parameter
00948 (ACE_TEXT("-ORBEndpoint"))))
00949 {
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969 this->set_endpoint_helper (TAO_DEFAULT_LANE,
00970 ACE_TEXT_ALWAYS_CHAR (current_arg));
00971
00972 arg_shifter.consume_arg ();
00973 }
00974 else if (0 != (current_arg = arg_shifter.get_the_parameter
00975 (ACE_TEXT("-ORBListenEndpoints"))))
00976 {
00977
00978
00979
00980
00981
00982 this->set_endpoint_helper (TAO_DEFAULT_LANE,
00983 ACE_TEXT_ALWAYS_CHAR (current_arg));
00984
00985 arg_shifter.consume_arg ();
00986 }
00987 else if ((0 != (current_arg = arg_shifter.get_the_parameter
00988 (ACE_TEXT("-ORBLaneEndpoint")))) ||
00989 (0 != (current_arg = arg_shifter.get_the_parameter
00990 (ACE_TEXT("-ORBLaneListenEndpoints")))))
00991 {
00992
00993
00994
00995 if (arg_shifter.is_option_next ())
00996 return -1;
00997
00998 ACE_CString lane (ACE_TEXT_ALWAYS_CHAR (current_arg));
00999 arg_shifter.consume_arg ();
01000
01001 if (arg_shifter.is_option_next ())
01002 return -1;
01003
01004 ACE_CString endpoints (ACE_TEXT_ALWAYS_CHAR
01005 (arg_shifter.get_current ()));
01006 arg_shifter.consume_arg ();
01007
01008 this->set_endpoint_helper (lane, endpoints);
01009 }
01010 else if (0 != (current_arg = arg_shifter.get_the_parameter
01011 (ACE_TEXT("-ORBNoProprietaryActivation"))))
01012 {
01013
01014
01015
01016
01017
01018
01019
01020
01021 throw ::CORBA::NO_IMPLEMENT ();
01022 }
01023 else if (0 != (current_arg = arg_shifter.get_the_parameter
01024 (ACE_TEXT("-ORBUseSharedProfile"))))
01025 {
01026 this->orb_params ()->shared_profile (ACE_OS::atoi (current_arg));
01027
01028 arg_shifter.consume_arg ();
01029 }
01030 else if (0 != (current_arg = arg_shifter.get_the_parameter
01031 (ACE_TEXT("-ORBNegotiateCodesets"))))
01032 {
01033 negotiate_codesets = (ACE_OS::atoi (current_arg));
01034
01035 arg_shifter.consume_arg ();
01036 }
01037 else if (0 != (current_arg = arg_shifter.get_the_parameter
01038 (ACE_TEXT("-ORBUseParallelConnects"))))
01039 {
01040 use_parallel_connects = ACE_OS::atoi (current_arg);
01041 arg_shifter.consume_arg ();
01042 }
01043 else if (0 != (current_arg = arg_shifter.get_the_parameter
01044 (ACE_TEXT("-ORBParallelConnectDelay"))))
01045 {
01046 this->orb_params ()->parallel_connect_delay
01047 (ACE_OS::atoi (current_arg));
01048 arg_shifter.consume_arg ();
01049 }
01050 else if (0 != (current_arg = arg_shifter.get_the_parameter
01051 (ACE_TEXT("-ORBSingleReadOptimization"))))
01052 {
01053 this->orb_params ()->single_read_optimization
01054 (ACE_OS::atoi (current_arg));
01055
01056 arg_shifter.consume_arg ();
01057 }
01058 else if (0 != (current_arg = arg_shifter.get_the_parameter
01059 (ACE_TEXT("-ORBDisableRTCollocation"))))
01060 {
01061 int disable_rt_collocation = ACE_OS::atoi (current_arg);
01062 if (disable_rt_collocation)
01063 this->orb_params ()->disable_rt_collocation_resolver (true);
01064 else
01065 this->orb_params ()->disable_rt_collocation_resolver (false);
01066
01067 arg_shifter.consume_arg ();
01068 }
01069 else if (0 != (current_arg = arg_shifter.get_the_parameter
01070 (ACE_TEXT("-ORBUseLocalMemoryPool"))))
01071 {
01072 this->use_local_memory_pool_ = (0 != ACE_OS::atoi (current_arg));
01073
01074 arg_shifter.consume_arg ();
01075 }
01076 else if (0 != (current_arg = arg_shifter.get_the_parameter
01077 (ACE_TEXT("-ORBMaxMessageSize"))))
01078 {
01079 this->orb_params_.max_message_size (ACE_OS::atoi (current_arg));
01080
01081 arg_shifter.consume_arg ();
01082 }
01083 else if (0 != (current_arg = arg_shifter.get_the_parameter
01084 (ACE_TEXT("-ORBFTSendFullGroupTC"))))
01085 {
01086 this->ft_send_extended_sc_ = ACE_OS::atoi (current_arg);
01087
01088 arg_shifter.consume_arg ();
01089 }
01090 else if (0 != (current_arg = arg_shifter.get_the_parameter
01091 (ACE_TEXT("-ORBForwardInvocationOnObjectNotExist"))))
01092 {
01093 int forward = ACE_OS::atoi (current_arg);
01094 if (forward)
01095 this->orb_params_.forward_invocation_on_object_not_exist (true);
01096 else
01097 this->orb_params_.forward_invocation_on_object_not_exist (false);
01098
01099 arg_shifter.consume_arg ();
01100 }
01101 else if (0 != (current_arg = arg_shifter.get_the_parameter
01102 (ACE_TEXT("-ORBForwardOnceOnObjectNotExist"))))
01103 {
01104 int forward = ACE_OS::atoi (current_arg);
01105 if (forward)
01106 this->orb_params_.forward_once_exception (TAO::FOE_OBJECT_NOT_EXIST);
01107
01108 arg_shifter.consume_arg ();
01109 }
01110 else if (0 != (current_arg = arg_shifter.get_the_parameter
01111 (ACE_TEXT("-ORBForwardOnceOnCommFailure"))))
01112 {
01113 int forward = ACE_OS::atoi (current_arg);
01114 if (forward)
01115 this->orb_params_.forward_once_exception (TAO::FOE_COMM_FAILURE);
01116
01117 arg_shifter.consume_arg ();
01118 }
01119 else if (0 != (current_arg = arg_shifter.get_the_parameter
01120 (ACE_TEXT("-ORBForwardOnceOnTransient"))))
01121 {
01122 int forward = ACE_OS::atoi (current_arg);
01123 if (forward)
01124 this->orb_params_.forward_once_exception (TAO::FOE_TRANSIENT);
01125
01126 arg_shifter.consume_arg ();
01127 }
01128 else if (0 != (current_arg = arg_shifter.get_the_parameter
01129 (ACE_TEXT("-ORBForwardOnceOnInvObjref"))))
01130 {
01131 int forward = ACE_OS::atoi (current_arg);
01132 if (forward)
01133 this->orb_params_.forward_once_exception (TAO::FOE_INV_OBJREF);
01134
01135 arg_shifter.consume_arg ();
01136 }
01137
01138
01139
01140
01141 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ORB")) != -1)
01142 {
01143 if (TAO_debug_level > 0)
01144 {
01145 current_arg = arg_shifter.get_current ();
01146 ACE_ERROR ((LM_ERROR,
01147 ACE_TEXT ("ERROR: Unknown \"-ORB\" option ")
01148 ACE_TEXT ("<%s>.\n"),
01149 ((current_arg == 0) ? ACE_TEXT("<NULL>")
01150 : current_arg)));
01151 }
01152
01153 throw ::CORBA::BAD_PARAM (
01154 CORBA::SystemException::_tao_minor_code (
01155 TAO_ORB_CORE_INIT_LOCATION_CODE,
01156 EINVAL),
01157 CORBA::COMPLETED_NO);
01158 }
01159
01160
01161
01162
01163 else
01164 {
01165
01166
01167 arg_shifter.ignore_arg ();
01168 }
01169 }
01170
01171 const char *env_endpoint =
01172 ACE_OS::getenv ("TAO_ORBENDPOINT");
01173
01174 if (env_endpoint != 0)
01175 {
01176 int result =
01177 this->orb_params ()->add_endpoints (TAO_DEFAULT_LANE, env_endpoint);
01178
01179 if (result != 0)
01180 {
01181 if (TAO_debug_level > 0)
01182 {
01183 ACE_ERROR ((LM_ERROR,
01184 ACE_TEXT ("ERROR: Environment variable ")
01185 ACE_TEXT ("TAO_ORBENDPOINT set to invalid value ")
01186 ACE_TEXT ("<%C>.\n"),
01187 env_endpoint));
01188 }
01189
01190 throw ::CORBA::BAD_PARAM (
01191 CORBA::SystemException::_tao_minor_code (
01192 TAO_ORB_CORE_INIT_LOCATION_CODE,
01193 EINVAL),
01194 CORBA::COMPLETED_NO);
01195 }
01196 }
01197
01198 #if defined (SIGPIPE) && !defined (ACE_LACKS_UNIX_SIGNALS)
01199
01200
01201
01202
01203
01204
01205
01206
01207 (void) ACE_OS::signal (SIGPIPE, (ACE_SignalHandler) SIG_IGN);
01208 #endif
01209
01210
01211
01212
01213 this->parser_registry_.open (this);
01214
01215
01216
01217
01218 TAO_Resource_Factory *trf = this->resource_factory ();
01219
01220 if (trf == 0)
01221 {
01222 ACE_ERROR ((LM_ERROR,
01223 ACE_TEXT ("TAO (%P|%t) - %p\n"),
01224 ACE_TEXT ("ORB Core unable to find a ")
01225 ACE_TEXT ("Resource Factory instance")));
01226 throw ::CORBA::INTERNAL (
01227 CORBA::SystemException::_tao_minor_code (
01228 TAO_ORB_CORE_INIT_LOCATION_CODE,
01229 0),
01230 CORBA::COMPLETED_NO);
01231 }
01232
01233
01234
01235 trf->use_local_memory_pool (this->use_local_memory_pool_);
01236
01237
01238
01239 ACE_Reactor *reactor = this->reactor ();
01240 if (reactor == 0)
01241 {
01242 ACE_ERROR ((LM_ERROR,
01243 ACE_TEXT ("TAO (%P|%t) - %p\n"),
01244 ACE_TEXT ("ORB Core unable to initialize reactor")));
01245 throw ::CORBA::INITIALIZE (
01246 CORBA::SystemException::_tao_minor_code (
01247 TAO_ORB_CORE_INIT_LOCATION_CODE,
01248 0),
01249 CORBA::COMPLETED_NO);
01250 }
01251
01252 TAO_Server_Strategy_Factory *ssf = this->server_factory ();
01253
01254 if (ssf == 0)
01255 {
01256 ACE_ERROR ((LM_ERROR,
01257 ACE_TEXT ("TAO (%P|%t) - %p\n"),
01258 ACE_TEXT ("ORB Core unable to find a ")
01259 ACE_TEXT ("Server Strategy Factory instance")));
01260 throw ::CORBA::INTERNAL (
01261 CORBA::SystemException::_tao_minor_code (
01262 TAO_ORB_CORE_INIT_LOCATION_CODE,
01263 0),
01264 CORBA::COMPLETED_NO);
01265 }
01266
01267 ssf->open (this);
01268
01269
01270 (void) this->object_key_table_.init (this);
01271
01272
01273 this->thread_per_connection_use_timeout_ =
01274 ssf->thread_per_connection_timeout (this->thread_per_connection_timeout_);
01275
01276 if (thread_per_connection_use_timeout_ == -1)
01277 {
01278 if (ACE_OS::strcasecmp (TAO_DEFAULT_THREAD_PER_CONNECTION_TIMEOUT,
01279 "INFINITE") == 0)
01280 {
01281 this->thread_per_connection_use_timeout_ = 0;
01282 }
01283 else
01284 {
01285 this->thread_per_connection_use_timeout_ = 1;
01286 int milliseconds =
01287 ACE_OS::atoi (TAO_DEFAULT_THREAD_PER_CONNECTION_TIMEOUT);
01288
01289 this->thread_per_connection_timeout_ =
01290 ACE_Time_Value (0, 1000 * milliseconds);
01291 }
01292 }
01293 if (this->thread_per_connection_use_timeout_ == 0)
01294 {
01295
01296
01297 this->tm_.wait_on_exit (0);
01298 }
01299
01300
01301 this->orb_ = CORBA::ORB::_tao_make_ORB (this);
01302
01303
01304
01305 this->orb_->_use_omg_ior_format (use_ior);
01306
01307
01308
01309
01310
01311 this->orb_params ()->service_port (TAO::MCAST_NAMESERVICE, ns_port);
01312
01313 if (ns_port != 0)
01314 {
01315 static char const mcast_fmt[] = "mcast://:%d::";
01316 static size_t const PORT_BUF_SIZE = 256;
01317
01318 char def_init_ref[PORT_BUF_SIZE] = { 0 };
01319
01320 ACE_OS::snprintf (def_init_ref,
01321 PORT_BUF_SIZE,
01322 mcast_fmt,
01323 ns_port);
01324
01325 this->orb_params ()->default_init_ref (def_init_ref);
01326 }
01327
01328 this->orb_params ()->service_port (TAO::MCAST_TRADINGSERVICE, ts_port);
01329 this->orb_params ()->service_port (TAO::MCAST_IMPLREPOSERVICE, ir_port);
01330
01331 this->orb_params ()->use_dotted_decimal_addresses (dotted_decimal_addresses);
01332
01333
01334 this->orb_params ()->cache_incoming_by_dotted_decimal_address
01335 (no_server_side_name_lookups
01336 || dotted_decimal_addresses);
01337
01338 this->orb_params ()->use_parallel_connects
01339 (use_parallel_connects != 0);
01340
01341 this->orb_params ()->linger (linger);
01342 this->orb_params ()->accept_error_delay (accept_error_delay);
01343 this->orb_params ()->nodelay (nodelay);
01344 this->orb_params ()->sock_keepalive (so_keepalive);
01345 this->orb_params ()->sock_dontroute (so_dontroute);
01346 this->orb_params ()->ip_hoplimit (ip_hoplimit);
01347 this->orb_params ()->ip_multicastloop (ip_multicastloop);
01348 if (rcv_sock_size >= 0)
01349 this->orb_params ()->sock_rcvbuf_size (rcv_sock_size);
01350 if (snd_sock_size >= 0)
01351 this->orb_params ()->sock_sndbuf_size (snd_sock_size);
01352 if (cdr_tradeoff >= 0)
01353 this->orb_params ()->cdr_memcpy_tradeoff (cdr_tradeoff);
01354
01355 this->orb_params ()->std_profile_components (std_profile_components);
01356
01357 this->orb_params ()->negotiate_codesets (negotiate_codesets);
01358
01359 if (this->codeset_manager())
01360 this->codeset_manager_->open(*this);
01361 else
01362 if (TAO_debug_level > 0)
01363 ACE_DEBUG ((LM_DEBUG,
01364 ACE_TEXT("TAO (%P|%t) - ORB_Core: ")
01365 ACE_TEXT("Codeset Manager not available\n")));
01366
01367
01368
01369
01370
01371 if (trf->init_protocol_factories () == -1)
01372 throw ::CORBA::INITIALIZE (
01373 CORBA::SystemException::_tao_minor_code (
01374 TAO_ORB_CORE_INIT_LOCATION_CODE,
01375 0),
01376 CORBA::COMPLETED_NO);
01377
01378
01379 this->protocol_factories_ = trf->get_protocol_factories ();
01380
01381
01382 this->flushing_strategy_ = trf->create_flushing_strategy ();
01383
01384
01385 const char *protocols_hooks_name = this->orb_params ()->protocols_hooks_name ();
01386
01387 this->protocols_hooks_ =
01388 ACE_Dynamic_Service<TAO_Protocols_Hooks>::instance
01389 (this->configuration (),
01390 ACE_TEXT_CHAR_TO_TCHAR (protocols_hooks_name));
01391
01392 if (this->protocols_hooks_ != 0)
01393 {
01394
01395 this->protocols_hooks_->init_hooks (this);
01396 }
01397
01398
01399 ACE_Service_Object *adapter_factory =
01400 ACE_Dynamic_Service<ACE_Service_Object>::instance (
01401 this->configuration (),
01402 this->orb_params ()->poa_factory_name ());
01403
01404 if (adapter_factory != 0)
01405 {
01406 adapter_factory->init (0, 0);
01407 }
01408
01409
01410
01411 const ACE_CString &network_priority_protocols_hooks_name =
01412 TAO_ORB_Core_Static_Resources::instance ()->
01413 network_priority_protocols_hooks_name_;
01414
01415 this->network_priority_protocols_hooks_ =
01416 ACE_Dynamic_Service<TAO_Network_Priority_Protocols_Hooks>::instance
01417 (this->configuration (),
01418 ACE_TEXT_CHAR_TO_TCHAR (network_priority_protocols_hooks_name.c_str()));
01419
01420 if (this->network_priority_protocols_hooks_ != 0)
01421 {
01422
01423 this->network_priority_protocols_hooks_->init_hooks (this);
01424 }
01425
01426
01427 this->services_callbacks_init ();
01428
01429
01430
01431 this->has_shutdown_ = false;
01432
01433 return 0;
01434 }
01435
01436
01437 int
01438 TAO_ORB_Core::fini (void)
01439 {
01440 try
01441 {
01442
01443 this->shutdown (1);
01444 }
01445 catch (const ::CORBA::Exception& ex)
01446 {
01447 ACE_CString message =
01448 "Exception caught in trying to shutdown ";
01449 message += this->orbid_;
01450 message += "\n";
01451
01452 ex._tao_print_exception (message.c_str ());
01453 }
01454
01455
01456 (void) this->thr_mgr ()->wait ();
01457
01458 ::CORBA::release (this->typecode_factory_);
01459
01460 ::CORBA::release (this->codec_factory_);
01461
01462 ::CORBA::release (this->dynany_factory_);
01463
01464 ::CORBA::release (this->ior_manip_factory_);
01465
01466 ::CORBA::release (this->ior_table_);
01467
01468 ::CORBA::release (this->monitor_);
01469
01470 if (TAO_debug_level > 2)
01471 {
01472 ACE_DEBUG ((LM_DEBUG,
01473 ACE_TEXT ("TAO (%P|%t) - Destroying ORB <%C>\n"),
01474 this->orbid_));
01475 }
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488 if (this->thread_lane_resources_manager_ != 0)
01489 this->thread_lane_resources_manager_->finalize ();
01490
01491
01492 this->object_key_table_.destroy ();
01493
01494 delete this;
01495
01496 return 0;
01497 }
01498
01499 void
01500 TAO_ORB_Core::set_resource_factory (const char *resource_factory_name)
01501 {
01502 TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_ =
01503 resource_factory_name;
01504 }
01505
01506 void
01507 TAO_ORB_Core::set_gui_resource_factory (TAO::GUIResource_Factory *gui_resource_factory)
01508 {
01509 if (TAO_TSS_Resources::instance ()->gui_resource_factory_ != 0)
01510 {
01511 if (TAO_debug_level > 2)
01512 {
01513 ACE_DEBUG ((LM_DEBUG,
01514 "TAO (%P|%t) - Deleting old gui_resource_factory.\n"));
01515 }
01516 delete TAO_TSS_Resources::instance ()->gui_resource_factory_;
01517 }
01518
01519 TAO_TSS_Resources::instance ()->gui_resource_factory_ = gui_resource_factory;
01520 }
01521
01522 void
01523 TAO_ORB_Core::dynamic_adapter_name (const char *name)
01524 {
01525 TAO_ORB_Core_Static_Resources::instance ()->dynamic_adapter_name_ = name;
01526 }
01527
01528 const char *
01529 TAO_ORB_Core::dynamic_adapter_name (void)
01530 {
01531 return TAO_ORB_Core_Static_Resources::instance ()->dynamic_adapter_name_.c_str();
01532 }
01533
01534 void
01535 TAO_ORB_Core::ifr_client_adapter_name (const char *name)
01536 {
01537 TAO_ORB_Core_Static_Resources::instance ()->ifr_client_adapter_name_ = name;
01538 }
01539
01540 const char *
01541 TAO_ORB_Core::ifr_client_adapter_name (void)
01542 {
01543 return TAO_ORB_Core_Static_Resources::instance ()->ifr_client_adapter_name_.c_str();
01544 }
01545
01546 void
01547 TAO_ORB_Core::typecodefactory_adapter_name (const char *name)
01548 {
01549 TAO_ORB_Core_Static_Resources::instance ()->typecodefactory_adapter_name_ = name;
01550 }
01551
01552 const char *
01553 TAO_ORB_Core::typecodefactory_adapter_name (void)
01554 {
01555 return TAO_ORB_Core_Static_Resources::instance ()->typecodefactory_adapter_name_.c_str();
01556 }
01557
01558 void
01559 TAO_ORB_Core::iorinterceptor_adapter_factory_name (const char *name)
01560 {
01561 TAO_ORB_Core_Static_Resources::instance ()->iorinterceptor_adapter_factory_name_ = name;
01562 }
01563
01564 const char *
01565 TAO_ORB_Core::iorinterceptor_adapter_factory_name (void)
01566 {
01567 return TAO_ORB_Core_Static_Resources::instance ()->iorinterceptor_adapter_factory_name_.c_str();
01568 }
01569
01570 void
01571 TAO_ORB_Core::valuetype_adapter_factory_name (const char *name)
01572 {
01573 TAO_ORB_Core_Static_Resources::instance ()->valuetype_adapter_factory_name_ = name;
01574 }
01575
01576 const char *
01577 TAO_ORB_Core::valuetype_adapter_factory_name (void)
01578 {
01579 return TAO_ORB_Core_Static_Resources::instance ()->valuetype_adapter_factory_name_.c_str();
01580 }
01581
01582 TAO_Resource_Factory *
01583 TAO_ORB_Core::resource_factory (void)
01584 {
01585
01586 if (this->resource_factory_ != 0)
01587 {
01588 return this->resource_factory_;
01589 }
01590
01591
01592 ACE_CString &resource_factory_name =
01593 TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_;
01594
01595 this->resource_factory_ =
01596 ACE_Dynamic_Service<TAO_Resource_Factory>::instance
01597 (this->configuration (),
01598 ACE_TEXT_CHAR_TO_TCHAR (resource_factory_name.c_str()));
01599
01600 return this->resource_factory_;
01601 }
01602
01603 TAO::GUIResource_Factory *
01604 TAO_ORB_Core::gui_resource_factory (void)
01605 {
01606 return TAO_TSS_Resources::instance ()->gui_resource_factory_;
01607 }
01608
01609
01610 TAO_Thread_Lane_Resources_Manager &
01611 TAO_ORB_Core::thread_lane_resources_manager (void)
01612 {
01613
01614 if (this->thread_lane_resources_manager_ != 0)
01615 return *this->thread_lane_resources_manager_;
01616
01617
01618 const char *thread_lane_resources_manager_factory_name =
01619 this->orb_params ()->thread_lane_resources_manager_factory_name ();
01620
01621 TAO_Thread_Lane_Resources_Manager_Factory *factory =
01622 ACE_Dynamic_Service<TAO_Thread_Lane_Resources_Manager_Factory>::instance
01623 (this->configuration (),
01624 ACE_TEXT_CHAR_TO_TCHAR (thread_lane_resources_manager_factory_name));
01625
01626 this->thread_lane_resources_manager_ =
01627 factory->create_thread_lane_resources_manager (*this);
01628
01629 return *this->thread_lane_resources_manager_;
01630 }
01631
01632 TAO_Collocation_Resolver &
01633 TAO_ORB_Core::collocation_resolver (void)
01634 {
01635
01636 if (this->collocation_resolver_ != 0)
01637 return *this->collocation_resolver_;
01638
01639
01640 this->collocation_resolver_ =
01641 ACE_Dynamic_Service<TAO_Collocation_Resolver>::instance
01642 (this->configuration (),
01643 ACE_TEXT_CHAR_TO_TCHAR (this->orb_params ()->collocation_resolver_name ()));
01644
01645 return *this->collocation_resolver_;
01646 }
01647
01648 TAO::PolicyFactory_Registry_Adapter *
01649 TAO_ORB_Core::policy_factory_registry_i (void)
01650 {
01651
01652 TAO_PolicyFactory_Registry_Factory *loader =
01653 ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance
01654 (this->configuration (),
01655 ACE_TEXT ("PolicyFactory_Loader"));
01656
01657 if (loader == 0)
01658 {
01659 this->configuration ()->process_directive (
01660 ACE_DYNAMIC_SERVICE_DIRECTIVE("PolicyFactory_Loader",
01661 "TAO_PI",
01662 "_make_TAO_PolicyFactory_Loader",
01663 ""));
01664 loader =
01665 ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance
01666 (this->configuration (),
01667 ACE_TEXT ("PolicyFactory_Loader"));
01668 }
01669
01670 if (loader != 0)
01671 {
01672 this->policy_factory_registry_ =
01673 loader->create ();
01674 }
01675
01676 return this->policy_factory_registry_;
01677 }
01678
01679 TAO_ZIOP_Adapter *
01680 TAO_ORB_Core::ziop_adapter_i (void)
01681 {
01682
01683 if (this->ziop_adapter_ != 0)
01684 return this->ziop_adapter_;
01685
01686 this->ziop_adapter_ =
01687 ACE_Dynamic_Service<TAO_ZIOP_Adapter>::instance
01688 (this->configuration (),
01689 ACE_TEXT ("ZIOP_Loader"));
01690
01691 return this->ziop_adapter_;
01692 }
01693
01694 TAO::ORBInitializer_Registry_Adapter *
01695 TAO_ORB_Core::orbinitializer_registry_i (void)
01696 {
01697
01698
01699
01700 this->orbinitializer_registry_ =
01701 ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance
01702 (this->configuration (),
01703 ACE_TEXT ("ORBInitializer_Registry"));
01704
01705 #if !defined (TAO_AS_STATIC_LIBS) && !(defined (ACE_VXWORKS) && !defined (__RTP__))
01706
01707
01708
01709 if (this->orbinitializer_registry_ == 0)
01710 {
01711 this->configuration ()->process_directive (
01712 ACE_DYNAMIC_SERVICE_DIRECTIVE ("ORBInitializer_Registry",
01713 "TAO_PI",
01714 "_make_ORBInitializer_Registry",
01715 ""));
01716 this->orbinitializer_registry_ =
01717 ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance
01718 (this->configuration (),
01719 ACE_TEXT ("ORBInitializer_Registry"));
01720 }
01721 #endif
01722
01723 return this->orbinitializer_registry_;
01724 }
01725
01726 TAO_Stub_Factory *
01727 TAO_ORB_Core::stub_factory (void)
01728 {
01729
01730 if (this->stub_factory_ != 0)
01731 return this->stub_factory_;
01732
01733
01734 const char *stub_factory_name =
01735 this->orb_params ()->stub_factory_name ();
01736
01737 this->stub_factory_ =
01738 ACE_Dynamic_Service<TAO_Stub_Factory>::instance
01739 (this->configuration (),
01740 ACE_TEXT_CHAR_TO_TCHAR (stub_factory_name));
01741
01742 return this->stub_factory_;
01743 }
01744
01745 TAO_Endpoint_Selector_Factory *
01746 TAO_ORB_Core::endpoint_selector_factory (void)
01747 {
01748
01749 if (this->endpoint_selector_factory_ != 0)
01750 return this->endpoint_selector_factory_;
01751
01752
01753 const char* endpoint_selector_factory_name =
01754 this->orb_params ()->endpoint_selector_factory_name ();
01755
01756 this->endpoint_selector_factory_ =
01757 ACE_Dynamic_Service<TAO_Endpoint_Selector_Factory>::instance
01758 (this->configuration (),
01759 ACE_TEXT_CHAR_TO_TCHAR (endpoint_selector_factory_name));
01760
01761 return this->endpoint_selector_factory_;
01762 }
01763
01764 void
01765 TAO_ORB_Core::set_network_priority_protocols_hooks (
01766 const char *network_priority_protocols_hooks_name)
01767 {
01768
01769 TAO_ORB_Core_Static_Resources::instance ()->
01770 network_priority_protocols_hooks_name_ =
01771 network_priority_protocols_hooks_name;
01772 }
01773
01774 void
01775 TAO_ORB_Core::services_callbacks_init (void)
01776 {
01777
01778
01779
01780 this->ft_service_.init (this);
01781
01782
01783 }
01784
01785 TAO::Invocation_Status
01786 TAO_ORB_Core::service_raise_comm_failure (
01787 IOP::ServiceContextList &clist,
01788 TAO_Profile *profile)
01789 {
01790 if (this->ft_service_.service_callback ())
01791 {
01792 return this->ft_service_.service_callback ()->
01793 raise_comm_failure (clist, profile);
01794 }
01795
01796 throw ::CORBA::COMM_FAILURE (
01797 CORBA::SystemException::_tao_minor_code (
01798 TAO_INVOCATION_RECV_REQUEST_MINOR_CODE,
01799 errno),
01800 CORBA::COMPLETED_MAYBE);
01801 }
01802
01803
01804 TAO::Invocation_Status
01805 TAO_ORB_Core::service_raise_transient_failure (
01806 IOP::ServiceContextList &clist,
01807 TAO_Profile *profile)
01808 {
01809 if (this->ft_service_.service_callback ())
01810 {
01811 return
01812 this->ft_service_.service_callback ()->raise_transient_failure (clist,
01813 profile);
01814 }
01815
01816 return TAO::TAO_INVOKE_FAILURE;
01817 }
01818
01819 TAO_Client_Strategy_Factory *
01820 TAO_ORB_Core::client_factory (void)
01821 {
01822 if (this->client_factory_ == 0)
01823 {
01824
01825 this->client_factory_ =
01826 ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance
01827 (this->configuration (),
01828 ACE_TEXT ("Client_Strategy_Factory"));
01829 }
01830
01831 return this->client_factory_;
01832 }
01833
01834 TAO_Server_Strategy_Factory *
01835 TAO_ORB_Core::server_factory (void)
01836 {
01837 if (this->server_factory_ == 0)
01838 {
01839
01840 this->server_factory_ =
01841 ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance
01842 (this->configuration (),
01843 ACE_TEXT ("Server_Strategy_Factory"));
01844 }
01845
01846 return this->server_factory_;
01847 }
01848
01849 CORBA::Object_ptr
01850 TAO_ORB_Core::root_poa (void)
01851 {
01852
01853 if (CORBA::is_nil (this->root_poa_.in ()))
01854 {
01855
01856
01857 ACE_Service_Config_Guard scg (this->configuration ());
01858
01859 TAO_Adapter_Factory *factory =
01860 ACE_Dynamic_Service<TAO_Adapter_Factory>::instance
01861 (this->configuration (),
01862 this->orb_params ()->poa_factory_name ());
01863
01864 if (factory == 0)
01865 {
01866 this->configuration()->process_directive (
01867 this->orb_params ()->poa_factory_directive ());
01868
01869 factory =
01870 ACE_Dynamic_Service<TAO_Adapter_Factory>::instance
01871 (this->configuration (),
01872 this->orb_params ()->poa_factory_name ());
01873 }
01874
01875 if (factory == 0)
01876 {
01877 return CORBA::Object::_nil ();
01878 }
01879
01880 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
01881 monitor,
01882 this->open_lock_,
01883 0);
01884
01885 if (CORBA::is_nil (this->root_poa_.in ()))
01886 {
01887 auto_ptr<TAO_Adapter> poa_adapter (factory->create (this));
01888
01889 poa_adapter->open ();
01890
01891
01892 this->root_poa_ = poa_adapter->root ();
01893
01894 this->adapter_registry_.insert (poa_adapter.get ());
01895
01896 poa_adapter.release ();
01897 }
01898 }
01899
01900 return CORBA::Object::_duplicate (this->root_poa_.in ());
01901 }
01902
01903 TAO_Adapter *
01904 TAO_ORB_Core::poa_adapter (void)
01905 {
01906 if (this->poa_adapter_ == 0)
01907 {
01908 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
01909 if (this->poa_adapter_ == 0)
01910 {
01911 this->poa_adapter_ =
01912 this->adapter_registry_.find_adapter ("RootPOA");
01913 }
01914 }
01915 return this->poa_adapter_;
01916 }
01917
01918 TAO_Stub *
01919 TAO_ORB_Core::create_stub (const char *repository_id,
01920 const TAO_MProfile &profiles)
01921 {
01922 TAO_Stub *retval =
01923 this->stub_factory ()->create_stub (repository_id, profiles, this);
01924 return retval;
01925 }
01926
01927 void
01928 TAO_ORB_Core::request_dispatcher (TAO_Request_Dispatcher *request_dispatcher)
01929 {
01930
01931 TAO_Request_Dispatcher *tmp = this->request_dispatcher_;
01932 this->request_dispatcher_ = request_dispatcher;
01933 delete tmp;
01934 }
01935
01936 TAO_Stub *
01937 TAO_ORB_Core::create_stub_object (TAO_MProfile &mprofile,
01938 const char *type_id,
01939 CORBA::PolicyList *policy_list)
01940 {
01941
01942
01943
01944
01945
01946
01947
01948
01949 if (policy_list->length () != 0)
01950 {
01951 TAO_Profile * profile = 0;
01952
01953 CORBA::ULong const count = mprofile.profile_count ();
01954 for (CORBA::ULong i = 0; i < count; ++i)
01955 {
01956
01957 profile = mprofile.get_profile (i);
01958 profile->policies (policy_list);
01959 }
01960 }
01961
01962
01963 TAO_Stub *stub = this->create_stub (type_id, mprofile);
01964
01965 stub->base_profiles ().policy_list (policy_list);
01966
01967 return stub;
01968 }
01969
01970 void
01971 TAO_ORB_Core::load_policy_validators (TAO_Policy_Validator &validator)
01972 {
01973 if (this->bidir_adapter_ == 0)
01974 {
01975 this->bidir_adapter_ =
01976 ACE_Dynamic_Service<TAO_BiDir_Adapter>::instance
01977 (this->configuration (), ACE_TEXT ("BiDirGIOP_Loader"));
01978 }
01979
01980
01981 if (this->bidir_adapter_)
01982 {
01983 this->bidir_adapter_->load_policy_validators (validator);
01984 }
01985
01986
01987 if (this->ziop_adapter_)
01988 {
01989 this->ziop_adapter_->load_policy_validators (validator);
01990 }
01991 }
01992
01993 CORBA::Object_ptr
01994 TAO_ORB_Core::create_object (TAO_Stub *stub)
01995 {
01996
01997
01998 const TAO_MProfile &mprofile = stub->base_profiles ();
01999
02000
02001
02002 TAO_ORB_Core_Auto_Ptr collocated_orb_core;
02003 CORBA::Object_ptr x = 0;
02004
02005 {
02006
02007
02008 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
02009 guard,
02010 TAO::ORB_Table::instance()->lock (),
02011 CORBA::Object::_nil ());
02012
02013 TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
02014 TAO::ORB_Table::iterator const end = table->end ();
02015 for (TAO::ORB_Table::iterator i = table->begin (); i != end; ++i)
02016 {
02017 ::TAO_ORB_Core * const other_core = (*i).second.core ();
02018
02019 if (this->is_collocation_enabled (other_core, mprofile))
02020 {
02021 other_core->_incr_refcnt();
02022 TAO_ORB_Core_Auto_Ptr tmp_auto_ptr (other_core);
02023 collocated_orb_core = tmp_auto_ptr;
02024 break;
02025 }
02026 }
02027 }
02028
02029 if (collocated_orb_core.get ())
02030 {
02031 x = collocated_orb_core.get ()->adapter_registry ().create_collocated_object (stub, mprofile);
02032 }
02033
02034
02035 if (!x)
02036 {
02037
02038
02039 ACE_NEW_RETURN (x,
02040 CORBA::Object (stub, 0),
02041 0);
02042 }
02043
02044 return x;
02045 }
02046
02047 CORBA::Long
02048 TAO_ORB_Core::initialize_object (TAO_Stub *stub, CORBA::Object_ptr)
02049 {
02050
02051
02052 const TAO_MProfile &mprofile =
02053 stub->base_profiles ();
02054
02055 return initialize_object_i (stub, mprofile);
02056 }
02057
02058 CORBA::Long
02059 TAO_ORB_Core::reinitialize_object (TAO_Stub *stub)
02060 {
02061 return initialize_object_i (stub, stub->forward_profiles ()
02062 ? *(stub->forward_profiles ())
02063 : stub->base_profiles ());
02064 }
02065
02066 CORBA::Long
02067 TAO_ORB_Core::initialize_object_i (TAO_Stub *stub, const TAO_MProfile &mprofile)
02068
02069 {
02070 CORBA::Long retval = 0;
02071 TAO_ORB_Core_Auto_Ptr collocated_orb_core;
02072
02073 {
02074
02075
02076 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
02077 guard,
02078 TAO::ORB_Table::instance()->lock (),
02079 0));
02080
02081 TAO::ORB_Table * const table = TAO::ORB_Table::instance ();
02082 TAO::ORB_Table::iterator const end = table->end ();
02083 for (TAO::ORB_Table::iterator i = table->begin (); i != end; ++i)
02084 {
02085 TAO_ORB_Core * const other_core = (*i).second.core ();
02086
02087 if (this->is_collocation_enabled (other_core,
02088 mprofile))
02089 {
02090 other_core->_incr_refcnt ();
02091 TAO_ORB_Core_Auto_Ptr tmp_auto_ptr (other_core);
02092 collocated_orb_core = tmp_auto_ptr;
02093 break;
02094 }
02095 }
02096 }
02097
02098 if (collocated_orb_core.get ())
02099 {
02100 retval = collocated_orb_core.get ()->adapter_registry ().initialize_collocated_object (stub);
02101 }
02102 else
02103 {
02104 stub->is_collocated (false);
02105 }
02106
02107 return retval;
02108 }
02109
02110 CORBA::Boolean
02111 TAO_ORB_Core::is_collocation_enabled (TAO_ORB_Core *orb_core,
02112 const TAO_MProfile &mp)
02113 {
02114 TAO_MProfile mp_temp;
02115
02116 TAO_Profile* profile = 0;
02117 if (this->service_profile_selection(mp, profile) && profile)
02118 {
02119 mp_temp.add_profile(profile);
02120 }
02121
02122 if (!orb_core->optimize_collocation_objects ())
02123 return 0;
02124
02125 if (!orb_core->use_global_collocation () && orb_core != this)
02126 return 0;
02127
02128 if (!orb_core->is_collocated (profile ? mp_temp : mp))
02129 return 0;
02130
02131 return 1;
02132 }
02133
02134 int
02135 TAO_ORB_Core::is_collocated (const TAO_MProfile& mprofile)
02136 {
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148 return this->thread_lane_resources_manager ().is_collocated (mprofile);
02149 }
02150
02151
02152
02153 TAO_Leader_Follower &
02154 TAO_ORB_Core::leader_follower (void)
02155 {
02156 return this->lane_resources ().leader_follower ();
02157 }
02158
02159 TAO_LF_Strategy &
02160 TAO_ORB_Core::lf_strategy (void)
02161 {
02162 return this->thread_lane_resources_manager ().lf_strategy ();
02163 }
02164
02165 int
02166 TAO_ORB_Core::run (ACE_Time_Value *tv, int perform_work)
02167 {
02168
02169
02170
02171
02172 ACE_Service_Config_Guard use_orbs (this->configuration());
02173
02174 if (TAO_debug_level > 10)
02175 {
02176 ACE_DEBUG ((LM_DEBUG,
02177 ACE_TEXT ("TAO (%P|%t) - ORB_Core::run, ")
02178 ACE_TEXT ("start [%s]\n"),
02179 perform_work?ACE_TEXT("perform_work"):ACE_TEXT("run")));
02180 }
02181
02182
02183 ACE_Reactor *r = this->reactor ();
02184
02185 int result = 1;
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196 while (this->has_shutdown () == false)
02197 {
02198
02199
02200
02201 TAO_Leader_Follower &leader_follower = this->leader_follower ();
02202 TAO_LF_Strategy &lf_strategy = this->lf_strategy ();
02203
02204 TAO_LF_Event_Loop_Thread_Helper helper (leader_follower, lf_strategy, tv);
02205
02206 result = helper.event_loop_return ();
02207 if (result != 0)
02208 {
02209 if (errno == ETIME)
02210 return 0;
02211 else
02212 return result;
02213 }
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223 r->owner (ACE_Thread::self ());
02224
02225 if (TAO_debug_level > 10)
02226 {
02227 ACE_DEBUG ((LM_DEBUG,
02228 ACE_TEXT ("TAO (%P|%t) - ORB_Core::run, ")
02229 ACE_TEXT ( "calling handle_events()\n")));
02230 }
02231
02232 result = r->handle_events (tv);
02233
02234 if (TAO_debug_level > 10)
02235 {
02236 ACE_DEBUG ((LM_DEBUG,
02237 ACE_TEXT ("TAO (%P|%t) - ORB_Core::run, ")
02238 ACE_TEXT ("handle_events() returns %d\n"),
02239 result));
02240 }
02241
02242 if (result == -1)
02243 {
02244
02245 break;
02246 }
02247 if (result == 0
02248 && tv != 0
02249 && *tv == ACE_Time_Value::zero)
02250 {
02251
02252 break;
02253 }
02254
02255 if (perform_work)
02256 {
02257
02258
02259 break;
02260 }
02261
02262 }
02263
02264
02265 if (this->has_shutdown () == true &&
02266 (this->server_factory_->activate_server_connections () ||
02267 (this->tm_.task() == 0 && this->tm_.count_threads() > 0) ) ) {
02268 this->tm_.wait ();
02269 }
02270
02271 if (TAO_debug_level > 10)
02272 {
02273 ACE_DEBUG ((LM_DEBUG,
02274 ACE_TEXT ("TAO (%P|%t) - ORB_Core::run, ")
02275 ACE_TEXT ("ends with result = %d\n"),
02276 result));
02277 }
02278
02279 return result;
02280 }
02281
02282
02283 void
02284 TAO_ORB_Core::shutdown (CORBA::Boolean wait_for_completion)
02285 {
02286 {
02287 ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
02288
02289 if (this->has_shutdown () == true)
02290 return;
02291
02292
02293
02294
02295 this->adapter_registry_.check_close (wait_for_completion);
02296
02297
02298
02299 this->has_shutdown_ = true;
02300
02301
02302
02303
02304 }
02305
02306 this->adapter_registry_.close (wait_for_completion);
02307
02308
02309 this->thread_lane_resources_manager ().shutdown_reactor ();
02310
02311
02312 this->thread_lane_resources_manager ().close_all_transports ();
02313
02314
02315 ACE_Thread_Manager *tm = this->thr_mgr ();
02316
02317
02318 tm->cancel_all ();
02319
02320
02321 if (wait_for_completion == true)
02322 tm->wait ();
02323
02324
02325 {
02326 ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
02327
02328 delete this->valuetype_adapter_;
02329 this->valuetype_adapter_ = 0;
02330 }
02331
02332
02333
02334
02335 this->object_ref_table_.destroy ();
02336
02337
02338
02339
02340 ::CORBA::release (this->implrepo_service_);
02341 this->implrepo_service_ = CORBA::Object::_nil ();
02342
02343 #if (TAO_HAS_INTERCEPTORS == 1)
02344 CORBA::release (this->pi_current_);
02345 this->pi_current_ = CORBA::Object::_nil ();
02346 #endif
02347 }
02348
02349 void
02350 TAO_ORB_Core::destroy (void)
02351 {
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366 this->shutdown (1);
02367
02368
02369 this->destroy_interceptors ();
02370
02371
02372
02373
02374
02375
02376
02377
02378 this->get_tss_resources ()->fini ();
02379
02380
02381
02382 TAO::ORB_Table::instance ()->unbind (this->orbid_);
02383 }
02384
02385 void
02386 TAO_ORB_Core::check_shutdown (void)
02387 {
02388 if (this->has_shutdown ())
02389 {
02390
02391
02392
02393
02394 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 4, CORBA::COMPLETED_NO);
02395 }
02396 }
02397
02398 void
02399 TAO_ORB_Core::destroy_interceptors (void)
02400 {
02401 try
02402 {
02403 ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
02404
02405 #if TAO_HAS_INTERCEPTORS == 1
02406 if (this->client_request_interceptor_adapter_ != 0)
02407 {
02408 this->client_request_interceptor_adapter_->destroy_interceptors ();
02409
02410 delete this->client_request_interceptor_adapter_;
02411 this->client_request_interceptor_adapter_ = 0;
02412 }
02413
02414 if (this->server_request_interceptor_adapter_ != 0)
02415 {
02416 this->server_request_interceptor_adapter_->destroy_interceptors ();
02417
02418 delete this->server_request_interceptor_adapter_;
02419 this->server_request_interceptor_adapter_ = 0;
02420 }
02421
02422 #endif
02423
02424 if (this->ior_interceptor_adapter_ != 0)
02425 {
02426 this->ior_interceptor_adapter_->destroy_interceptors ();
02427
02428 this->ior_interceptor_adapter_ = 0;
02429 }
02430
02431 }
02432 catch (...)
02433 {
02434
02435 if (TAO_debug_level > 3)
02436 {
02437 ACE_DEBUG ((LM_DEBUG,
02438 ACE_TEXT ("TAO (%P|%t) - Exception in TAO_ORB_Core")
02439 ACE_TEXT ("::destroy_interceptors ()\n")));
02440 }
02441 }
02442
02443 return;
02444 }
02445
02446 TAO_Thread_Lane_Resources &
02447 TAO_ORB_Core::lane_resources (void)
02448 {
02449 return this->thread_lane_resources_manager ().lane_resources ();
02450 }
02451
02452 void
02453 TAO_ORB_Core::resolve_typecodefactory_i (void)
02454 {
02455 TAO_Object_Loader *loader =
02456 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02457 (this->configuration (),
02458 ACE_TEXT ("TypeCodeFactory_Loader"));
02459
02460 if (loader == 0)
02461 {
02462 this->configuration ()->process_directive
02463 (ACE_DYNAMIC_SERVICE_DIRECTIVE("TypeCodeFactory",
02464 "TAO_TypeCodeFactory",
02465 "_make_TAO_TypeCodeFactory_Loader",
02466 ""));
02467 loader =
02468 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02469 (this->configuration (),
02470 ACE_TEXT ("TypeCodeFactory_Loader"));
02471
02472 if (loader == 0)
02473 {
02474 ACE_ERROR ((LM_ERROR,
02475 ACE_TEXT ("TAO (%P|%t) Unable to instantiate ")
02476 ACE_TEXT ("a TypeCodeFactory_Loader\n")));
02477 throw ::CORBA::ORB::InvalidName ();
02478 }
02479 }
02480
02481 this->typecode_factory_ =
02482 loader->create_object (this->orb_, 0, 0);
02483 }
02484
02485 void
02486 TAO_ORB_Core::resolve_codecfactory_i (void)
02487 {
02488 TAO_Object_Loader *loader =
02489 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02490 (this->configuration (),
02491 ACE_TEXT ("CodecFactory_Loader"));
02492
02493 if (loader == 0)
02494 {
02495 this->configuration()->process_directive
02496 (ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory",
02497 "TAO_CodecFactory",
02498 "_make_TAO_CodecFactory_Loader",
02499 ""));
02500 loader =
02501 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02502 (this->configuration (), ACE_TEXT ("CodecFactory_Loader"));
02503 }
02504
02505 if (loader != 0)
02506 {
02507 this->codec_factory_ =
02508 loader->create_object (this->orb_, 0, 0);
02509 }
02510 }
02511
02512 void
02513 TAO_ORB_Core::resolve_compression_manager_i (void)
02514 {
02515 TAO_Object_Loader *loader =
02516 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02517 (this->configuration (),
02518 ACE_TEXT ("Compression_Loader"));
02519
02520 if (loader == 0)
02521 {
02522 this->configuration()->process_directive
02523 (ACE_DYNAMIC_SERVICE_DIRECTIVE("Compression",
02524 "TAO_Compression",
02525 "_make_TAO_Compression_Loader",
02526 ""));
02527 loader =
02528 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02529 (this->configuration (), ACE_TEXT ("Compression_Loader"));
02530 }
02531
02532 if (loader != 0)
02533 {
02534 this->compression_manager_ = loader->create_object (this->orb_, 0, 0);
02535 }
02536 }
02537
02538 void
02539 TAO_ORB_Core::resolve_poa_current_i (void)
02540 {
02541 TAO_Object_Loader *loader =
02542 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02543 (this->configuration(),
02544 ACE_TEXT ("TAO_POA_Current_Factory"));
02545
02546 if (loader == 0)
02547 {
02548 this->configuration()->process_directive
02549 (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_POA_Current_Factory",
02550 "TAO_PortableServer",
02551 "_make_TAO_POA_Current_Factory",
02552 ""));
02553 loader =
02554 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02555 (this->configuration(), ACE_TEXT ("TAO_POA_Current_Factory"));
02556 }
02557
02558 if (loader != 0)
02559 {
02560 this->poa_current_ = loader->create_object (this->orb_, 0, 0);
02561 }
02562 }
02563
02564
02565 #if TAO_HAS_INTERCEPTORS == 1
02566
02567 void
02568 TAO_ORB_Core::resolve_picurrent_i (void)
02569 {
02570 TAO_Object_Loader *loader =
02571 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02572 (this->configuration (),
02573 ACE_TEXT ("PICurrent_Loader"));
02574
02575 if (loader == 0)
02576 {
02577 this->configuration ()->process_directive
02578 (ACE_DYNAMIC_SERVICE_DIRECTIVE("PICurrent_Loader",
02579 "TAO_PI",
02580 "_make_TAO_PICurrent_Loader",
02581 ""));
02582 loader =
02583 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02584 (this->configuration (), ACE_TEXT ("PICurrent_Loader"));
02585 }
02586
02587 if (loader != 0)
02588 {
02589 CORBA::Object_ptr pi = loader->create_object (this->orb_, 0, 0);
02590
02591 this->pi_current_ = pi;
02592 }
02593 }
02594
02595 #endif
02596
02597
02598 void
02599 TAO_ORB_Core::resolve_dynanyfactory_i (void)
02600 {
02601 TAO_Object_Loader *loader =
02602 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02603 (this->configuration (),
02604 ACE_TEXT ("DynamicAny_Loader"));
02605
02606 if (loader == 0)
02607 {
02608 this->configuration ()->process_directive
02609 (ACE_DYNAMIC_SERVICE_DIRECTIVE("DynamicAny_Loader",
02610 "TAO_DynamicAny",
02611 "_make_TAO_DynamicAny_Loader",
02612 ""));
02613 loader =
02614 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02615 (this->configuration (),
02616 ACE_TEXT ("DynamicAny_Loader"));
02617 }
02618
02619 if (loader != 0)
02620 {
02621 this->dynany_factory_ = loader->create_object (this->orb_, 0, 0);
02622 }
02623 }
02624
02625 void
02626 TAO_ORB_Core::resolve_iormanipulation_i (void)
02627 {
02628 TAO_Object_Loader *loader =
02629 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02630 (this->configuration (),
02631 ACE_TEXT ("IORManip_Loader"));
02632
02633 if (loader == 0)
02634 {
02635 this->configuration()->process_directive
02636 (ACE_DYNAMIC_SERVICE_DIRECTIVE("IORManip_Loader",
02637 "TAO_IORManip",
02638 "_make_TAO_IORManip_Loader",
02639 ""));
02640 loader =
02641 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02642 (this->configuration (), ACE_TEXT ("IORManip_Loader"));
02643 }
02644
02645 if (loader != 0)
02646 {
02647 this->ior_manip_factory_ = loader->create_object (this->orb_, 0, 0);
02648 }
02649 }
02650
02651 void
02652 TAO_ORB_Core::resolve_ior_table_i (void)
02653 {
02654 TAO_Adapter_Factory *factory =
02655 ACE_Dynamic_Service<TAO_Adapter_Factory>::instance
02656 (this->configuration (),
02657 ACE_TEXT ("TAO_IORTable"));
02658
02659 if (factory == 0)
02660 {
02661 this->configuration ()->process_directive
02662 (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_IORTable",
02663 "TAO_IORTable",
02664 "_make_TAO_Table_Adapter_Factory",
02665 ""));
02666 factory =
02667 ACE_Dynamic_Service<TAO_Adapter_Factory>::instance
02668 (this->configuration (), ACE_TEXT ("TAO_IORTable"));
02669 }
02670
02671 if (factory != 0)
02672 {
02673 ACE_Auto_Ptr <TAO_Adapter> iortable_adapter (factory->create (this));
02674 iortable_adapter->open ();
02675
02676 CORBA::Object_var tmp_root = iortable_adapter->root ();
02677
02678 this->adapter_registry_.insert (iortable_adapter.get ());
02679
02680
02681 this->ior_table_= tmp_root._retn ();
02682 iortable_adapter.release ();
02683 }
02684 }
02685
02686 void
02687 TAO_ORB_Core::resolve_monitor_i (void)
02688 {
02689 TAO_Object_Loader *loader =
02690 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02691 (this->configuration (),
02692 ACE_TEXT ("Monitor_Init"));
02693
02694 if (loader == 0)
02695 {
02696 this->configuration ()->process_directive
02697 (ACE_DYNAMIC_SERVICE_DIRECTIVE("Monitor_Init",
02698 "TAO_Monitor",
02699 "_make_TAO_Monitor_Init",
02700 ""));
02701 loader =
02702 ACE_Dynamic_Service<TAO_Object_Loader>::instance
02703 (this->configuration (),
02704 ACE_TEXT ("Monitor_Init"));
02705 }
02706
02707 if (loader != 0)
02708 {
02709 this->monitor_ = loader->create_object (this->orb_, 0, 0);
02710 }
02711 }
02712
02713 int
02714 TAO_ORB_Core::set_endpoint_helper (const ACE_CString &lane,
02715 const ACE_CString &endpoints)
02716 {
02717 if (this->orb_params ()->add_endpoints (lane, endpoints) != 0)
02718 {
02719 ACE_ERROR ((LM_ERROR,
02720 ACE_TEXT ("(%P|%t) ")
02721 ACE_TEXT ("Invalid endpoint(s) specified: <%C>.\n"),
02722 endpoints.c_str ()));
02723 throw ::CORBA::BAD_PARAM (
02724 CORBA::SystemException::_tao_minor_code (
02725 TAO_ORB_CORE_INIT_LOCATION_CODE,
02726 EINVAL),
02727 CORBA::COMPLETED_NO);
02728 }
02729
02730 return 0;
02731 }
02732
02733 CORBA::Object_ptr
02734 TAO_ORB_Core::resolve_rir (const char *name)
02735 {
02736
02737
02738 ACE_CString ior;
02739 ACE_CString object_id ((const char *) name);
02740
02741
02742
02743 CORBA::String_var default_init_ref =
02744 this->orb_params ()->default_init_ref ();
02745
02746
02747 if (ACE_OS::strlen (default_init_ref.in ()) != 0)
02748 {
02749 static const char corbaloc_prefix[] = "corbaloc:";
02750 static const char mcast_prefix[] = "mcast:";
02751 char object_key_delimiter = 0;
02752
02753 ACE_CString list_of_profiles (default_init_ref.in ());
02754
02755
02756
02757 if ((ACE_OS::strncmp (default_init_ref.in (),
02758 corbaloc_prefix,
02759 sizeof corbaloc_prefix -1) == 0) ||
02760 (ACE_OS::strncmp (default_init_ref.in (),
02761 mcast_prefix,
02762 sizeof mcast_prefix -1) == 0))
02763 {
02764 object_key_delimiter = '/';
02765 }
02766 else
02767 {
02768 TAO_Connector_Registry *conn_reg = this->connector_registry ();
02769
02770
02771
02772 object_key_delimiter =
02773 conn_reg->object_key_delimiter (list_of_profiles.c_str ());
02774 }
02775
02776
02777
02778 if (list_of_profiles[list_of_profiles.length() - 1] !=
02779 object_key_delimiter)
02780 list_of_profiles += ACE_CString (object_key_delimiter);
02781
02782 list_of_profiles += object_id;
02783
02784 return this->orb ()->string_to_object (list_of_profiles.c_str ());
02785 }
02786
02787 return CORBA::Object::_nil ();
02788 }
02789
02790 CORBA::ORB::ObjectIdList *
02791 TAO_ORB_Core::list_initial_references (void)
02792 {
02793
02794 static const char *initial_services[] = { TAO_LIST_OF_INITIAL_SERVICES };
02795
02796
02797
02798 static const size_t initial_services_size =
02799 sizeof (initial_services) / sizeof (initial_services[0]);
02800
02801 const size_t total_size =
02802 initial_services_size
02803 + this->init_ref_map_.size ()
02804 + this->object_ref_table_.current_size ();
02805
02806 CORBA::ORB::ObjectIdList *tmp = 0;
02807
02808 ACE_NEW_THROW_EX (tmp,
02809 CORBA::ORB::ObjectIdList (
02810 static_cast<CORBA::ULong> (total_size)),
02811 CORBA::NO_MEMORY ());
02812
02813 CORBA::ORB::ObjectIdList_var list (tmp);
02814 list->length (static_cast<CORBA::ULong> (total_size));
02815
02816 CORBA::ULong index = 0;
02817
02818
02819
02820 for (index = 0; index < initial_services_size; ++index)
02821 list[index] = initial_services[index];
02822
02823
02824
02825
02826
02827
02828 TAO_Object_Ref_Table::iterator const obj_ref_end =
02829 this->object_ref_table_.end ();
02830
02831 for (TAO_Object_Ref_Table::iterator i = this->object_ref_table_.begin ();
02832 i != obj_ref_end;
02833 ++i, ++index)
02834 list[index] = CORBA::string_dup ((*i).first.in ());
02835
02836
02837 InitRefMap::iterator const end = this->init_ref_map_.end ();
02838
02839 for (InitRefMap::iterator j = this-> init_ref_map_.begin ();
02840 j != end;
02841 ++j, ++index)
02842 list[index] = (*j).first.c_str ();
02843
02844 return list._retn ();
02845 }
02846
02847
02848 ACE_Allocator*
02849 TAO_ORB_Core::input_cdr_dblock_allocator (void)
02850 {
02851 return this->lane_resources ().input_cdr_dblock_allocator ();
02852 }
02853
02854 ACE_Allocator*
02855 TAO_ORB_Core::input_cdr_buffer_allocator (void)
02856 {
02857 return this->lane_resources ().input_cdr_buffer_allocator ();
02858 }
02859
02860 ACE_Allocator*
02861 TAO_ORB_Core::input_cdr_msgblock_allocator (void)
02862 {
02863 return this->lane_resources ().input_cdr_msgblock_allocator ();
02864 }
02865
02866 ACE_Allocator*
02867 TAO_ORB_Core::output_cdr_dblock_allocator (void)
02868 {
02869
02870 return this->lane_resources ().output_cdr_dblock_allocator ();
02871 }
02872
02873 ACE_Allocator*
02874 TAO_ORB_Core::output_cdr_buffer_allocator (void)
02875 {
02876 return this->lane_resources ().output_cdr_buffer_allocator ();
02877 }
02878
02879
02880 ACE_Allocator*
02881 TAO_ORB_Core::output_cdr_msgblock_allocator (void)
02882 {
02883 return this->lane_resources ().output_cdr_msgblock_allocator ();
02884 }
02885
02886
02887 ACE_Allocator *
02888 TAO_ORB_Core::transport_message_buffer_allocator (void)
02889 {
02890 return this->lane_resources ().transport_message_buffer_allocator ();
02891 }
02892
02893
02894 ACE_Data_Block*
02895 TAO_ORB_Core::create_input_cdr_data_block (size_t size)
02896 {
02897
02898 ACE_Allocator *dblock_allocator = 0;
02899 ACE_Allocator *buffer_allocator = 0;
02900
02901 dblock_allocator =
02902 this->input_cdr_dblock_allocator ();
02903 buffer_allocator =
02904 this->input_cdr_buffer_allocator ();
02905
02906 ACE_Lock* lock_strategy = 0;
02907 if (this->resource_factory ()->use_locked_data_blocks ())
02908 {
02909 lock_strategy = &this->data_block_lock_;
02910 }
02911
02912 return this->create_data_block_i (size,
02913 buffer_allocator,
02914 dblock_allocator,
02915 lock_strategy);
02916 }
02917
02918 ACE_Data_Block *
02919 TAO_ORB_Core::create_data_block_i (size_t size,
02920 ACE_Allocator *buffer_allocator,
02921 ACE_Allocator *dblock_allocator,
02922 ACE_Lock *lock_strategy)
02923 {
02924 ACE_Data_Block *nb = 0;
02925
02926 ACE_NEW_MALLOC_RETURN (
02927 nb,
02928 static_cast<ACE_Data_Block*> (
02929 dblock_allocator->malloc (sizeof (ACE_Data_Block))),
02930 ACE_Data_Block (size,
02931 ACE_Message_Block::MB_DATA,
02932 0,
02933 buffer_allocator,
02934 lock_strategy,
02935 0,
02936 dblock_allocator),
02937 0);
02938
02939 return nb;
02940 }
02941
02942 TAO_Connector_Registry *
02943 TAO_ORB_Core::connector_registry (void)
02944 {
02945 TAO_Connector_Registry *conn =
02946 this->lane_resources ().connector_registry ();
02947
02948 return conn;
02949 }
02950
02951 auto_ptr<TAO_GIOP_Fragmentation_Strategy>
02952 TAO_ORB_Core::fragmentation_strategy (TAO_Transport * transport)
02953 {
02954 return
02955 this->resource_factory ()->create_fragmentation_strategy (
02956 transport,
02957 this->orb_params_.max_message_size ());
02958 }
02959
02960 ACE_Reactor *
02961 TAO_ORB_Core::reactor (void)
02962 {
02963 return this->leader_follower ().reactor ();
02964 }
02965
02966 CORBA::Object_ptr
02967 TAO_ORB_Core::implrepo_service (void)
02968 {
02969 if (!this->use_implrepo_)
02970 return CORBA::Object::_nil ();
02971
02972 if (CORBA::is_nil (this->implrepo_service_))
02973 {
02974
02975 try
02976 {
02977 CORBA::Object_var temp =
02978 this->orb_->resolve_initial_references ("ImplRepoService");
02979
02980 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::Object::_nil ());
02981
02982
02983 this->implrepo_service_ = temp._retn ();
02984 }
02985 catch (const ::CORBA::Exception&)
02986 {
02987
02988
02989 this->implrepo_service_ = CORBA::Object::_nil ();
02990 }
02991 }
02992
02993 return CORBA::Object::_duplicate (this->implrepo_service_);
02994 }
02995
02996 void
02997 TAO_ORB_Core::default_sync_scope_hook (TAO_ORB_Core *,
02998 TAO_Stub *,
02999 bool &has_synchronization,
03000 Messaging::SyncScope &scope)
03001 {
03002 has_synchronization = true;
03003 scope = Messaging::SYNC_WITH_TRANSPORT;
03004 }
03005
03006 void
03007 TAO_ORB_Core::call_sync_scope_hook (TAO_Stub *stub,
03008 bool &has_synchronization,
03009 Messaging::SyncScope &scope)
03010 {
03011 Sync_Scope_Hook sync_scope_hook = this->sync_scope_hook_;
03012
03013 if (sync_scope_hook == 0)
03014 {
03015 has_synchronization = false;
03016 return;
03017 }
03018
03019 (*sync_scope_hook) (this, stub, has_synchronization, scope);
03020 }
03021
03022 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
03023
03024 TAO::Transport_Queueing_Strategy *
03025 TAO_ORB_Core::get_transport_queueing_strategy (TAO_Stub *,
03026 Messaging::SyncScope &scope)
03027 {
03028 switch (scope)
03029 {
03030 case Messaging::SYNC_WITH_TRANSPORT:
03031 case Messaging::SYNC_WITH_SERVER:
03032 case Messaging::SYNC_WITH_TARGET:
03033 {
03034 return this->flush_transport_queueing_strategy_;
03035 }
03036 break;
03037 case Messaging::SYNC_NONE:
03038 {
03039 return this->eager_transport_queueing_strategy_;
03040 }
03041 break;
03042 case TAO::SYNC_DELAYED_BUFFERING:
03043 {
03044 return this->delayed_transport_queueing_strategy_;
03045 }
03046 break;
03047 default:
03048 {
03049 return 0;
03050 }
03051 }
03052 }
03053
03054 #endif
03055
03056 int
03057 TAO_ORB_Core::add_tss_cleanup_func (ACE_CLEANUP_FUNC cleanup, size_t &slot_id)
03058 {
03059 return this->tss_cleanup_funcs_.register_cleanup_function (cleanup, slot_id);
03060 }
03061
03062 void
03063 TAO_ORB_Core::call_timeout_hook (TAO_Stub *stub,
03064 bool &has_timeout,
03065 ACE_Time_Value &time_value)
03066 {
03067 Timeout_Hook timeout_hook = this->timeout_hook_;
03068
03069 if (timeout_hook == 0)
03070 {
03071 has_timeout = false;
03072 return;
03073 }
03074 (*timeout_hook) (this, stub, has_timeout, time_value);
03075 }
03076
03077 void
03078 TAO_ORB_Core::connection_timeout (TAO_Stub *stub,
03079 bool &has_timeout,
03080 ACE_Time_Value &time_value)
03081 {
03082 Timeout_Hook connection_timeout_hook =
03083 TAO_ORB_Core_Static_Resources::instance ()->connection_timeout_hook_;
03084
03085 if (connection_timeout_hook == 0)
03086 {
03087 has_timeout = false;
03088 return;
03089 }
03090
03091 (*connection_timeout_hook) (this, stub, has_timeout, time_value);
03092
03093 Timeout_Hook alt_connection_timeout_hook =
03094 TAO_ORB_Core_Static_Resources::instance ()->alt_connection_timeout_hook_;
03095
03096 if (alt_connection_timeout_hook == 0)
03097 return;
03098
03099 if (!has_timeout || time_value == ACE_Time_Value::zero )
03100 {
03101 (*alt_connection_timeout_hook) (this, stub, has_timeout,time_value);
03102 return;
03103 }
03104
03105
03106
03107 ACE_Time_Value tv1;
03108 bool ht1;
03109 (*alt_connection_timeout_hook) (this, stub, ht1,tv1);
03110 if (ht1 && tv1 > ACE_Time_Value::zero && tv1 < time_value)
03111 time_value = tv1;
03112 }
03113
03114 void
03115 TAO_ORB_Core::connection_timeout_hook (Timeout_Hook hook)
03116 {
03117
03118
03119
03120
03121
03122 #define TOCSRi TAO_ORB_Core_Static_Resources::instance ()
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140 if (TOCSRi->connection_timeout_hook_ == 0)
03141 {
03142 if (TAO_debug_level > 2)
03143 {
03144 ACE_DEBUG ((LM_DEBUG,
03145 ACE_TEXT("TAO (%P|%t) - Setting primary connection ")
03146 ACE_TEXT("timeout hook\n")));
03147 }
03148 TOCSRi->connection_timeout_hook_ = hook;
03149 }
03150 else if (TOCSRi->connection_timeout_hook_ != hook &&
03151 TOCSRi->alt_connection_timeout_hook_ == 0)
03152 {
03153 if (TAO_debug_level > 2)
03154 {
03155 ACE_DEBUG ((LM_DEBUG,
03156 ACE_TEXT("TAO (%P|%t) - Setting alternate connection ")
03157 ACE_TEXT("timeout hook\n")));
03158 }
03159 TOCSRi->alt_connection_timeout_hook_ = hook;
03160 }
03161 else
03162 if (TAO_debug_level > 2)
03163 {
03164 ACE_DEBUG ((LM_DEBUG,
03165 ACE_TEXT ("TAO (%P|%t) - Not overwriting alternate ")
03166 ACE_TEXT ("connection timeout hook. It is %@\n"),
03167 TOCSRi->alt_connection_timeout_hook_));
03168 }
03169
03170 #undef TOCSRi
03171 }
03172
03173 #if (TAO_HAS_CORBA_MESSAGING == 1)
03174
03175 CORBA::Policy_ptr
03176 TAO_ORB_Core::get_policy (CORBA::PolicyType type)
03177 {
03178 CORBA::Policy_var result;
03179
03180 TAO_Policy_Manager *policy_manager = this->policy_manager ();
03181 if (policy_manager != 0)
03182 {
03183 result = policy_manager->get_policy (type);
03184 }
03185
03186 if (CORBA::is_nil (result.in ()))
03187 {
03188 result = this->get_default_policies ()->get_policy (type);
03189 }
03190
03191 return result._retn ();
03192 }
03193
03194 CORBA::Policy_ptr
03195 TAO_ORB_Core::get_policy_including_current (CORBA::PolicyType type)
03196 {
03197 TAO_Policy_Current &policy_current = this->policy_current ();
03198
03199 CORBA::Policy_var result = policy_current.get_policy (type);
03200
03201 if (CORBA::is_nil (result.in ()))
03202 {
03203 result = this->get_policy (type);
03204 }
03205
03206 return result._retn ();
03207 }
03208
03209 CORBA::Policy_ptr
03210 TAO_ORB_Core::get_cached_policy (TAO_Cached_Policy_Type type)
03211 {
03212 CORBA::Policy_var result;
03213
03214 TAO_Policy_Manager *policy_manager = this->policy_manager ();
03215 if (policy_manager != 0)
03216 {
03217 result = policy_manager->get_cached_policy (type);
03218 }
03219
03220 if (CORBA::is_nil (result.in ()))
03221 {
03222 result = this->get_default_policies ()->get_cached_policy (type);
03223 }
03224
03225 return result._retn ();
03226 }
03227
03228 CORBA::Policy_ptr
03229 TAO_ORB_Core::get_cached_policy_including_current (TAO_Cached_Policy_Type type)
03230 {
03231 TAO_Policy_Current &policy_current = this->policy_current ();
03232
03233 CORBA::Policy_var result = policy_current.get_cached_policy (type);
03234
03235 if (CORBA::is_nil (result.in ()))
03236 {
03237 result = this->get_cached_policy (type);
03238 }
03239
03240 return result._retn ();
03241 }
03242
03243 #endif
03244
03245 CORBA::Environment *
03246 TAO_ORB_Core::default_environment (void) const
03247 {
03248 return TAO_TSS_Resources::instance ()->default_environment_;
03249 }
03250
03251 void
03252 TAO_ORB_Core::default_environment (CORBA::Environment *env)
03253 {
03254 TAO_TSS_Resources::instance ()->default_environment_ = env;
03255 }
03256
03257 void
03258 TAO_ORB_Core::add_interceptor (
03259 PortableInterceptor::IORInterceptor_ptr interceptor)
03260 {
03261 if (this->ior_interceptor_adapter ())
03262 {
03263 this->ior_interceptor_adapter_->add_interceptor (interceptor);
03264 }
03265 else
03266 {
03267 ACE_ERROR ((LM_ERROR,
03268 ACE_TEXT ("TAO (%P|%t) - %p\n"),
03269 ACE_TEXT ("ERROR: ORB Core unable to find the ")
03270 ACE_TEXT ("IORInterceptor Adapter Factory instance")));
03271
03272 throw ::CORBA::INTERNAL ();
03273 }
03274 }
03275
03276 TAO_IORInterceptor_Adapter *
03277 TAO_ORB_Core::ior_interceptor_adapter (void)
03278 {
03279 if (this->ior_interceptor_adapter_ == 0)
03280 {
03281 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
03282 ace_mon,
03283 this->lock_,
03284 0);
03285
03286 if (this->ior_interceptor_adapter_ == 0)
03287 {
03288 try
03289 {
03290 TAO_IORInterceptor_Adapter_Factory * ior_ap_factory =
03291 ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance
03292 (this->configuration (),
03293 ACE_TEXT_CHAR_TO_TCHAR (TAO_ORB_Core::iorinterceptor_adapter_factory_name ()));
03294
03295 if (ior_ap_factory)
03296 {
03297 this->ior_interceptor_adapter_ = ior_ap_factory->create ();
03298 }
03299 }
03300 catch (const ::CORBA::Exception& ex)
03301 {
03302 ex._tao_print_exception (
03303 "Cannot initialize the ior_interceptor_adapter\n");
03304 }
03305 }
03306 }
03307
03308 return this->ior_interceptor_adapter_;
03309 }
03310
03311 #if TAO_HAS_INTERCEPTORS == 1
03312
03313 void
03314 TAO_ORB_Core::add_interceptor (
03315 PortableInterceptor::ClientRequestInterceptor_ptr interceptor
03316 )
03317 {
03318 if (this->clientrequestinterceptor_adapter_i ())
03319 {
03320 this->client_request_interceptor_adapter_->add_interceptor (interceptor);
03321 }
03322 else
03323 {
03324 ACE_ERROR ((LM_ERROR,
03325 ACE_TEXT ("TAO (%P|%t) - %p\n"),
03326 ACE_TEXT ("ERROR: ORB Core unable to find the ")
03327 ACE_TEXT ("Client Request Interceptor Adapter Factory ")
03328 ACE_TEXT ("instance")));
03329
03330 throw ::CORBA::INTERNAL ();
03331 }
03332 }
03333
03334 TAO::ClientRequestInterceptor_Adapter *
03335 TAO_ORB_Core::clientrequestinterceptor_adapter_i (void)
03336 {
03337 if (this->client_request_interceptor_adapter_ == 0)
03338 {
03339 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
03340 ace_mon,
03341 this->lock_,
03342 0);
03343
03344 if (this->client_request_interceptor_adapter_ == 0)
03345 {
03346 TAO_ClientRequestInterceptor_Adapter_Factory *factory =
03347 ACE_Dynamic_Service<TAO_ClientRequestInterceptor_Adapter_Factory>::instance
03348 (this->configuration (),
03349 ACE_TEXT ("ClientRequestInterceptor_Adapter_Factory"));
03350
03351 if (factory)
03352 {
03353 this->client_request_interceptor_adapter_ =
03354 factory->create ();
03355 }
03356 }
03357 }
03358
03359 return this->client_request_interceptor_adapter_;
03360 }
03361
03362 void
03363 TAO_ORB_Core::add_interceptor (
03364 PortableInterceptor::ServerRequestInterceptor_ptr interceptor
03365 )
03366 {
03367 if (this->serverrequestinterceptor_adapter_i ())
03368 {
03369 this->server_request_interceptor_adapter_->add_interceptor (interceptor);
03370 }
03371 else
03372 {
03373 ACE_ERROR ((LM_ERROR,
03374 ACE_TEXT ("TAO (%P|%t) - %p\n"),
03375 ACE_TEXT ("ERROR: ORB Core unable to find the ")
03376 ACE_TEXT ("Server Request Interceptor Adapter Factory ")
03377 ACE_TEXT ("instance")));
03378
03379 throw ::CORBA::INTERNAL ();
03380 }
03381 }
03382
03383 void
03384 TAO_ORB_Core::add_interceptor (
03385 PortableInterceptor::ClientRequestInterceptor_ptr interceptor,
03386 const CORBA::PolicyList& policies)
03387 {
03388 if (this->clientrequestinterceptor_adapter_i ())
03389 {
03390 this->client_request_interceptor_adapter_->add_interceptor (
03391 interceptor,
03392 policies);
03393
03394 }
03395 else
03396 {
03397 ACE_ERROR ((LM_ERROR,
03398 ACE_TEXT ("TAO (%P|%t) - %p\n"),
03399 ACE_TEXT ("ERROR: ORB Core unable to find the ")
03400 ACE_TEXT ("Client Request Interceptor Adapter Factory ")
03401 ACE_TEXT ("instance")));
03402
03403 throw ::CORBA::INTERNAL ();
03404 }
03405 }
03406
03407 void
03408 TAO_ORB_Core::add_interceptor (
03409 PortableInterceptor::ServerRequestInterceptor_ptr interceptor,
03410 const CORBA::PolicyList& policies)
03411 {
03412 if (this->serverrequestinterceptor_adapter_i ())
03413 {
03414 this->server_request_interceptor_adapter_->add_interceptor (
03415 interceptor,
03416 policies);
03417
03418 }
03419 else
03420 {
03421 ACE_ERROR ((LM_ERROR,
03422 ACE_TEXT ("TAO (%P|%t) - %p\n"),
03423 ACE_TEXT ("ERROR: ORB Core unable to find the ")
03424 ACE_TEXT ("Server Request Interceptor Adapter Factory ")
03425 ACE_TEXT ("instance")));
03426
03427 throw ::CORBA::INTERNAL ();
03428 }
03429 }
03430
03431 TAO::ServerRequestInterceptor_Adapter *
03432 TAO_ORB_Core::serverrequestinterceptor_adapter_i (void)
03433 {
03434 if (this->server_request_interceptor_adapter_ == 0)
03435 {
03436 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
03437 ace_mon,
03438 this->lock_,
03439 0);
03440
03441 if (this->server_request_interceptor_adapter_ == 0)
03442 {
03443 TAO_ServerRequestInterceptor_Adapter_Factory *factory =
03444 ACE_Dynamic_Service<TAO_ServerRequestInterceptor_Adapter_Factory>::instance
03445 (this->configuration (),
03446 ACE_TEXT ("ServerRequestInterceptor_Adapter_Factory"));
03447
03448 if (factory)
03449 {
03450 this->server_request_interceptor_adapter_ =
03451 factory->create ();
03452 }
03453 }
03454 }
03455
03456 return this->server_request_interceptor_adapter_;
03457 }
03458
03459 #endif
03460
03461 TAO_Valuetype_Adapter *
03462 TAO_ORB_Core::valuetype_adapter (void)
03463 {
03464 if (this->valuetype_adapter_ == 0)
03465 {
03466 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
03467 ace_mon,
03468 this->lock_,
03469 0);
03470
03471 if (this->valuetype_adapter_ == 0)
03472 {
03473 try
03474 {
03475 TAO_Valuetype_Adapter_Factory * vt_ap_factory =
03476 ACE_Dynamic_Service<TAO_Valuetype_Adapter_Factory>::instance (
03477 TAO_ORB_Core::valuetype_adapter_factory_name ()
03478 );
03479
03480 if (vt_ap_factory)
03481 {
03482 this->valuetype_adapter_ = vt_ap_factory->create ();
03483 }
03484 }
03485 catch (const ::CORBA::Exception& ex)
03486 {
03487 ex._tao_print_exception (
03488 "Cannot initialize the valuetype_adapter\n");
03489 }
03490 }
03491
03492 if (this->valuetype_adapter_ == 0)
03493 {
03494 throw ::CORBA::INTERNAL ();
03495 }
03496 }
03497
03498 return this->valuetype_adapter_;
03499 }
03500
03501
03502
03503
03504
03505 #if !defined(CORBA_E_MICRO)
03506 CORBA::ValueFactory
03507 TAO_ORB_Core::register_value_factory (const char *repository_id,
03508 CORBA::ValueFactory factory)
03509 {
03510 if (this->valuetype_adapter ())
03511 {
03512 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
03513
03514 if (this->valuetype_adapter_ == 0)
03515 {
03516 return 0;
03517 }
03518
03519 int const result =
03520 this->valuetype_adapter_->vf_map_rebind (repository_id, factory);
03521
03522 if (result == 0)
03523 {
03524 return 0;
03525 }
03526
03527 if (result == -1)
03528 {
03529
03530 throw ::CORBA::MARSHAL ();
03531 }
03532 }
03533
03534 return factory;
03535 }
03536 #endif
03537
03538 #if !defined(CORBA_E_MICRO)
03539 void
03540 TAO_ORB_Core::unregister_value_factory (const char *repository_id)
03541 {
03542 if (this->valuetype_adapter ())
03543 {
03544 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
03545
03546 if (this->valuetype_adapter_ == 0)
03547 {
03548 return;
03549 }
03550
03551
03552 (void) this->valuetype_adapter_->vf_map_unbind (repository_id);
03553 }
03554 }
03555 #endif
03556
03557 #if !defined(CORBA_E_MICRO)
03558 CORBA::ValueFactory
03559 TAO_ORB_Core::lookup_value_factory (const char *repository_id)
03560 {
03561 if (this->valuetype_adapter ())
03562 {
03563 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
03564
03565 if (this->valuetype_adapter_ == 0)
03566 {
03567 return 0;
03568 }
03569
03570 return this->valuetype_adapter_->vf_map_find (repository_id);
03571 }
03572
03573 return 0;
03574 }
03575 #endif
03576
03577
03578
03579 TAO_Export TAO_ORB_Core *
03580 TAO_ORB_Core_instance (void)
03581 {
03582
03583
03584 TAO::ORB_Table * const orb_table = TAO::ORB_Table::instance ();
03585 if (orb_table->first_orb () == 0)
03586 {
03587 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, guard,
03588 *ACE_Static_Object_Lock::instance (), 0));
03589
03590 if (orb_table->first_orb () == 0)
03591 {
03592
03593
03594
03595
03596
03597
03598
03599
03600 try
03601 {
03602 int argc = 0;
03603 ACE_TCHAR **const argv= 0;
03604 CORBA::ORB_var orb =
03605 CORBA::ORB_init (argc, argv);
03606 }
03607 catch (const ::CORBA::Exception&)
03608 {
03609
03610 }
03611 }
03612 }
03613
03614 return orb_table->first_orb ();
03615 }
03616
03617
03618 TAO::Collocation_Strategy
03619 TAO_ORB_Core::collocation_strategy (CORBA::Object_ptr object)
03620 {
03621 TAO_Stub *stub = object->_stubobj ();
03622 if (!CORBA::is_nil (stub->servant_orb_var ().in ()) &&
03623 stub->servant_orb_var ()->orb_core () != 0)
03624 {
03625 TAO_ORB_Core *orb_core = stub->servant_orb_var ()->orb_core ();
03626
03627 if (orb_core->collocation_resolver ().is_collocated (object))
03628 {
03629 switch (orb_core->get_collocation_strategy ())
03630 {
03631 case THRU_POA:
03632 return TAO::TAO_CS_THRU_POA_STRATEGY;
03633
03634 case DIRECT:
03635 {
03636
03637
03638
03639
03640
03641 ACE_ASSERT (object->_servant () != 0);
03642 return TAO::TAO_CS_DIRECT_STRATEGY;
03643 }
03644 }
03645 }
03646 }
03647
03648
03649 return TAO::TAO_CS_REMOTE_STRATEGY;
03650 }
03651
03652 TAO_END_VERSIONED_NAMESPACE_DECL