00001
00002
00003 #include "tao/ORB.h"
00004
00005 ACE_RCSID (tao,
00006 ORB,
00007 "$Id: ORB.cpp 89152 2010-02-23 09:57:24Z vzykov $")
00008
00009 #include "tao/ORB_Table.h"
00010 #include "tao/Connector_Registry.h"
00011 #include "tao/IOR_Parser.h"
00012 #include "tao/Stub.h"
00013 #include "tao/ORB_Core.h"
00014 #include "tao/ORB_Core_TSS_Resources.h"
00015 #include "tao/TAO_Internal.h"
00016 #include "tao/Dynamic_Adapter.h"
00017 #include "tao/Profile.h"
00018 #include "tao/default_ports.h"
00019 #include "tao/ORBInitializer_Registry_Adapter.h"
00020 #include "tao/PolicyFactory_Registry_Adapter.h"
00021 #include "tao/NVList_Adapter.h"
00022 #include "tao/Policy_Current.h"
00023 #include "tao/Policy_Manager.h"
00024 #include "tao/Valuetype_Adapter.h"
00025 #include "tao/IFR_Client_Adapter.h"
00026 #include "tao/TypeCodeFactory_Adapter.h"
00027 #include "tao/debug.h"
00028 #include "tao/CDR.h"
00029 #include "tao/SystemException.h"
00030 #include "tao/default_environment.h"
00031 #include "tao/ObjectIdListC.h"
00032
00033 #if !defined (__ACE_INLINE__)
00034 # include "tao/ORB.inl"
00035 #endif
00036
00037 #include "ace/Dynamic_Service.h"
00038 #include "ace/Service_Config.h"
00039 #include "ace/Arg_Shifter.h"
00040 #include "ace/Reactor.h"
00041 #include "ace/Argv_Type_Converter.h"
00042 #include "ace/ACE.h"
00043 #include "ace/Static_Object_Lock.h"
00044 #include "ace/OS_NS_strings.h"
00045 #include "ace/OS_NS_string.h"
00046 #include "ace/OS_NS_ctype.h"
00047 #include "ace/CORBA_macros.h"
00048
00049 static const char ior_prefix[] = "IOR:";
00050
00051
00052
00053 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00054
00055 CORBA::ORB::InvalidName::InvalidName (void)
00056 : CORBA::UserException ("IDL:omg.org/CORBA/ORB/InvalidName:1.0",
00057 "InvalidName")
00058 {
00059 }
00060
00061
00062 CORBA::ORB::InvalidName::~InvalidName (void)
00063 {
00064 }
00065
00066
00067 CORBA::ORB::InvalidName::InvalidName (const CORBA::ORB::InvalidName &exc)
00068 : CORBA::UserException (exc._rep_id (),
00069 exc._name ())
00070 {
00071 }
00072
00073
00074 CORBA::ORB::InvalidName&
00075 CORBA::ORB::InvalidName::operator= (const ::CORBA::ORB::InvalidName &_tao_excp)
00076 {
00077 this->UserException::operator= (_tao_excp);
00078 return *this;
00079 }
00080
00081 CORBA::ORB::InvalidName *
00082 CORBA::ORB::InvalidName::_downcast (CORBA::Exception *exc)
00083 {
00084 return dynamic_cast<InvalidName *> (exc);
00085 }
00086
00087 CORBA::Exception *CORBA::ORB::InvalidName::_alloc (void)
00088 {
00089 CORBA::Exception *retval = 0;
00090 ACE_NEW_RETURN (retval, ::CORBA::ORB::InvalidName, 0);
00091 return retval;
00092 }
00093
00094 CORBA::Exception *
00095 CORBA::ORB::InvalidName::_tao_duplicate (void) const
00096 {
00097 CORBA::Exception *result = 0;
00098 ACE_NEW_RETURN (
00099 result,
00100 ::CORBA::ORB::InvalidName (*this),
00101 0);
00102 return result;
00103 }
00104
00105 void CORBA::ORB::InvalidName::_raise (void) const
00106 {
00107 throw *this;
00108 }
00109
00110 void CORBA::ORB::InvalidName::_tao_encode (TAO_OutputCDR &) const
00111 {
00112 throw ::CORBA::MARSHAL ();
00113 }
00114
00115 void CORBA::ORB::InvalidName::_tao_decode (TAO_InputCDR &)
00116 {
00117 throw ::CORBA::MARSHAL ();
00118 }
00119
00120
00121
00122 CORBA::ORB::ORB (TAO_ORB_Core *orb_core)
00123 : refcount_ (1)
00124 , orb_core_ (orb_core)
00125 , use_omg_ior_format_ (1)
00126 , timeout_ (0)
00127 {
00128 }
00129
00130 CORBA::ORB::~ORB (void)
00131 {
00132
00133
00134 }
00135
00136 void
00137 CORBA::ORB::shutdown (CORBA::Boolean wait_for_completion)
00138 {
00139
00140
00141
00142 this->check_shutdown ();
00143
00144 this->orb_core ()->shutdown (wait_for_completion);
00145 }
00146
00147 void
00148 CORBA::ORB::destroy (void)
00149 {
00150 if (this->orb_core () == 0)
00151 {
00152
00153
00154
00155
00156
00157
00158
00159 throw ::CORBA::OBJECT_NOT_EXIST (0, CORBA::COMPLETED_NO);
00160 }
00161
00162 if (TAO_debug_level > 2)
00163 {
00164 ACE_DEBUG ((LM_DEBUG,
00165 ACE_TEXT ("CORBA::ORB::destroy() called on ORB <%C>.\n"),
00166 this->orb_core ()->orbid ()));
00167 }
00168
00169 this->orb_core ()->destroy ();
00170
00171
00172
00173 this->orb_core_ = 0;
00174 }
00175
00176 void
00177 CORBA::ORB::run (void)
00178 {
00179 this->run (0);
00180 }
00181
00182 void
00183 CORBA::ORB::run (ACE_Time_Value &tv)
00184 {
00185 this->run (&tv);
00186 }
00187
00188 void
00189 CORBA::ORB::run (ACE_Time_Value *tv)
00190 {
00191 this->check_shutdown ();
00192
00193 this->orb_core ()->run (tv, 0);
00194 }
00195
00196 void
00197 CORBA::ORB::perform_work (void)
00198 {
00199 this->perform_work (0);
00200 }
00201
00202 void
00203 CORBA::ORB::perform_work (ACE_Time_Value &tv)
00204 {
00205 this->perform_work (&tv);
00206 }
00207
00208 void
00209 CORBA::ORB::perform_work (ACE_Time_Value *tv)
00210 {
00211
00212 this->check_shutdown ();
00213
00214 this->orb_core ()->run (tv, 1);
00215 }
00216
00217 CORBA::Boolean
00218 CORBA::ORB::work_pending (ACE_Time_Value &tv)
00219 {
00220
00221 this->check_shutdown ();
00222
00223 int const result = this->orb_core_->reactor ()->work_pending (tv);
00224 if (result == 0 || (result == -1 && errno == ETIME))
00225 return false;
00226
00227 if (result == -1)
00228 throw ::CORBA::INTERNAL ();
00229
00230 return true;
00231 }
00232
00233 CORBA::Boolean
00234 CORBA::ORB::work_pending (void)
00235 {
00236
00237 this->check_shutdown ();
00238
00239 const int result = this->orb_core_->reactor ()->work_pending ();
00240 if (result == 0)
00241 return false;
00242
00243 if (result == -1)
00244 throw ::CORBA::INTERNAL ();
00245
00246 return true;
00247 }
00248
00249 #if (TAO_HAS_MINIMUM_CORBA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00250
00251 void
00252 CORBA::ORB::create_list (CORBA::Long count, CORBA::NVList_ptr &new_list)
00253 {
00254 TAO_NVList_Adapter *adapter =
00255 ACE_Dynamic_Service<TAO_NVList_Adapter>::instance ("TAO_NVList_Adapter");
00256
00257 if (adapter == 0)
00258 {
00259 ACE_ERROR ((LM_ERROR,
00260 ACE_TEXT ("(%P|%t) %p\n"),
00261 ACE_TEXT ("ORB unable to find the ")
00262 ACE_TEXT ("NVList Adapter instance")));
00263 throw ::CORBA::INTERNAL ();
00264 }
00265
00266 adapter->create_list (count, new_list);
00267 }
00268
00269 void
00270 CORBA::ORB::create_exception_list (CORBA::ExceptionList_ptr &list)
00271 {
00272 TAO_Dynamic_Adapter *dynamic_adapter =
00273 ACE_Dynamic_Service<TAO_Dynamic_Adapter>::instance (
00274 TAO_ORB_Core::dynamic_adapter_name ());
00275
00276 dynamic_adapter->create_exception_list (list);
00277 }
00278
00279 void
00280 CORBA::ORB::create_operation_list (CORBA::OperationDef_ptr opDef,
00281 CORBA::NVList_ptr &result)
00282 {
00283 TAO_IFR_Client_Adapter *adapter =
00284 ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
00285 TAO_ORB_Core::ifr_client_adapter_name ());
00286
00287 if (adapter == 0)
00288 {
00289 throw ::CORBA::INTF_REPOS ();
00290 }
00291
00292 adapter->create_operation_list (this, opDef, result);
00293 }
00294
00295
00296 void
00297 CORBA::ORB::create_environment (CORBA::Environment_ptr &environment)
00298 {
00299 ACE_NEW_THROW_EX (environment,
00300 CORBA::Environment (),
00301 CORBA::NO_MEMORY (
00302 CORBA::SystemException::_tao_minor_code (
00303 0,
00304 ENOMEM),
00305 CORBA::COMPLETED_NO));
00306 }
00307
00308 void
00309 CORBA::ORB::create_named_value (CORBA::NamedValue_ptr &nv)
00310 {
00311 TAO_NVList_Adapter *adapter =
00312 ACE_Dynamic_Service<TAO_NVList_Adapter>::instance (
00313 "TAO_NVList_Adapter");
00314
00315 if (adapter == 0)
00316 {
00317 ACE_ERROR ((LM_ERROR,
00318 ACE_TEXT ("(%P|%t) %p\n"),
00319 ACE_TEXT ("ORB unable to find the ")
00320 ACE_TEXT ("NVList Adapter instance")));
00321
00322 throw ::CORBA::INTERNAL ();
00323 }
00324
00325 adapter->create_named_value (nv);
00326 }
00327
00328
00329
00330
00331 CORBA::Boolean
00332 CORBA::ORB::get_service_information (
00333 CORBA::ServiceType ,
00334 CORBA::ServiceInformation_out )
00335 {
00336 throw ::CORBA::NO_IMPLEMENT (
00337 CORBA::SystemException::_tao_minor_code (
00338 0,
00339 ENOTSUP),
00340 CORBA::COMPLETED_NO);
00341 }
00342
00343 void
00344 CORBA::ORB::create_context_list (CORBA::ContextList_ptr &)
00345 {
00346 throw ::CORBA::NO_IMPLEMENT (
00347 CORBA::SystemException::_tao_minor_code (
00348 0,
00349 ENOTSUP),
00350 CORBA::COMPLETED_NO);
00351 }
00352
00353 void
00354 CORBA::ORB::get_default_context (CORBA::Context_ptr &)
00355 {
00356 throw ::CORBA::NO_IMPLEMENT (
00357 CORBA::SystemException::_tao_minor_code (
00358 0,
00359 ENOTSUP),
00360 CORBA::COMPLETED_NO);
00361 }
00362
00363 void
00364 CORBA::ORB::send_multiple_requests_oneway (const CORBA::RequestSeq &)
00365 {
00366 throw ::CORBA::NO_IMPLEMENT (
00367 CORBA::SystemException::_tao_minor_code (
00368 0,
00369 ENOTSUP),
00370 CORBA::COMPLETED_NO);
00371 }
00372
00373 void
00374 CORBA::ORB::send_multiple_requests_deferred (const CORBA::RequestSeq &)
00375 {
00376 throw ::CORBA::NO_IMPLEMENT (
00377 CORBA::SystemException::_tao_minor_code (
00378 0,
00379 ENOTSUP),
00380 CORBA::COMPLETED_NO);
00381 }
00382
00383 void
00384 CORBA::ORB::get_next_response (CORBA::Request_ptr &)
00385 {
00386 throw ::CORBA::NO_IMPLEMENT (
00387 CORBA::SystemException::_tao_minor_code (
00388 0,
00389 ENOTSUP),
00390 CORBA::COMPLETED_NO);
00391 }
00392
00393 CORBA::Boolean
00394 CORBA::ORB::poll_next_response (void)
00395 {
00396 throw ::CORBA::NO_IMPLEMENT (
00397 CORBA::SystemException::_tao_minor_code (
00398 0,
00399 ENOTSUP),
00400 CORBA::COMPLETED_NO);
00401 }
00402
00403
00404
00405 CORBA::TypeCode_ptr
00406 CORBA::ORB::create_struct_tc (
00407 const char *id,
00408 const char *name,
00409 const CORBA::StructMemberSeq & members)
00410 {
00411 TAO_TypeCodeFactory_Adapter *adapter =
00412 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00413 TAO_ORB_Core::typecodefactory_adapter_name ());
00414
00415 if (adapter == 0)
00416 {
00417 throw ::CORBA::INTERNAL ();
00418 }
00419
00420 return adapter->create_struct_tc (id, name, members);
00421 }
00422
00423 CORBA::TypeCode_ptr
00424 CORBA::ORB::create_union_tc (
00425 const char *id,
00426 const char *name,
00427 CORBA::TypeCode_ptr discriminator_type,
00428 const CORBA::UnionMemberSeq & members)
00429 {
00430 TAO_TypeCodeFactory_Adapter *adapter =
00431 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00432 TAO_ORB_Core::typecodefactory_adapter_name ());
00433
00434 if (adapter == 0)
00435 {
00436 throw ::CORBA::INTERNAL ();
00437 }
00438
00439 return adapter->create_union_tc (id,
00440 name,
00441 discriminator_type,
00442 members);
00443 }
00444
00445 CORBA::TypeCode_ptr
00446 CORBA::ORB::create_enum_tc (
00447 const char *id,
00448 const char *name,
00449 const CORBA::EnumMemberSeq & members)
00450 {
00451 TAO_TypeCodeFactory_Adapter *adapter =
00452 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00453 TAO_ORB_Core::typecodefactory_adapter_name ());
00454
00455 if (adapter == 0)
00456 {
00457 throw ::CORBA::INTERNAL ();
00458 }
00459
00460 return adapter->create_enum_tc (id, name, members);
00461 }
00462
00463 CORBA::TypeCode_ptr
00464 CORBA::ORB::create_alias_tc (
00465 const char *id,
00466 const char *name,
00467 CORBA::TypeCode_ptr original_type)
00468 {
00469 TAO_TypeCodeFactory_Adapter *adapter =
00470 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00471 TAO_ORB_Core::typecodefactory_adapter_name ());
00472
00473 if (adapter == 0)
00474 {
00475 throw ::CORBA::INTERNAL ();
00476 }
00477
00478 return adapter->create_alias_tc (id, name, original_type);
00479 }
00480
00481 CORBA::TypeCode_ptr
00482 CORBA::ORB::create_exception_tc (
00483 const char *id,
00484 const char *name,
00485 const CORBA::StructMemberSeq & members)
00486 {
00487 TAO_TypeCodeFactory_Adapter *adapter =
00488 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00489 TAO_ORB_Core::typecodefactory_adapter_name ());
00490
00491 if (adapter == 0)
00492 {
00493 throw ::CORBA::INTERNAL ();
00494 }
00495
00496 return adapter->create_exception_tc (id, name, members);
00497 }
00498
00499 CORBA::TypeCode_ptr
00500 CORBA::ORB::create_interface_tc (
00501 const char *id,
00502 const char *name)
00503 {
00504 TAO_TypeCodeFactory_Adapter *adapter =
00505 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00506 TAO_ORB_Core::typecodefactory_adapter_name ());
00507
00508 if (adapter == 0)
00509 {
00510 throw ::CORBA::INTERNAL ();
00511 }
00512
00513 return adapter->create_interface_tc (id, name);
00514 }
00515
00516 CORBA::TypeCode_ptr
00517 CORBA::ORB::create_string_tc (
00518 CORBA::ULong bound)
00519 {
00520 TAO_TypeCodeFactory_Adapter *adapter =
00521 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00522 TAO_ORB_Core::typecodefactory_adapter_name ());
00523
00524 if (adapter == 0)
00525 {
00526 throw ::CORBA::INTERNAL ();
00527 }
00528
00529 return adapter->create_string_tc (bound);
00530 }
00531
00532 CORBA::TypeCode_ptr
00533 CORBA::ORB::create_wstring_tc (
00534 CORBA::ULong bound)
00535 {
00536 TAO_TypeCodeFactory_Adapter *adapter =
00537 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00538 TAO_ORB_Core::typecodefactory_adapter_name ());
00539
00540 if (adapter == 0)
00541 {
00542 throw ::CORBA::INTERNAL ();
00543 }
00544
00545 return adapter->create_wstring_tc (bound);
00546 }
00547
00548 CORBA::TypeCode_ptr
00549 CORBA::ORB::create_fixed_tc (
00550 CORBA::UShort digits,
00551 CORBA::UShort scale)
00552 {
00553 TAO_TypeCodeFactory_Adapter *adapter =
00554 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00555 TAO_ORB_Core::typecodefactory_adapter_name ());
00556
00557 if (adapter == 0)
00558 {
00559 throw ::CORBA::INTERNAL ();
00560 }
00561
00562 return adapter->create_fixed_tc (digits, scale);
00563 }
00564
00565 CORBA::TypeCode_ptr
00566 CORBA::ORB::create_sequence_tc (
00567 CORBA::ULong bound,
00568 CORBA::TypeCode_ptr element_type)
00569 {
00570 TAO_TypeCodeFactory_Adapter *adapter =
00571 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00572 TAO_ORB_Core::typecodefactory_adapter_name ());
00573
00574 if (adapter == 0)
00575 {
00576 throw ::CORBA::INTERNAL ();
00577 }
00578
00579 return adapter->create_sequence_tc (bound, element_type);
00580 }
00581
00582 CORBA::TypeCode_ptr
00583 CORBA::ORB::create_array_tc (
00584 CORBA::ULong length,
00585 CORBA::TypeCode_ptr element_type)
00586 {
00587 TAO_TypeCodeFactory_Adapter *adapter =
00588 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00589 TAO_ORB_Core::typecodefactory_adapter_name ());
00590
00591 if (adapter == 0)
00592 {
00593 throw ::CORBA::INTERNAL ();
00594 }
00595
00596 return adapter->create_array_tc (length, element_type);
00597 }
00598
00599 CORBA::TypeCode_ptr
00600 CORBA::ORB::create_value_tc (
00601 const char *id,
00602 const char *name,
00603 CORBA::ValueModifier type_modifier,
00604 CORBA::TypeCode_ptr concrete_base,
00605 const CORBA::ValueMemberSeq & members)
00606 {
00607 TAO_TypeCodeFactory_Adapter *adapter =
00608 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00609 TAO_ORB_Core::typecodefactory_adapter_name ());
00610
00611 if (adapter == 0)
00612 {
00613 throw ::CORBA::INTERNAL ();
00614 }
00615
00616 return adapter->create_value_tc (id, name,
00617 type_modifier,
00618 concrete_base,
00619 members);
00620 }
00621
00622 CORBA::TypeCode_ptr
00623 CORBA::ORB::create_value_box_tc (
00624 const char *id,
00625 const char *name,
00626 CORBA::TypeCode_ptr boxed_type)
00627 {
00628 TAO_TypeCodeFactory_Adapter *adapter =
00629 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00630 TAO_ORB_Core::typecodefactory_adapter_name ());
00631
00632 if (adapter == 0)
00633 {
00634 throw ::CORBA::INTERNAL ();
00635 }
00636
00637 return adapter->create_value_box_tc (id, name, boxed_type);
00638 }
00639
00640 CORBA::TypeCode_ptr
00641 CORBA::ORB::create_native_tc (const char *id, const char *name)
00642 {
00643 TAO_TypeCodeFactory_Adapter *adapter =
00644 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00645 TAO_ORB_Core::typecodefactory_adapter_name ());
00646
00647 if (adapter == 0)
00648 {
00649 throw ::CORBA::INTERNAL ();
00650 }
00651
00652 return adapter->create_native_tc (id, name);
00653 }
00654
00655 CORBA::TypeCode_ptr
00656 CORBA::ORB::create_recursive_tc (const char *id)
00657 {
00658 TAO_TypeCodeFactory_Adapter *adapter =
00659 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00660 TAO_ORB_Core::typecodefactory_adapter_name ());
00661
00662 if (adapter == 0)
00663 {
00664 throw ::CORBA::INTERNAL ();
00665 }
00666
00667 return adapter->create_recursive_tc (id);
00668 }
00669
00670 CORBA::TypeCode_ptr
00671 CORBA::ORB::create_abstract_interface_tc (const char *id, const char *name)
00672 {
00673 TAO_TypeCodeFactory_Adapter *adapter =
00674 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00675 TAO_ORB_Core::typecodefactory_adapter_name ());
00676
00677 if (adapter == 0)
00678 {
00679 throw ::CORBA::INTERNAL ();
00680 }
00681
00682 return adapter->create_abstract_interface_tc (id, name);
00683 }
00684
00685 CORBA::TypeCode_ptr
00686 CORBA::ORB::create_local_interface_tc (const char *id, const char *name)
00687 {
00688 TAO_TypeCodeFactory_Adapter *adapter =
00689 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00690 TAO_ORB_Core::typecodefactory_adapter_name ());
00691
00692 if (adapter == 0)
00693 {
00694 throw ::CORBA::INTERNAL ();
00695 }
00696
00697 return adapter->create_local_interface_tc (id, name);
00698 }
00699
00700 CORBA::TypeCode_ptr
00701 CORBA::ORB::create_component_tc (const char *id, const char *name)
00702 {
00703 TAO_TypeCodeFactory_Adapter *adapter =
00704 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00705 TAO_ORB_Core::typecodefactory_adapter_name ());
00706
00707 if (adapter == 0)
00708 {
00709 throw ::CORBA::INTERNAL ();
00710 }
00711
00712 return adapter->create_component_tc (id, name);
00713 }
00714
00715 CORBA::TypeCode_ptr
00716 CORBA::ORB::create_home_tc (const char *id, const char *name)
00717 {
00718 TAO_TypeCodeFactory_Adapter *adapter =
00719 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00720 TAO_ORB_Core::typecodefactory_adapter_name ());
00721
00722 if (adapter == 0)
00723 {
00724 throw ::CORBA::INTERNAL ();
00725 }
00726
00727 return adapter->create_home_tc (id, name);
00728 }
00729
00730 CORBA::TypeCode_ptr
00731 CORBA::ORB::create_event_tc (
00732 const char *id,
00733 const char *name,
00734 CORBA::ValueModifier type_modifier,
00735 CORBA::TypeCode_ptr concrete_base,
00736 const CORBA::ValueMemberSeq &members)
00737 {
00738 TAO_TypeCodeFactory_Adapter *adapter =
00739 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00740 TAO_ORB_Core::typecodefactory_adapter_name ());
00741
00742 if (adapter == 0)
00743 {
00744 throw ::CORBA::INTERNAL ();
00745 }
00746
00747 return adapter->create_event_tc (id,
00748 name,
00749 type_modifier,
00750 concrete_base,
00751 members);
00752 }
00753
00754
00755
00756 #endif
00757
00758 CORBA::Object_ptr
00759 CORBA::ORB::resolve_policy_manager (void)
00760 {
00761 #if (TAO_HAS_CORBA_MESSAGING == 1)
00762
00763 TAO_Policy_Manager *policy_manager = this->orb_core_->policy_manager ();
00764
00765 if (policy_manager == 0)
00766 {
00767 return CORBA::Object::_nil ();
00768 }
00769
00770 return CORBA::Object::_duplicate (policy_manager);
00771
00772 #else
00773
00774 return CORBA::Object::_nil ();
00775
00776 #endif
00777 }
00778
00779 CORBA::Object_ptr
00780 CORBA::ORB::resolve_policy_current (void)
00781 {
00782 #if (TAO_HAS_CORBA_MESSAGING == 1)
00783
00784 TAO_Policy_Current &policy_current = this->orb_core_->policy_current ();
00785 return CORBA::Object::_duplicate (&policy_current);
00786
00787 #else
00788
00789 return CORBA::Object::_nil ();
00790
00791 #endif
00792 }
00793
00794 void
00795 CORBA::ORB::resolve_service (TAO::MCAST_SERVICEID mcast_service_id)
00796 {
00797 #if defined ACE_HAS_IP_MULTICAST
00798 static char const * const env_service_port[] =
00799 {
00800 "NameServicePort",
00801 "TradingServicePort",
00802 "ImplRepoServicePort",
00803 "InterfaceRepoServicePort"
00804 };
00805
00806 static unsigned short const default_service_port[] =
00807 {
00808 TAO_DEFAULT_NAME_SERVER_REQUEST_PORT,
00809 TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT,
00810 TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT,
00811 TAO_DEFAULT_INTERFACEREPO_SERVER_REQUEST_PORT
00812 };
00813
00814
00815
00816
00817
00818 CORBA::String_var default_init_ref =
00819 this->orb_core_->orb_params ()->default_init_ref ();
00820
00821 static char const mcast_prefix[] = "mcast://:::";
00822
00823 if ((ACE_OS::strncmp (default_init_ref.in (),
00824 mcast_prefix,
00825 sizeof (mcast_prefix) - 1) == 0))
00826 {
00827
00828 unsigned short port =
00829 this->orb_core_->orb_params ()->service_port (mcast_service_id);
00830
00831 if (port == 0)
00832 {
00833
00834 char const * const port_number =
00835 ACE_OS::getenv (env_service_port[mcast_service_id]);
00836
00837 if (port_number != 0)
00838 port = static_cast<unsigned short> (ACE_OS::atoi (port_number));
00839 else
00840 port = default_service_port[mcast_service_id];
00841 }
00842
00843
00844
00845 static char const mcast_fmt[] = "mcast://:%d::";
00846 static size_t const PORT_BUF_SIZE = 256;
00847
00848 char def_init_ref[PORT_BUF_SIZE] = { 0 };
00849
00850 ACE_OS::snprintf (def_init_ref,
00851 PORT_BUF_SIZE,
00852 mcast_fmt,
00853 port);
00854
00855 this->orb_core_->orb_params ()->default_init_ref (def_init_ref);
00856 }
00857 #else
00858 ACE_UNUSED_ARG (mcast_service_id);
00859 #endif
00860 }
00861
00862 CORBA::Object_ptr
00863 CORBA::ORB::resolve_initial_references (const char *name,
00864 ACE_Time_Value *timeout)
00865 {
00866
00867 this->check_shutdown ();
00868
00869 CORBA::Object_var result;
00870
00871 if (ACE_OS::strcmp (name, TAO_OBJID_ROOTPOA) == 0)
00872 {
00873 result = this->orb_core ()->root_poa ();
00874 }
00875 else if (ACE_OS::strcmp (name, TAO_OBJID_POACURRENT) == 0)
00876 {
00877 result = this->orb_core ()->resolve_poa_current ();
00878 }
00879 else if (ACE_OS::strcmp (name, TAO_OBJID_POLICYMANAGER) == 0)
00880 {
00881 result = this->resolve_policy_manager ();
00882 }
00883 else if (ACE_OS::strcmp (name, TAO_OBJID_POLICYCURRENT) == 0)
00884 {
00885 result = this->resolve_policy_current ();
00886 }
00887 else if (ACE_OS::strcmp (name, TAO_OBJID_IORMANIPULATION) == 0)
00888 {
00889 result = this->orb_core ()->resolve_ior_manipulation ();
00890 }
00891 else if (ACE_OS::strcmp (name, TAO_OBJID_IORTABLE) == 0)
00892 {
00893 result = this->orb_core ()->resolve_ior_table ();
00894 }
00895 else if (ACE_OS::strcmp (name, TAO_OBJID_DYNANYFACTORY) == 0)
00896 {
00897 result = this->orb_core ()->resolve_dynanyfactory ();
00898 }
00899 else if (ACE_OS::strcmp (name, TAO_OBJID_TYPECODEFACTORY) == 0)
00900 {
00901 result = this->orb_core ()->resolve_typecodefactory ();
00902 }
00903 else if (ACE_OS::strcmp (name, TAO_OBJID_CODECFACTORY) == 0)
00904 {
00905 result = this->orb_core ()->resolve_codecfactory ();
00906 }
00907 else if (ACE_OS::strcmp (name, TAO_OBJID_COMPRESSIONMANAGER) == 0)
00908 {
00909 result = this->orb_core ()->resolve_compression_manager ();
00910 }
00911 else if (ACE_OS::strcmp (name, TAO_OBJID_MONITOR) == 0)
00912 {
00913 result = this->orb_core ()->resolve_monitor ();
00914 }
00915 #if TAO_HAS_INTERCEPTORS == 1
00916 else if (ACE_OS::strcmp (name, TAO_OBJID_PICurrent) == 0)
00917 {
00918 result = this->orb_core ()->resolve_picurrent ();
00919 }
00920 #endif
00921
00922
00923
00924 if (CORBA::is_nil (result.in ()))
00925 {
00926
00927
00928 result =
00929 this->orb_core ()->object_ref_table ().resolve_initial_reference (name);
00930 }
00931
00932 if (!CORBA::is_nil (result.in ()))
00933 return result._retn ();
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944 TAO_ORB_Core::InitRefMap::iterator ior =
00945 this->orb_core_->init_ref_map ()->find (ACE_CString (name));
00946
00947 if (ior != this->orb_core_->init_ref_map ()->end ())
00948 return this->string_to_object ((*ior).second.c_str ());
00949
00950
00951
00952 static const char ior_string[] = "IOR";
00953
00954 CORBA::String_var ior_env_var_name =
00955 CORBA::string_alloc (
00956 static_cast<CORBA::ULong> (ACE_OS::strlen (name) + sizeof (ior_string)));
00957
00958 ACE_OS::strcpy (ior_env_var_name.inout (), name);
00959
00960 ACE_OS::strcat (ior_env_var_name.inout (), ior_string);
00961
00962 ACE_CString service_ior = ACE_OS::getenv (ior_env_var_name.in ());
00963
00964 if (ACE_OS::strcmp (service_ior.c_str (), "") != 0)
00965 {
00966 result = this->string_to_object (service_ior.c_str());
00967
00968 return result._retn ();
00969 }
00970
00971
00972
00973
00974
00975
00976 this->set_timeout (timeout);
00977
00978 if (ACE_OS::strcmp (name, TAO_OBJID_NAMESERVICE) == 0)
00979 {
00980 this->resolve_service (TAO::MCAST_NAMESERVICE);
00981 }
00982 else if (ACE_OS::strcmp (name, TAO_OBJID_TRADINGSERVICE) == 0)
00983 {
00984 this->resolve_service (TAO::MCAST_TRADINGSERVICE);
00985 }
00986 else if (ACE_OS::strcmp (name, TAO_OBJID_IMPLREPOSERVICE) == 0)
00987 {
00988 this->resolve_service (TAO::MCAST_IMPLREPOSERVICE);
00989 }
00990 else if (ACE_OS::strcmp (name, TAO_OBJID_INTERFACEREP) == 0)
00991 {
00992 this->resolve_service (TAO::MCAST_INTERFACEREPOSERVICE);
00993 }
00994
00995
00996
00997
00998 result = this->orb_core ()->resolve_rir (name);
00999
01000 if (!CORBA::is_nil (result.in ()))
01001 return result._retn ();
01002
01003
01004 throw ::CORBA::ORB::InvalidName ();
01005 }
01006
01007 #if !defined(CORBA_E_MICRO)
01008 void
01009 CORBA::ORB::register_initial_reference (const char * id, CORBA::Object_ptr obj)
01010 {
01011 if (id == 0 || ACE_OS::strlen (id) == 0)
01012 throw ::CORBA::ORB::InvalidName ();
01013
01014 if (CORBA::is_nil (obj))
01015 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 27, CORBA::COMPLETED_NO);
01016
01017 TAO_Object_Ref_Table &table = this->orb_core_->object_ref_table ();
01018
01019 if (table.register_initial_reference (id, obj) == -1)
01020 throw ::CORBA::ORB::InvalidName ();
01021 }
01022
01023 CORBA::Object_ptr
01024 CORBA::ORB::unregister_initial_reference (const char * id)
01025 {
01026 if (id == 0 || ACE_OS::strlen (id) == 0)
01027 throw ::CORBA::ORB::InvalidName ();
01028
01029 TAO_Object_Ref_Table &table = this->orb_core_->object_ref_table ();
01030 CORBA::Object_ptr obj = table.unregister_initial_reference (id);
01031
01032 if (CORBA::is_nil (obj))
01033 throw ::CORBA::ORB::InvalidName ();
01034
01035 return obj;
01036 }
01037 #endif
01038
01039 CORBA::ORB::ObjectIdList_ptr
01040 CORBA::ORB::list_initial_services (void)
01041 {
01042 this->check_shutdown ();
01043
01044 return this->orb_core ()->list_initial_references ();
01045 }
01046
01047 void
01048 CORBA::ORB::check_shutdown (void)
01049 {
01050 if (this->orb_core () != 0)
01051 {
01052 this->orb_core ()->check_shutdown ();
01053 }
01054 else
01055 {
01056
01057
01058
01059
01060
01061
01062
01063 throw ::CORBA::OBJECT_NOT_EXIST (0, CORBA::COMPLETED_NO);
01064 }
01065 }
01066
01067
01068 CORBA::ORB_ptr
01069 CORBA::ORB::_tao_make_ORB (TAO_ORB_Core * orb_core)
01070 {
01071 CORBA::ORB_ptr orb = CORBA::ORB_ptr ();
01072
01073 ACE_NEW_RETURN (orb,
01074 CORBA::ORB (orb_core),
01075 CORBA::ORB::_nil ());
01076
01077 return orb;
01078 }
01079
01080
01081
01082 namespace TAO
01083 {
01084 bool
01085 parse_orb_opt (ACE_Argv_Type_Converter& command_line,
01086 const ACE_TCHAR* orb_opt,
01087 ACE_TString& opt_arg)
01088 {
01089
01090 if (opt_arg.length () > 0)
01091 return false;
01092
01093 ACE_Arg_Shifter arg_shifter (command_line.get_argc (),
01094 command_line.get_TCHAR_argv ());
01095
01096 size_t opt_len = ACE_OS::strlen (orb_opt);
01097
01098 bool found = false;
01099 while (arg_shifter.is_anything_left ())
01100 {
01101 const ACE_TCHAR *current_arg = arg_shifter.get_current ();
01102
01103 if (ACE_OS::strcasecmp (current_arg,
01104 orb_opt) == 0)
01105 {
01106 found = true;
01107 arg_shifter.consume_arg ();
01108 if (arg_shifter.is_parameter_next ())
01109 {
01110 opt_arg = arg_shifter.get_current ();
01111 arg_shifter.consume_arg ();
01112 }
01113 }
01114 else if (ACE_OS::strncasecmp (current_arg, orb_opt,
01115 opt_len) == 0)
01116 {
01117 arg_shifter.consume_arg ();
01118
01119
01120 if (current_arg[opt_len] == ' ')
01121 opt_arg = current_arg + opt_len + 1;
01122 else
01123 opt_arg = current_arg + opt_len;
01124 }
01125 else
01126 arg_shifter.ignore_arg ();
01127 }
01128 return found;
01129 }
01130
01131 ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt>
01132 find_orb_context (const ACE_TString& orbconfig_string)
01133 {
01134 const ACE_TCHAR *arg = orbconfig_string.c_str ();
01135
01136
01137
01138 if (ACE_OS::strcasecmp (arg, ACE_TEXT("LOCAL")) == 0)
01139 {
01140 ACE_Service_Gestalt* gestalt = 0;
01141 ACE_NEW_THROW_EX (gestalt,
01142 ACE_Service_Gestalt
01143 (ACE_Service_Gestalt::MAX_SERVICES / 4, true),
01144 CORBA::NO_MEMORY
01145 (CORBA::SystemException::_tao_minor_code (0,
01146 ENOMEM),
01147 CORBA::COMPLETED_NO));
01148 return ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> (gestalt);
01149 }
01150
01151 if (ACE_OS::strcasecmp (arg, ACE_TEXT("CURRENT")) == 0)
01152 {
01153 return ACE_Service_Config::current ();
01154 }
01155
01156
01157 if (orbconfig_string.is_empty () || ACE_OS::strcasecmp (arg, ACE_TEXT("GLOBAL")) == 0)
01158 {
01159 return ACE_Service_Config::global ();
01160 }
01161
01162
01163 const ACE_TCHAR *shared = ACE_TEXT("ORB:");
01164 size_t const shared_len = ACE_OS::strlen(shared);
01165 if (ACE_OS::strncmp (arg, shared, shared_len) == 0)
01166 {
01167 ACE_TString orbid (orbconfig_string.substr (shared_len));
01168
01169
01170 TAO_ORB_Core_Auto_Ptr oc (TAO::ORB_Table::instance ()->find (
01171 ACE_TEXT_ALWAYS_CHAR(orbid.c_str ())));
01172 if (oc.get () != 0)
01173 return oc->configuration ();
01174
01175 if (TAO_debug_level > 0)
01176 ACE_ERROR ((LM_ERROR,
01177 ACE_TEXT ("ERROR: Unable to find ORB: %s. Invalid shared ")
01178 ACE_TEXT ("configuration argument \"%s\"\n"),
01179 orbid.c_str (), arg));
01180
01181 throw ::CORBA::BAD_PARAM
01182 (CORBA::SystemException::_tao_minor_code
01183 ( TAO_ORB_CORE_INIT_LOCATION_CODE,
01184 ENOTSUP),
01185 CORBA::COMPLETED_NO);
01186 }
01187
01188
01189
01190 if (TAO_debug_level > 0)
01191 ACE_ERROR ((LM_ERROR,
01192 ACE_TEXT ("ERROR: -ORBGestalt unknown value <%s>\n"),
01193 orbconfig_string.c_str()));
01194
01195 throw ::CORBA::BAD_PARAM
01196 (CORBA::SystemException::_tao_minor_code
01197 ( TAO_ORB_CORE_INIT_LOCATION_CODE,
01198 EINVAL),
01199 CORBA::COMPLETED_NO);
01200 }
01201 }
01202
01203
01204
01205
01206
01207
01208
01209 #if defined (ACE_USES_WCHAR)
01210
01211 CORBA::ORB_ptr
01212 CORBA::ORB_init (int &argc,
01213 ACE_ANTI_TCHAR *argv[],
01214 const char *orbid)
01215 {
01216 ACE_Argv_Type_Converter command_line (argc, argv);
01217 return CORBA::ORB_init (command_line.get_argc (),
01218 command_line.get_TCHAR_argv (),
01219 orbid);
01220 }
01221
01222 CORBA::ORB_ptr
01223 CORBA::ORB_init (int &argc,
01224 wchar_t *argv[],
01225 const wchar_t *orbid)
01226 {
01227 return CORBA::ORB_init (argc, argv, ACE_TEXT_ALWAYS_CHAR (orbid));
01228 }
01229 #endif
01230
01231 CORBA::ORB_ptr
01232 CORBA::ORB_init (int &argc, ACE_TCHAR *argv[], const char *orbid)
01233 {
01234
01235
01236
01237 size_t const argv0_len = (argv ? (*argv
01238 ? ACE_OS::strlen (*argv)
01239 : 0)
01240 : 0);
01241
01242 if ((argc == 0 && argv0_len != 0)
01243 || (argc != 0 && (argv == 0 || argv[0] == 0)))
01244 {
01245 throw ::CORBA::BAD_PARAM (
01246 CORBA::SystemException::_tao_minor_code (
01247 0,
01248 EINVAL),
01249 CORBA::COMPLETED_NO);
01250 }
01251
01252
01253
01254
01255
01256
01257
01258
01259 if (TAO::ORB::open_global_services (argc, argv) == -1)
01260 {
01261 return CORBA::ORB::_nil ();
01262 }
01263
01264
01265 ACE_Argv_Type_Converter command_line (argc, argv);
01266
01267
01268
01269
01270
01271 ACE_TString orbid_string (ACE_TEXT_CHAR_TO_TCHAR(orbid));
01272 TAO::parse_orb_opt (command_line, ACE_TEXT("-ORBid"), orbid_string);
01273
01274
01275 TAO_ORB_Core_Auto_Ptr oc (TAO::ORB_Table::instance ()->find (
01276 ACE_TEXT_ALWAYS_CHAR(orbid_string.c_str ())));
01277
01278
01279 if (oc.get () != 0)
01280 {
01281 return CORBA::ORB::_duplicate (oc->orb ());
01282 }
01283
01284
01285
01286
01287
01288 ACE_TString orbconfig_string;
01289 TAO::parse_orb_opt (command_line, ACE_TEXT("-ORBGestalt"), orbconfig_string);
01290 ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> gestalt = TAO::find_orb_context (orbconfig_string);
01291
01292
01293
01294 TAO_ORB_Core * tmp = 0;
01295 ACE_NEW_THROW_EX (tmp,
01296 TAO_ORB_Core (ACE_TEXT_ALWAYS_CHAR(orbid_string.c_str ()),
01297 gestalt),
01298 CORBA::NO_MEMORY (
01299 CORBA::SystemException::_tao_minor_code (0,
01300 ENOMEM),
01301 CORBA::COMPLETED_NO));
01302
01303
01304
01305
01306
01307 oc.reset (tmp);
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320 ACE_Service_Config_Guard scg (oc->configuration ());
01321
01322
01323
01324
01325 int result = TAO::ORB::open_services (oc->configuration (),
01326 command_line.get_argc (),
01327 command_line.get_TCHAR_argv ());
01328
01329
01330 if (result != 0 && errno != ENOENT)
01331 {
01332 ACE_ERROR ((LM_ERROR,
01333 ACE_TEXT ("TAO (%P|%t) %p\n"),
01334 ACE_TEXT ("Unable to initialize the ")
01335 ACE_TEXT ("Service Configurator")));
01336 throw ::CORBA::INITIALIZE (
01337 CORBA::SystemException::_tao_minor_code (
01338 TAO_ORB_CORE_INIT_LOCATION_CODE,
01339 0),
01340 CORBA::COMPLETED_NO);
01341 }
01342
01343 TAO::ORBInitializer_Registry_Adapter * orbinitializer_registry =
01344 oc.get ()->orbinitializer_registry ();
01345
01346 PortableInterceptor::SlotId slotid = 0;
01347 size_t pre_init_count = 0;
01348
01349 if (orbinitializer_registry != 0)
01350 {
01351 pre_init_count =
01352 orbinitializer_registry->pre_init (oc.get (),
01353 command_line.get_argc(),
01354 command_line.get_ASCII_argv(),
01355 slotid);
01356 }
01357
01358
01359 result = oc->init (command_line.get_argc(),
01360 command_line.get_ASCII_argv());
01361
01362 if (orbinitializer_registry != 0)
01363 {
01364 orbinitializer_registry->post_init (pre_init_count,
01365 oc.get (),
01366 command_line.get_argc(),
01367 command_line.get_ASCII_argv(),
01368 slotid);
01369 }
01370
01371 if (TAO_debug_level > 2)
01372 {
01373 ACE_DEBUG ((LM_DEBUG,
01374 ACE_TEXT("TAO (%P|%t) - Created new ORB <%s>\n"),
01375 orbid_string.c_str ()));
01376 }
01377
01378
01379 if (TAO::ORB_Table::instance ()->bind (ACE_TEXT_ALWAYS_CHAR(orbid_string.c_str ()),
01380 oc.get ()) != 0)
01381 throw ::CORBA::INTERNAL (0, CORBA::COMPLETED_NO);
01382
01383
01384
01385 return CORBA::ORB::_duplicate (oc->orb ());
01386 }
01387
01388
01389
01390
01391 char *
01392 CORBA::ORB::object_to_string (CORBA::Object_ptr obj)
01393 {
01394
01395 this->check_shutdown ();
01396
01397 if (!CORBA::is_nil (obj))
01398 {
01399 if (!obj->can_convert_to_ior ())
01400 throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 4, CORBA::COMPLETED_NO);
01401
01402
01403 char* user_string =
01404 obj->convert_to_ior (this->use_omg_ior_format_, ior_prefix);
01405
01406 if (user_string != 0)
01407 return user_string;
01408 }
01409
01410
01411
01412
01413 if (use_omg_ior_format_)
01414 {
01415
01416
01417
01418
01419
01420
01421 #if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE)
01422 char buf [ACE_CDR::DEFAULT_BUFSIZE] = { 0 };
01423 #else
01424
01425
01426
01427 char buf [ACE_CDR::DEFAULT_BUFSIZE];
01428 #endif
01429
01430 TAO_OutputCDR cdr (buf, sizeof buf,
01431 TAO_ENCAP_BYTE_ORDER,
01432 this->orb_core_->output_cdr_buffer_allocator (),
01433 this->orb_core_->output_cdr_dblock_allocator (),
01434 this->orb_core_->output_cdr_msgblock_allocator (),
01435 this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
01436 TAO_DEF_GIOP_MAJOR,
01437 TAO_DEF_GIOP_MINOR);
01438
01439
01440
01441
01442
01443
01444 (void) ACE_OS::memset (buf, 0, sizeof (buf));
01445
01446
01447 (void) cdr.write_octet (TAO_ENCAP_BYTE_ORDER);
01448 if (!(cdr << obj))
01449 throw ::CORBA::MARSHAL ();
01450
01451
01452
01453
01454 size_t const total_len = cdr.total_length ();
01455
01456 char *cp = 0;
01457 ACE_ALLOCATOR_RETURN (cp,
01458 CORBA::string_alloc (
01459 sizeof ior_prefix
01460 + 2
01461 * static_cast<CORBA::ULong> (total_len)),
01462 0);
01463
01464 CORBA::String_var string = cp;
01465
01466 ACE_OS::strcpy (cp, ior_prefix);
01467 cp += sizeof (ior_prefix) - 1;
01468
01469 for (const ACE_Message_Block *i = cdr.begin (); i != 0; i = i->cont ())
01470 {
01471 const char *bytes = i->rd_ptr ();
01472 size_t len = i->length ();
01473
01474 while (len--)
01475 {
01476 *cp++ = static_cast<char> (ACE::nibble2hex ((*bytes) >> 4));
01477 *cp++ = static_cast<char> (ACE::nibble2hex (*bytes));
01478 ++bytes;
01479 }
01480 }
01481
01482 *cp = 0;
01483
01484 return string._retn ();
01485 }
01486 else
01487 {
01488
01489
01490
01491 if (CORBA::is_nil (obj) || obj->_stubobj () == 0)
01492 {
01493 if (TAO_debug_level > 0)
01494 ACE_ERROR ((LM_ERROR,
01495 ACE_TEXT ("Nil object reference or TAO_Stub ")
01496 ACE_TEXT ("pointer is zero when converting\n")
01497 ACE_TEXT ("object reference to URL IOR.\n")));
01498
01499 throw ::CORBA::MARSHAL (
01500 CORBA::SystemException::_tao_minor_code (
01501 0,
01502 EINVAL),
01503 CORBA::COMPLETED_NO);
01504 }
01505
01506 TAO_MProfile &mp = obj->_stubobj ()->base_profiles ();
01507
01508
01509 for (CORBA::ULong index = 0; index < mp.profile_count(); ++index)
01510 {
01511 char * result = mp.get_profile (index)->to_string();
01512 if (result)
01513 return result;
01514 }
01515
01516 if (TAO_debug_level > 0)
01517 ACE_ERROR ((LM_ERROR,
01518 ACE_TEXT ("TAO (%P|%t) - Cannot stringify given ")
01519 ACE_TEXT ("object. No or only unknown profiles.\n")));
01520
01521 throw ::CORBA::MARSHAL (
01522 CORBA::SystemException::_tao_minor_code (
01523 0,
01524 EINVAL),
01525 CORBA::COMPLETED_NO);
01526 }
01527 }
01528
01529
01530
01531
01532 CORBA::Object_ptr
01533 CORBA::ORB::string_to_object (const char *str)
01534 {
01535
01536 this->check_shutdown ();
01537
01538
01539 if (str == 0)
01540 throw ::CORBA::INV_OBJREF (
01541 CORBA::SystemException::_tao_minor_code (
01542 0,
01543 EINVAL),
01544 CORBA::COMPLETED_NO);
01545
01546 TAO_IOR_Parser *ior_parser =
01547 this->orb_core_->parser_registry ()->match_parser (str);
01548
01549 if (ior_parser != 0)
01550 {
01551 return ior_parser->parse_string (str, this);
01552 }
01553
01554 if (ACE_OS::strncmp (str, ior_prefix, sizeof ior_prefix - 1) == 0)
01555 return this->ior_string_to_object (str + sizeof ior_prefix - 1);
01556 else
01557 return this->url_ior_string_to_object (str);
01558 }
01559
01560 #if defined (ACE_USES_WCHAR)
01561 CORBA::Object_ptr
01562 CORBA::ORB::string_to_object (const wchar_t *str)
01563 {
01564 return this->string_to_object (ACE_TEXT_ALWAYS_CHAR (str));
01565 }
01566 #endif
01567
01568
01569
01570 char *
01571 CORBA::ORB::id (void)
01572 {
01573 return CORBA::string_dup (this->orb_core_->orbid ());
01574 }
01575
01576
01577
01578 #if !defined(CORBA_E_MICRO)
01579 CORBA::Policy_ptr
01580 CORBA::ORB::create_policy (CORBA::PolicyType type, const CORBA::Any& val)
01581 {
01582 this->check_shutdown ();
01583
01584 TAO::PolicyFactory_Registry_Adapter *adapter =
01585 this->orb_core_->policy_factory_registry ();
01586
01587 if (adapter == 0)
01588 {
01589 throw ::CORBA::INTERNAL ();
01590 }
01591
01592
01593 return adapter->create_policy (type, val);
01594 }
01595 #endif
01596
01597 #if !defined(CORBA_E_MICRO)
01598 CORBA::Policy_ptr
01599 CORBA::ORB::_create_policy (CORBA::PolicyType type)
01600 {
01601 this->check_shutdown ();
01602
01603 TAO::PolicyFactory_Registry_Adapter *adapter =
01604 this->orb_core_->policy_factory_registry ();
01605
01606 if (adapter == 0)
01607 {
01608 throw ::CORBA::INTERNAL ();
01609 }
01610
01611
01612 return adapter->_create_policy (type);
01613 }
01614 #endif
01615
01616
01617
01618
01619
01620
01621 CORBA::Object_ptr
01622 CORBA::ORB::ior_string_to_object (const char *str)
01623 {
01624
01625
01626 ACE_Message_Block mb (ACE_OS::strlen (str) / 2 + 1
01627 + ACE_CDR::MAX_ALIGNMENT + 1);
01628
01629 ACE_CDR::mb_align (&mb);
01630
01631 char *buffer = mb.rd_ptr ();
01632 const char *tmp = str;
01633 size_t len = 0;
01634
01635 while (tmp [0] && tmp [1])
01636 {
01637
01638
01639 #undef byte
01640 unsigned char byte;
01641
01642 if (!(ACE_OS::ace_isxdigit (tmp [0]) && ACE_OS::ace_isxdigit (tmp [1])))
01643 break;
01644
01645 byte = (u_char) (ACE::hex2byte (tmp [0]) << 4);
01646 byte |= ACE::hex2byte (tmp [1]);
01647
01648 buffer [len++] = byte;
01649 tmp += 2;
01650 }
01651
01652 if (tmp [0] && !ACE_OS::ace_isspace (tmp [0]))
01653 {
01654 throw ::CORBA::BAD_PARAM ();
01655 }
01656
01657
01658
01659
01660 int const byte_order = *(mb.rd_ptr ());
01661 mb.rd_ptr (1);
01662 mb.wr_ptr (len);
01663 TAO_InputCDR stream (&mb,
01664 byte_order,
01665 TAO_DEF_GIOP_MAJOR,
01666 TAO_DEF_GIOP_MINOR,
01667 this->orb_core_);
01668
01669 CORBA::Object_ptr objref = CORBA::Object::_nil ();
01670 stream >> objref;
01671 return objref;
01672 }
01673
01674
01675
01676
01677
01678 CORBA::Object_ptr
01679 CORBA::ORB::url_ior_string_to_object (const char* str)
01680 {
01681 TAO_MProfile mprofile;
01682
01683
01684
01685
01686
01687
01688 TAO_Connector_Registry *conn_reg = this->orb_core_->connector_registry ();
01689
01690 if (conn_reg->make_mprofile (str, mprofile) != 0)
01691 {
01692 throw ::CORBA::INV_OBJREF (
01693 CORBA::SystemException::_tao_minor_code (
01694 0,
01695 EINVAL),
01696 CORBA::COMPLETED_NO);
01697 }
01698
01699
01700 TAO_Stub *data = this->orb_core_->create_stub ((char *) 0, mprofile);
01701
01702 TAO_Stub_Auto_Ptr safe_objdata (data);
01703
01704
01705 CORBA::Object_ptr obj = this->orb_core_->create_object (safe_objdata.get ());
01706
01707 if (!CORBA::is_nil (obj))
01708 {
01709
01710 (void) safe_objdata.release ();
01711 }
01712
01713 return obj;
01714 }
01715
01716
01717
01718
01719
01720 #if !defined(CORBA_E_MICRO)
01721 CORBA::ValueFactory
01722 CORBA::ORB::register_value_factory (const char *repository_id,
01723 CORBA::ValueFactory factory)
01724 {
01725 this->check_shutdown ();
01726
01727 return this->orb_core_->register_value_factory (repository_id, factory);
01728 }
01729 #endif
01730
01731 #if !defined(CORBA_E_MICRO)
01732 void
01733 CORBA::ORB::unregister_value_factory (const char *repository_id)
01734 {
01735 this->check_shutdown ();
01736
01737 this->orb_core_->unregister_value_factory (repository_id);
01738 }
01739 #endif
01740
01741 #if !defined(CORBA_E_MICRO)
01742 CORBA::ValueFactory
01743 CORBA::ORB::lookup_value_factory (const char *repository_id)
01744 {
01745 this->check_shutdown ();
01746
01747 return this->orb_core_->lookup_value_factory (repository_id);
01748 }
01749 #endif
01750
01751 TAO_END_VERSIONED_NAMESPACE_DECL