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