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