1
// "ORB.cpp,v 1.461 2003/11/20 01:53:32 parsons Exp"
7
"ORB.cpp,v 1.461 2003/11/20 01:53:32 parsons Exp")
10
#include "Connector_Registry.h"
11
#include "IOR_Parser.h"
12
#include "Typecode_Constants.h"
15
#include "TAO_Internal.h"
17
#include "Dynamic_Adapter.h"
19
#include "default_ports.h"
20
#include "ORBInitInfo.h"
21
#include "ORBInitializer_Registry.h"
22
#include "TAO_Singleton_Manager.h"
23
#include "Policy_Manager.h"
24
#include "Valuetype_Adapter.h"
25
#include "IFR_Client_Adapter.h"
26
#include "CodecFactory_ORBInitializer.h"
27
#include "TypeCodeFactory_Adapter.h"
30
#if TAO_HAS_INTERCEPTORS == 1
31
# include "PICurrent_ORBInitializer.h" /* @@ This should go away! */
32
#endif /* TAO_HAS_INTERCEPTORS == 1 */
34
#include "ace/Dynamic_Service.h"
35
#include "ace/Arg_Shifter.h"
36
#include "ace/Reactor.h"
37
#include "ace/Argv_Type_Converter.h"
38
#include "ace/OS_NS_strings.h"
40
#if !defined (__ACE_INLINE__)
42
#endif /* ! __ACE_INLINE__ */
44
static const char ior_prefix[] = "IOR:";
46
// = Static initialization.
48
// Count of the number of ORBs.
49
int CORBA::ORB::orb_init_count_ = 0;
51
// ****************************************************************
53
CORBA::ORB::InvalidName::InvalidName (void)
54
: CORBA::UserException ("IDL:omg.org/CORBA/ORB/InvalidName:1.0",
59
// Destructor - all members are of self managing types.
60
CORBA::ORB::InvalidName::~InvalidName (void)
65
CORBA::ORB::InvalidName::InvalidName (const CORBA::ORB::InvalidName &exc)
66
: CORBA::UserException (exc._rep_id (),
71
// Assignment operator.
72
CORBA::ORB::InvalidName&
73
CORBA::ORB::InvalidName::operator= (const ::CORBA::ORB::InvalidName &_tao_excp)
75
this->UserException::operator= (_tao_excp);
79
CORBA::ORB::InvalidName *
80
CORBA::ORB::InvalidName::_downcast (CORBA::Exception *exc)
82
if (!ACE_OS::strcmp ("IDL:omg.org/CORBA/ORB/InvalidName:1.0",
85
return ACE_dynamic_cast (InvalidName *, exc);
93
CORBA::Exception *CORBA::ORB::InvalidName::_alloc (void)
95
CORBA::Exception *retval = 0;
96
ACE_NEW_RETURN (retval, ::CORBA::ORB::InvalidName, 0);
101
CORBA::ORB::InvalidName::_tao_duplicate (void) const
103
CORBA::Exception *result;
106
::CORBA::ORB::InvalidName (*this),
112
void CORBA::ORB::InvalidName::_raise (void) const
117
void CORBA::ORB::InvalidName::_tao_encode (
122
ACE_THROW (CORBA::MARSHAL ());
125
void CORBA::ORB::InvalidName::_tao_decode (
130
ACE_THROW (CORBA::MARSHAL ());
133
// ****************************************************************
135
CORBA::ORB::ORB (TAO_ORB_Core *orb_core)
138
, orb_core_ (orb_core)
139
, use_omg_ior_format_ (1)
144
CORBA::ORB::~ORB (void)
146
// This destructor is only invoked when the last ORB reference (not
147
// instance) is being destroyed.
151
CORBA::ORB::shutdown (CORBA::Boolean wait_for_completion
154
// We cannot lock the exceptions here. We need to propogate
155
// BAD_INV_ORDER exceptions if needed to the caller. Locking
156
// exceptions down would render us non-compliant with the spec.
157
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
160
this->orb_core ()->shutdown (wait_for_completion
161
ACE_ENV_ARG_PARAMETER);
165
CORBA::ORB::destroy (ACE_ENV_SINGLE_ARG_DECL)
167
if (this->orb_core () == 0)
169
// If the ORB_Core pointer is zero, assume that the ORB_Core has
172
// As defined by the CORBA 2.3 specification, throw a
173
// CORBA::OBJECT_NOT_EXIST exception if the ORB has been
174
// destroyed by the time an ORB function is called.
176
ACE_THROW (CORBA::OBJECT_NOT_EXIST (TAO_DEFAULT_MINOR_CODE,
177
CORBA::COMPLETED_NO));
180
if (TAO_debug_level >= 3)
182
ACE_DEBUG ((LM_DEBUG,
183
ACE_LIB_TEXT ("CORBA::ORB::destroy() has been called on ORB <%s>.\n"),
184
ACE_TEXT_CHAR_TO_TCHAR (this->orb_core ()->orbid ())));
187
this->orb_core ()->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
190
// Now invalidate the pointer to the ORB_Core that created this
196
CORBA::ORB::run (ACE_ENV_SINGLE_ARG_DECL)
198
this->run (0 ACE_ENV_ARG_PARAMETER);
202
CORBA::ORB::run (ACE_Time_Value &tv ACE_ENV_ARG_DECL)
204
this->run (&tv ACE_ENV_ARG_PARAMETER);
208
CORBA::ORB::run (ACE_Time_Value *tv
211
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
214
this->orb_core ()->run (tv, 0 ACE_ENV_ARG_PARAMETER);
218
CORBA::ORB::perform_work (ACE_ENV_SINGLE_ARG_DECL)
220
this->perform_work (0 ACE_ENV_ARG_PARAMETER);
224
CORBA::ORB::perform_work (ACE_Time_Value &tv ACE_ENV_ARG_DECL)
226
this->perform_work (&tv ACE_ENV_ARG_PARAMETER);
230
CORBA::ORB::perform_work (ACE_Time_Value *tv
233
// This method should not be called if the ORB has been shutdown.
234
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
237
this->orb_core ()->run (tv, 1 ACE_ENV_ARG_PARAMETER);
241
CORBA::ORB::work_pending (ACE_Time_Value &tv ACE_ENV_ARG_DECL)
243
// This method should not be called if the ORB has been shutdown.
244
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
245
ACE_CHECK_RETURN (0);
247
int result = this->orb_core_->reactor ()->work_pending (tv);
248
if (result == 0 || (result == -1 && errno == ETIME))
252
ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
258
CORBA::ORB::work_pending (ACE_ENV_SINGLE_ARG_DECL)
260
// This method should not be called if the ORB has been shutdown.
261
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
262
ACE_CHECK_RETURN (0);
264
int result = this->orb_core_->reactor ()->work_pending ();
269
ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
274
#if (TAO_HAS_MINIMUM_CORBA == 0)
277
CORBA::ORB::create_list (CORBA::Long count,
278
CORBA::NVList_ptr &new_list
281
ACE_ASSERT (CORBA::ULong (count) <= UINT_MAX);
283
// Create an empty list
284
ACE_NEW_THROW_EX (new_list,
287
CORBA::SystemException::_tao_minor_code (
288
TAO_DEFAULT_MINOR_CODE,
290
CORBA::COMPLETED_NO));
293
// If count is greater than 0, create a list of NamedValues.
296
new_list->max_ = (CORBA::ULong) count;
298
for (CORBA::Long i = 0; i < count; i++)
300
CORBA::NamedValue_ptr nv = 0;
301
ACE_NEW_THROW_EX (nv,
304
CORBA::SystemException::_tao_minor_code (
305
TAO_DEFAULT_MINOR_CODE,
307
CORBA::COMPLETED_NO));
310
new_list->values_.enqueue_tail (nv);
316
CORBA::ORB::create_exception_list (CORBA::ExceptionList_ptr &list
319
TAO_Dynamic_Adapter *dynamic_adapter =
320
ACE_Dynamic_Service<TAO_Dynamic_Adapter>::instance (
321
TAO_ORB_Core::dynamic_adapter_name ()
324
dynamic_adapter->create_exception_list (list
325
ACE_ENV_ARG_PARAMETER);
329
CORBA::ORB::create_operation_list (CORBA::OperationDef_ptr opDef,
330
CORBA::NVList_ptr &result
333
TAO_IFR_Client_Adapter *adapter =
334
ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
335
TAO_ORB_Core::ifr_client_adapter_name ()
340
ACE_THROW (CORBA::INTF_REPOS ());
343
adapter->create_operation_list (this,
346
ACE_ENV_ARG_PARAMETER);
351
CORBA::ORB::create_environment (CORBA::Environment_ptr &environment
354
ACE_NEW_THROW_EX (environment,
355
CORBA::Environment (),
357
CORBA::SystemException::_tao_minor_code (
358
TAO_DEFAULT_MINOR_CODE,
360
CORBA::COMPLETED_NO));
364
CORBA::ORB::create_named_value (CORBA::NamedValue_ptr &nv
367
ACE_NEW_THROW_EX (nv,
370
CORBA::SystemException::_tao_minor_code (
371
TAO_DEFAULT_MINOR_CODE,
373
CORBA::COMPLETED_NO));
376
// The following functions are not implemented - they just throw
377
// CORBA::NO_IMPLEMENT.
380
CORBA::ORB::get_service_information (
381
CORBA::ServiceType /* service_type */,
382
CORBA::ServiceInformation_out /* service_information */
385
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
386
CORBA::SystemException::_tao_minor_code (
387
TAO_DEFAULT_MINOR_CODE,
389
CORBA::COMPLETED_NO),
394
CORBA::ORB::create_context_list (CORBA::ContextList_ptr &
397
ACE_THROW (CORBA::NO_IMPLEMENT (
398
CORBA::SystemException::_tao_minor_code (
399
TAO_DEFAULT_MINOR_CODE,
401
CORBA::COMPLETED_NO));
405
CORBA::ORB::get_default_context (CORBA::Context_ptr &
408
ACE_THROW (CORBA::NO_IMPLEMENT (
409
CORBA::SystemException::_tao_minor_code (
410
TAO_DEFAULT_MINOR_CODE,
412
CORBA::COMPLETED_NO));
416
CORBA::ORB::send_multiple_requests_oneway (const CORBA::ORB::RequestSeq &
419
ACE_THROW (CORBA::NO_IMPLEMENT (
420
CORBA::SystemException::_tao_minor_code (
421
TAO_DEFAULT_MINOR_CODE,
423
CORBA::COMPLETED_NO));
427
CORBA::ORB::send_multiple_requests_deferred (const CORBA::ORB::RequestSeq &
430
ACE_THROW (CORBA::NO_IMPLEMENT (
431
CORBA::SystemException::_tao_minor_code (
432
TAO_DEFAULT_MINOR_CODE,
434
CORBA::COMPLETED_NO));
438
CORBA::ORB::get_next_response (CORBA::Request_ptr &
441
ACE_THROW (CORBA::NO_IMPLEMENT (
442
CORBA::SystemException::_tao_minor_code (
443
TAO_DEFAULT_MINOR_CODE,
445
CORBA::COMPLETED_NO));
449
CORBA::ORB::poll_next_response (ACE_ENV_SINGLE_ARG_DECL)
451
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
452
CORBA::SystemException::_tao_minor_code (
453
TAO_DEFAULT_MINOR_CODE,
455
CORBA::COMPLETED_NO),
459
// ****************************************************************
462
CORBA::ORB::create_struct_tc (
465
const CORBA::StructMemberSeq & members
468
ACE_THROW_SPEC ((CORBA::SystemException))
470
TAO_TypeCodeFactory_Adapter *adapter =
471
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
472
TAO_ORB_Core::typecodefactory_adapter_name ()
477
ACE_THROW_RETURN (CORBA::INTERNAL (),
481
return adapter->create_struct_tc (id,
484
ACE_ENV_ARG_PARAMETER);
488
CORBA::ORB::create_union_tc (
491
CORBA::TypeCode_ptr discriminator_type,
492
const CORBA::UnionMemberSeq & members
495
ACE_THROW_SPEC ((CORBA::SystemException))
497
TAO_TypeCodeFactory_Adapter *adapter =
498
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
499
TAO_ORB_Core::typecodefactory_adapter_name ()
504
ACE_THROW_RETURN (CORBA::INTERNAL (),
508
return adapter->create_union_tc (id,
512
ACE_ENV_ARG_PARAMETER);
516
CORBA::ORB::create_enum_tc (
519
const CORBA::EnumMemberSeq & members
522
ACE_THROW_SPEC ((CORBA::SystemException))
524
TAO_TypeCodeFactory_Adapter *adapter =
525
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
526
TAO_ORB_Core::typecodefactory_adapter_name ()
531
ACE_THROW_RETURN (CORBA::INTERNAL (),
535
return adapter->create_enum_tc (id,
538
ACE_ENV_ARG_PARAMETER);
542
CORBA::ORB::create_alias_tc (
545
CORBA::TypeCode_ptr original_type
548
ACE_THROW_SPEC ((CORBA::SystemException))
550
TAO_TypeCodeFactory_Adapter *adapter =
551
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
552
TAO_ORB_Core::typecodefactory_adapter_name ()
557
ACE_THROW_RETURN (CORBA::INTERNAL (),
561
return adapter->create_alias_tc (id,
564
ACE_ENV_ARG_PARAMETER);
568
CORBA::ORB::create_exception_tc (
571
const CORBA::StructMemberSeq & members
574
ACE_THROW_SPEC ((CORBA::SystemException))
576
TAO_TypeCodeFactory_Adapter *adapter =
577
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
578
TAO_ORB_Core::typecodefactory_adapter_name ()
583
ACE_THROW_RETURN (CORBA::INTERNAL (),
587
return adapter->create_exception_tc (id,
590
ACE_ENV_ARG_PARAMETER);
594
CORBA::ORB::create_interface_tc (
599
ACE_THROW_SPEC ((CORBA::SystemException))
601
TAO_TypeCodeFactory_Adapter *adapter =
602
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
603
TAO_ORB_Core::typecodefactory_adapter_name ()
608
ACE_THROW_RETURN (CORBA::INTERNAL (),
612
return adapter->create_interface_tc (id,
614
ACE_ENV_ARG_PARAMETER);
618
CORBA::ORB::create_string_tc (
622
ACE_THROW_SPEC ((CORBA::SystemException))
624
TAO_TypeCodeFactory_Adapter *adapter =
625
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
626
TAO_ORB_Core::typecodefactory_adapter_name ()
631
ACE_THROW_RETURN (CORBA::INTERNAL (),
635
return adapter->create_string_tc (bound
636
ACE_ENV_ARG_PARAMETER);
640
CORBA::ORB::create_wstring_tc (
644
ACE_THROW_SPEC ((CORBA::SystemException))
646
TAO_TypeCodeFactory_Adapter *adapter =
647
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
648
TAO_ORB_Core::typecodefactory_adapter_name ()
653
ACE_THROW_RETURN (CORBA::INTERNAL (),
657
return adapter->create_wstring_tc (bound
658
ACE_ENV_ARG_PARAMETER);
662
CORBA::ORB::create_fixed_tc (
663
CORBA::UShort digits,
667
ACE_THROW_SPEC ((CORBA::SystemException))
669
TAO_TypeCodeFactory_Adapter *adapter =
670
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
671
TAO_ORB_Core::typecodefactory_adapter_name ()
676
ACE_THROW_RETURN (CORBA::INTERNAL (),
680
return adapter->create_fixed_tc (digits,
682
ACE_ENV_ARG_PARAMETER);
686
CORBA::ORB::create_sequence_tc (
688
CORBA::TypeCode_ptr element_type
691
ACE_THROW_SPEC ((CORBA::SystemException))
693
TAO_TypeCodeFactory_Adapter *adapter =
694
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
695
TAO_ORB_Core::typecodefactory_adapter_name ()
700
ACE_THROW_RETURN (CORBA::INTERNAL (),
704
return adapter->create_sequence_tc (bound,
706
ACE_ENV_ARG_PARAMETER);
710
CORBA::ORB::create_array_tc (
712
CORBA::TypeCode_ptr element_type
715
ACE_THROW_SPEC ((CORBA::SystemException))
717
TAO_TypeCodeFactory_Adapter *adapter =
718
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
719
TAO_ORB_Core::typecodefactory_adapter_name ()
724
ACE_THROW_RETURN (CORBA::INTERNAL (),
728
return adapter->create_array_tc (length,
730
ACE_ENV_ARG_PARAMETER);
734
CORBA::ORB::create_value_tc (
737
CORBA::ValueModifier type_modifier,
738
CORBA::TypeCode_ptr concrete_base,
739
const CORBA::ValueMemberSeq & members
742
ACE_THROW_SPEC ((CORBA::SystemException))
744
TAO_TypeCodeFactory_Adapter *adapter =
745
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
746
TAO_ORB_Core::typecodefactory_adapter_name ()
751
ACE_THROW_RETURN (CORBA::INTERNAL (),
755
return adapter->create_value_tc (id,
760
ACE_ENV_ARG_PARAMETER);
764
CORBA::ORB::create_value_box_tc (
767
CORBA::TypeCode_ptr boxed_type
770
ACE_THROW_SPEC ((CORBA::SystemException))
772
TAO_TypeCodeFactory_Adapter *adapter =
773
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
774
TAO_ORB_Core::typecodefactory_adapter_name ()
779
ACE_THROW_RETURN (CORBA::INTERNAL (),
783
return adapter->create_value_box_tc (id,
786
ACE_ENV_ARG_PARAMETER);
790
CORBA::ORB::create_native_tc (
795
ACE_THROW_SPEC ((CORBA::SystemException))
797
TAO_TypeCodeFactory_Adapter *adapter =
798
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
799
TAO_ORB_Core::typecodefactory_adapter_name ()
804
ACE_THROW_RETURN (CORBA::INTERNAL (),
808
return adapter->create_native_tc (id,
810
ACE_ENV_ARG_PARAMETER);
814
CORBA::ORB::create_recursive_tc (
818
ACE_THROW_SPEC ((CORBA::SystemException))
820
TAO_TypeCodeFactory_Adapter *adapter =
821
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
822
TAO_ORB_Core::typecodefactory_adapter_name ()
827
ACE_THROW_RETURN (CORBA::INTERNAL (),
831
return adapter->create_recursive_tc (id
832
ACE_ENV_ARG_PARAMETER);
836
CORBA::ORB::create_abstract_interface_tc (
841
ACE_THROW_SPEC ((CORBA::SystemException))
843
TAO_TypeCodeFactory_Adapter *adapter =
844
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
845
TAO_ORB_Core::typecodefactory_adapter_name ()
850
ACE_THROW_RETURN (CORBA::INTERNAL (),
854
return adapter->create_abstract_interface_tc (id,
856
ACE_ENV_ARG_PARAMETER);
860
CORBA::ORB::create_local_interface_tc (
865
ACE_THROW_SPEC ((CORBA::SystemException))
867
TAO_TypeCodeFactory_Adapter *adapter =
868
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
869
TAO_ORB_Core::typecodefactory_adapter_name ()
874
ACE_THROW_RETURN (CORBA::INTERNAL (),
878
return adapter->create_local_interface_tc (id,
880
ACE_ENV_ARG_PARAMETER);
884
CORBA::ORB::create_component_tc (
889
ACE_THROW_SPEC ((CORBA::SystemException))
891
TAO_TypeCodeFactory_Adapter *adapter =
892
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
893
TAO_ORB_Core::typecodefactory_adapter_name ()
898
ACE_THROW_RETURN (CORBA::INTERNAL (),
902
return adapter->create_component_tc (id,
904
ACE_ENV_ARG_PARAMETER);
908
CORBA::ORB::create_home_tc (
913
ACE_THROW_SPEC ((CORBA::SystemException))
915
TAO_TypeCodeFactory_Adapter *adapter =
916
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
917
TAO_ORB_Core::typecodefactory_adapter_name ()
922
ACE_THROW_RETURN (CORBA::INTERNAL (),
926
return adapter->create_home_tc (id,
928
ACE_ENV_ARG_PARAMETER);
932
CORBA::ORB::create_event_tc (
935
CORBA::ValueModifier type_modifier,
936
CORBA::TypeCode_ptr concrete_base,
937
const CORBA::ValueMemberSeq &members
940
ACE_THROW_SPEC ((CORBA::SystemException))
942
TAO_TypeCodeFactory_Adapter *adapter =
943
ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
944
TAO_ORB_Core::typecodefactory_adapter_name ()
949
ACE_THROW_RETURN (CORBA::INTERNAL (),
953
return adapter->create_event_tc (id,
958
ACE_ENV_ARG_PARAMETER);
961
// ****************************************************************
963
#endif /* TAO_HAS_MINIMUM_CORBA */
966
CORBA::ORB::resolve_root_poa (ACE_ENV_SINGLE_ARG_DECL)
968
return this->orb_core_->root_poa (ACE_ENV_SINGLE_ARG_PARAMETER);
972
CORBA::ORB::resolve_poa_current (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
974
return this->orb_core_->poa_current ();
978
CORBA::ORB::resolve_policy_manager (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
980
#if (TAO_HAS_CORBA_MESSAGING == 1)
982
TAO_Policy_Manager *policy_manager =
983
this->orb_core_->policy_manager ();
985
if (policy_manager == 0)
987
return CORBA::Object::_nil ();
990
return CORBA::Object::_duplicate (policy_manager);
994
return CORBA::Object::_nil ();
996
#endif /* TAO_HAS_CORBA_MESSAGING == 1 */
1000
CORBA::ORB::resolve_policy_current (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
1003
#if (TAO_HAS_CORBA_MESSAGING == 1)
1005
TAO_Policy_Current &policy_current = this->orb_core_->policy_current ();
1006
return CORBA::Object::_duplicate (&policy_current);
1010
return CORBA::Object::_nil ();
1012
#endif /* TAO_HAS_CORBA_MESSAGING == 1 */
1016
CORBA::ORB::resolve_service (TAO_MCAST_SERVICEID mcast_service_id
1017
ACE_ENV_ARG_DECL_NOT_USED)
1019
const char * env_service_port [] =
1022
"TradingServicePort",
1023
"ImplRepoServicePort",
1024
"InterfaceRepoServicePort"
1027
u_short default_service_port [] =
1029
TAO_DEFAULT_NAME_SERVER_REQUEST_PORT,
1030
TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT,
1031
TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT,
1032
TAO_DEFAULT_INTERFACEREPO_SERVER_REQUEST_PORT
1035
CORBA::Object_var return_value = CORBA::Object::_nil ();
1037
// By now, the table filled in with -ORBInitRef arguments has been
1038
// checked. We only get here if the table didn't contain an initial
1039
// reference for the requested Service.
1041
// First, determine if the port was supplied on the command line
1043
this->orb_core_->orb_params ()->service_port (mcast_service_id);
1047
// Look for the port among our environment variables.
1048
const char *port_number =
1049
ACE_OS::getenv (env_service_port[mcast_service_id]);
1051
if (port_number != 0)
1052
port = (u_short) ACE_OS::atoi (port_number);
1054
port = default_service_port[mcast_service_id];
1057
// Set the port value in ORB_Params: modify the default mcast
1059
const char prefix[] = "mcast://:";
1061
char port_char[256];
1067
CORBA::String_var port_ptr =
1068
CORBA::string_alloc (ACE_static_cast (CORBA::ULong,
1069
ACE_OS::strlen ((const char *) port_char)));
1071
port_ptr = (const char *) port_char;
1073
CORBA::String_var def_init_ref =
1074
CORBA::string_alloc (sizeof (prefix) +
1075
ACE_static_cast (CORBA::ULong,
1076
ACE_OS::strlen (port_ptr.in ())) +
1079
ACE_OS::strcpy (def_init_ref.inout (), prefix);
1080
ACE_OS::strcat (def_init_ref.inout (), port_ptr.in ());
1081
ACE_OS::strcat (def_init_ref.inout (), "::");
1083
CORBA::String_var default_init_ref =
1084
this->orb_core_->orb_params ()->default_init_ref ();
1086
static const char mcast_prefix[] = "mcast://:::";
1088
if ((ACE_OS::strncmp (default_init_ref.in (),
1090
sizeof mcast_prefix - 1) == 0))
1092
this->orb_core_->orb_params ()->default_init_ref (def_init_ref.in ());
1095
return CORBA::Object::_nil ();
1099
CORBA::ORB::resolve_initial_references (const char *name
1102
return this->resolve_initial_references (name,
1104
ACE_ENV_ARG_PARAMETER);
1108
CORBA::ORB::resolve_initial_references (const char *name,
1109
ACE_Time_Value *timeout
1112
// This method should not be called if the ORB has been shutdown.
1113
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1114
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1116
if (ACE_OS::strcmp (name, TAO_OBJID_ROOTPOA) == 0)
1117
return this->resolve_root_poa (ACE_ENV_SINGLE_ARG_PARAMETER);
1119
else if (ACE_OS::strcmp (name, TAO_OBJID_POACURRENT) == 0)
1120
return this->resolve_poa_current (ACE_ENV_SINGLE_ARG_PARAMETER);
1122
else if (ACE_OS::strcmp (name, TAO_OBJID_POLICYMANAGER) == 0)
1123
return this->resolve_policy_manager (ACE_ENV_SINGLE_ARG_PARAMETER);
1125
else if (ACE_OS::strcmp (name, TAO_OBJID_POLICYCURRENT) == 0)
1126
return this->resolve_policy_current (ACE_ENV_SINGLE_ARG_PARAMETER);
1128
else if (ACE_OS::strcmp (name, TAO_OBJID_IORMANIPULATION) == 0)
1129
return this->orb_core ()->resolve_ior_manipulation (ACE_ENV_SINGLE_ARG_PARAMETER);
1131
else if (ACE_OS::strcmp (name, TAO_OBJID_IORTABLE) == 0)
1132
return this->orb_core ()->resolve_ior_table (ACE_ENV_SINGLE_ARG_PARAMETER);
1134
else if (ACE_OS::strcmp (name, TAO_OBJID_DYNANYFACTORY) == 0)
1135
return this->orb_core ()->resolve_dynanyfactory (ACE_ENV_SINGLE_ARG_PARAMETER);
1137
else if (ACE_OS::strcmp (name, TAO_OBJID_TYPECODEFACTORY) == 0)
1138
return this->orb_core ()->resolve_typecodefactory (ACE_ENV_SINGLE_ARG_PARAMETER);
1141
// -----------------------------------------------------------------
1143
// Search the object reference table. This search must occur before
1144
// the InitRef table search, since it may contain local objects.
1145
CORBA::Object_var result =
1146
this->orb_core ()->object_ref_table ().resolve_initial_references (
1148
ACE_ENV_ARG_PARAMETER);
1149
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1151
if (!CORBA::is_nil (result.in ()))
1152
return result._retn ();
1154
// -----------------------------------------------------------------
1156
// Check ORBInitRef options.
1158
ACE_CString object_id ((const char *) name);
1160
// Is the service name in the IOR Table.
1161
if (this->orb_core_->init_ref_map ()->find (object_id, ior) == 0)
1162
return this->string_to_object (ior.c_str ()
1163
ACE_ENV_ARG_PARAMETER);
1165
// Look for an environment variable called "<name>IOR".
1167
CORBA::String_var ior_env_var_name =
1168
CORBA::string_alloc (ACE_OS::strlen (name) + 3);
1170
ACE_OS::strcpy (ior_env_var_name.inout (),
1173
ACE_OS::strcat (ior_env_var_name.inout (),
1176
ACE_CString service_ior = ACE_OS::getenv (ior_env_var_name.in ());
1178
if (ACE_OS::strcmp (service_ior.c_str (), "") != 0 )
1181
this->string_to_object (service_ior.c_str()
1182
ACE_ENV_ARG_PARAMETER);
1183
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1185
return result._retn ();
1188
// May be trying the explicitly specified services and the well
1189
// known services should be tried first before falling on to default
1192
// Set the timeout value.
1193
this->set_timeout (timeout);
1195
if (ACE_OS::strcmp (name, TAO_OBJID_NAMESERVICE) == 0)
1197
result = this->resolve_service (NAMESERVICE
1198
ACE_ENV_ARG_PARAMETER);
1199
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1201
if (!CORBA::is_nil (result.in ()))
1202
return result._retn ();
1204
else if (ACE_OS::strcmp (name, TAO_OBJID_TRADINGSERVICE) == 0)
1206
result = this->resolve_service (TRADINGSERVICE
1207
ACE_ENV_ARG_PARAMETER);
1208
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1210
if (!CORBA::is_nil (result.in ()))
1211
return result._retn ();
1213
else if (ACE_OS::strcmp (name, TAO_OBJID_IMPLREPOSERVICE) == 0)
1215
result = this->resolve_service (IMPLREPOSERVICE
1216
ACE_ENV_ARG_PARAMETER);
1217
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1219
if (!CORBA::is_nil (result.in ()))
1220
return result._retn ();
1222
else if (ACE_OS::strcmp (name, TAO_OBJID_INTERFACEREP) == 0)
1224
result = this->resolve_service (INTERFACEREPOSERVICE
1225
ACE_ENV_ARG_PARAMETER);
1226
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1228
if (!CORBA::is_nil (result.in ()))
1229
return result._retn ();
1232
// Is not one of the well known services, try to find it in the
1233
// InitRef table....check the defaultinitref values also.
1235
result = this->orb_core ()->resolve_rir (name ACE_ENV_ARG_PARAMETER);
1236
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1238
if (!CORBA::is_nil (result.in ()))
1239
return result._retn ();
1240
// -----------------------------------------------------------------
1242
ACE_THROW_RETURN (CORBA::ORB::InvalidName (), CORBA::Object::_nil ());
1246
CORBA::ORB::register_initial_reference (const char * id,
1247
CORBA::Object_ptr obj
1250
TAO_Object_Ref_Table &table = this->orb_core_->object_ref_table ();
1252
table.register_initial_reference (id,
1254
ACE_ENV_ARG_PARAMETER);
1259
CORBA::ORB::ObjectIdList_ptr
1260
CORBA::ORB::list_initial_services (ACE_ENV_SINGLE_ARG_DECL)
1262
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1263
ACE_CHECK_RETURN (0);
1266
this->orb_core ()->list_initial_references (ACE_ENV_SINGLE_ARG_PARAMETER);
1270
CORBA::ORB::check_shutdown (ACE_ENV_SINGLE_ARG_DECL)
1272
if (this->orb_core () != 0)
1274
this->orb_core ()->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1279
// If the ORB_Core pointer is zero, assume that the ORB_Core has
1282
// As defined by the CORBA 2.3 specification, throw a
1283
// CORBA::OBJECT_NOT_EXIST exception if the ORB has been
1284
// destroyed by the time an ORB function is called.
1286
ACE_THROW (CORBA::OBJECT_NOT_EXIST (TAO_DEFAULT_MINOR_CODE,
1287
CORBA::COMPLETED_NO));
1291
// ****************************************************************
1294
CORBA::ORB::init_orb_globals (ACE_ENV_SINGLE_ARG_DECL)
1296
// This method should be invoked atomically. It is the caller's
1297
// responsibility to ensure that this condition is satisfied.
1299
// Prevent multiple initializations.
1300
if (CORBA::ORB::orb_init_count_ != 0)
1306
CORBA::ORB::orb_init_count_++;
1309
// initialize the system TypeCodes
1310
TAO::TypeCode_Constants::init ();
1312
// initialize the system exceptions
1313
TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_PARAMETER);
1316
#if defined (ACE_HAS_EXCEPTIONS)
1317
// This must be done after the system TypeCodes and Exceptions have
1318
// been initialized. An unexpected exception will cause TAO's
1319
// unexpected exception handler to be called. That handler
1320
// transforms all unexpected exceptions to CORBA::UNKNOWN, which of
1321
// course requires the TypeCode constants and system exceptions to
1322
// have been initialized.
1323
TAO_Singleton_Manager::instance ()->_set_unexpected (
1324
CORBA::ORB::_tao_unexpected_exception);
1325
#endif /* ACE_HAS_EXCEPTIONS */
1327
// Verify some of the basic implementation requirements. This test
1328
// gets optimized away by a decent compiler (or else the rest of the
1331
// NOTE: we still "just" assume that native floating point is IEEE.
1332
if (sizeof (CORBA::Short) != 2
1333
|| sizeof (CORBA::Long) != 4
1334
|| sizeof (CORBA::LongLong) != 8
1335
|| sizeof (CORBA::Float) != 4
1336
|| sizeof (CORBA::Double) != 8
1337
|| sizeof (CORBA::LongDouble) != 16
1338
|| sizeof (CORBA::WChar) < 2
1339
|| sizeof (void *) != ACE_SIZEOF_VOID_P)
1341
ACE_DEBUG ((LM_DEBUG,
1342
"%s; ERROR: unexpected basic type size; "
1343
"s:%d l:%d ll:%d f:%d d:%d ld:%d wc:%d v:%d\n"
1344
"please reconfigure TAO\n",
1346
sizeof (CORBA::Short),
1347
sizeof (CORBA::Long),
1348
sizeof (CORBA::LongLong),
1349
sizeof (CORBA::Float),
1350
sizeof (CORBA::Double),
1351
sizeof (CORBA::LongDouble),
1352
sizeof (CORBA::WChar),
1355
ACE_THROW (CORBA::INITIALIZE ());
1358
// Register the CodecFactory ORBInitializer.
1359
PortableInterceptor::ORBInitializer_ptr tmp_cf_initializer;
1360
ACE_NEW_THROW_EX (tmp_cf_initializer,
1361
TAO_CodecFactory_ORBInitializer,
1363
CORBA::SystemException::_tao_minor_code (
1364
TAO_DEFAULT_MINOR_CODE,
1366
CORBA::COMPLETED_NO));
1369
PortableInterceptor::ORBInitializer_var cf_initializer =
1372
PortableInterceptor::register_orb_initializer (cf_initializer.in ()
1373
ACE_ENV_ARG_PARAMETER);
1376
// -------------------------------------------------------------
1377
// @@ These ORB initializer instantiations should go away. They
1378
// should be registered via the service configurator, for
1381
#if TAO_HAS_INTERCEPTORS == 1
1382
PortableInterceptor::ORBInitializer_ptr temp_pi_initializer =
1383
PortableInterceptor::ORBInitializer::_nil ();
1384
PortableInterceptor::ORBInitializer_var pi_initializer;
1386
// Register the PICurrent ORBInitializer.
1387
ACE_NEW_THROW_EX (temp_pi_initializer,
1388
TAO_PICurrent_ORBInitializer,
1390
CORBA::SystemException::_tao_minor_code (
1391
TAO_DEFAULT_MINOR_CODE,
1393
CORBA::COMPLETED_NO));
1396
pi_initializer = temp_pi_initializer;
1398
PortableInterceptor::register_orb_initializer (pi_initializer.in ()
1399
ACE_ENV_ARG_PARAMETER);
1401
#endif /* TAO_HAS_INTERCEPTORS == 1 */
1404
void CORBA::ORB::_tao_unexpected_exception (void)
1406
#if defined(ACE_HAS_EXCEPTIONS)
1407
throw CORBA::UNKNOWN ();
1409
// Nothing to do, this will be handled by the ORB core when sending
1410
// the exception back to the client...
1411
#endif /* ACE_HAS_EXCEPTIONS */
1415
CORBA::ORB::_tao_ft_client_id (void)
1417
return this->orb_core ()->fault_tolerance_service ().client_id ();
1421
CORBA::ORB::_tao_ft_client_id (const char *id)
1423
this->orb_core ()->fault_tolerance_service ().client_id (id);
1427
CORBA::ORB::_tao_make_ORB (TAO_ORB_Core * orb_core)
1429
CORBA::ORB_ptr orb = CORBA::ORB::_nil ();
1431
ACE_NEW_RETURN (orb,
1432
CORBA::ORB (orb_core),
1433
CORBA::ORB::_nil ());
1438
// ****************************************************************
1440
// ORB initialization, per OMG document 98-12-01.
1443
CORBA::ORB_init (int &argc,
1445
const char *orb_name)
1447
// Make sure TAO's singleton manager is initialized.
1449
// We need to initialize before TAO_default_environment() is called
1450
// since that call instantiates a TAO_TSS_Singleton.
1451
if (TAO_Singleton_Manager::instance ()->init () == -1)
1453
return CORBA::ORB::_nil ();
1456
return CORBA::ORB_init (argc,
1459
TAO_default_environment ());
1463
CORBA::ORB_init (int &argc,
1466
CORBA::Environment &ACE_TRY_ENV)
1468
// This ugly macro will go away once we've merged the two ORB_init's.
1469
ACE_UNUSED_ARG(ACE_TRY_ENV); // FUZZ: ignore check_for_ace_check
1471
// Use this string variable to hold the orbid
1472
ACE_CString orbid_string = orbid;
1474
// Copy command line parameter not to use original.
1475
ACE_Argv_Type_Converter command_line(argc, argv);
1477
// Using ACE_Static_Object_Lock::instance() precludes <ORB_init>
1478
// from being called within a static object CTOR.
1479
ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, guard,
1480
*ACE_Static_Object_Lock::instance (),
1481
CORBA::ORB::_nil ()));
1483
// Make sure TAO's singleton manager is initialized.
1484
if (TAO_Singleton_Manager::instance ()->init () == -1)
1486
return CORBA::ORB::_nil ();
1489
CORBA::ORB::init_orb_globals (ACE_ENV_SINGLE_ARG_PARAMETER);
1490
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1492
// Make sure the following is done after the global ORB
1493
// initialization since we need to have exceptions initialized.
1495
// It doesn't make sense for argc to be zero and argv to be
1496
// non-empty/zero, or for argc to be greater than zero and argv be
1499
(command_line.get_TCHAR_argv ()
1500
? (*command_line.get_TCHAR_argv ()
1501
? ACE_OS::strlen (*command_line.get_TCHAR_argv ())
1505
if ((command_line.get_argc () == 0 && argv0_len != 0)
1506
|| (command_line.get_argc () != 0
1507
&& (command_line.get_TCHAR_argv () == 0
1508
|| command_line.get_TCHAR_argv ()[0] == 0)))
1510
ACE_THROW_RETURN (CORBA::BAD_PARAM (
1511
CORBA::SystemException::_tao_minor_code (
1512
TAO_DEFAULT_MINOR_CODE,
1514
CORBA::COMPLETED_NO),
1515
CORBA::ORB::_nil ());
1518
if (orbid_string.length () == 0)
1520
ACE_Arg_Shifter arg_shifter (command_line.get_argc (),
1521
command_line.get_TCHAR_argv ());
1523
while (arg_shifter.is_anything_left ())
1525
const ACE_TCHAR *current_arg = arg_shifter.get_current ();
1527
const ACE_TCHAR orbid_opt[] = ACE_TEXT ("-ORBid");
1528
size_t orbid_len = ACE_OS::strlen (orbid_opt);
1529
if (ACE_OS::strcasecmp (current_arg,
1532
arg_shifter.consume_arg ();
1533
if (arg_shifter.is_parameter_next ())
1536
ACE_TEXT_ALWAYS_CHAR (arg_shifter.get_current ());
1537
arg_shifter.consume_arg ();
1540
else if (ACE_OS::strncasecmp (current_arg, orbid_opt,
1543
arg_shifter.consume_arg ();
1544
// The rest of the argument is the ORB id...
1545
// but we should skip an optional space...
1546
if (current_arg[orbid_len] == ' ')
1548
ACE_TEXT_ALWAYS_CHAR (current_arg + orbid_len + 1);
1550
orbid_string = ACE_TEXT_ALWAYS_CHAR (current_arg + orbid_len);
1553
arg_shifter.ignore_arg ();
1559
TAO_ORB_Table::instance ()->find (orbid_string.c_str ());
1561
// The ORB was initialized already, just return that one!
1564
if (oc->has_shutdown ())
1566
// As defined by the CORBA 2.3 specification, throw a
1567
// CORBA::BAD_INV_ORDER exception with minor code 4 if the ORB
1568
// has shutdown by the time an ORB function is called.
1570
// @@ Does the BAD_INV_ORDER exception apply here?
1573
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 4,
1574
CORBA::COMPLETED_NO),
1575
CORBA::ORB::_nil ());
1578
return CORBA::ORB::_duplicate (oc->orb ());
1581
// An ORB corresponding to the desired ORBid doesn't exist so create
1583
ACE_NEW_THROW_EX (oc,
1584
TAO_ORB_Core (orbid_string.c_str ()),
1586
CORBA::SystemException::_tao_minor_code (
1587
TAO_DEFAULT_MINOR_CODE,
1589
CORBA::COMPLETED_NO));
1590
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1592
// The ORB table increases the reference count on the ORB Core so do
1593
// not release it here. Allow the TAO_ORB_Core_Auto_Ptr do decrease
1594
// the reference on the ORB Core when it goes out of scope.
1595
TAO_ORB_Core_Auto_Ptr safe_oc (oc);
1597
// Initialize the Service Configurator. This must occur before the
1598
// ORBInitializer::pre_init() method is invoked on each registered
1600
int result = TAO_Internal::open_services (command_line.get_argc (),
1601
command_line.get_TCHAR_argv ());
1603
// Check for errors returned from <TAO_Internal::open_services>.
1604
if (result != 0 && errno != ENOENT)
1606
ACE_ERROR ((LM_ERROR,
1607
ACE_TEXT ("(%P|%t) %p\n"),
1608
ACE_TEXT ("Unable to initialize the ")
1609
ACE_TEXT ("Service Configurator")));
1610
ACE_THROW_RETURN (CORBA::INITIALIZE (
1611
CORBA::SystemException::_tao_minor_code (
1612
TAO_ORB_CORE_INIT_LOCATION_CODE,
1614
CORBA::COMPLETED_NO),
1615
CORBA::ORB::_nil ());
1618
// Run the registered ORB initializers, and initialize the ORB_Core.
1619
TAO_ORBInitInfo *orb_init_info_temp;
1620
ACE_NEW_THROW_EX (orb_init_info_temp,
1621
TAO_ORBInitInfo (safe_oc.get (),
1622
command_line.get_argc(),
1623
command_line.get_ASCII_argv()),
1625
CORBA::SystemException::_tao_minor_code (
1626
TAO_DEFAULT_MINOR_CODE,
1628
CORBA::COMPLETED_NO));
1629
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1631
// This ORBInitInfo instance is only valid for the duration of this
1632
// ORB's initialization.
1633
PortableInterceptor::ORBInitInfo_var orb_init_info =
1636
// Call the ORBInitializer::pre_init() on each registered ORB
1638
TAO_ORBInitializer_Registry::instance ()->pre_init (orb_init_info.in ()
1639
ACE_ENV_ARG_PARAMETER);
1640
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1642
// Initialize the ORB Core instance.
1643
result = safe_oc->init (command_line.get_argc(),
1644
command_line.get_ASCII_argv()
1645
ACE_ENV_ARG_PARAMETER);
1646
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1648
// Check for errors and return nil pseudo-reference on error.
1650
ACE_THROW_RETURN (CORBA::BAD_PARAM (
1651
CORBA::SystemException::_tao_minor_code (
1652
TAO_DEFAULT_MINOR_CODE,
1654
CORBA::COMPLETED_NO),
1655
CORBA::ORB::_nil ());
1657
// Call the ORBInitializer::post_init() on each registered ORB
1659
TAO_ORBInitializer_Registry::instance ()->post_init (orb_init_info.in ()
1660
ACE_ENV_ARG_PARAMETER);
1661
ACE_CHECK_RETURN (CORBA::ORB::_nil ());
1663
#if TAO_HAS_INTERCEPTORS == 1
1664
oc->pi_current ()->initialize (oc,
1665
orb_init_info_temp->slot_count ());
1666
#endif /* TAO_HAS_INTERCEPTORS == 1 */
1668
// Invalidate the ORBInitInfo instance to prevent future
1669
// modifications to the ORB. This behavior complies with the
1670
// PortableInterceptor specification.
1671
orb_init_info_temp->invalidate ();
1673
if (TAO_debug_level >= 3)
1674
ACE_DEBUG ((LM_DEBUG,
1675
ACE_LIB_TEXT("TAO (%P|%t) created new ORB <%s>\n"),
1676
ACE_TEXT_CHAR_TO_TCHAR (orbid_string.c_str ())));
1678
// Before returning remember to store the ORB into the table...
1679
if (TAO_ORB_Table::instance ()->bind (orbid_string.c_str (),
1680
safe_oc.get ()) != 0)
1681
ACE_THROW_RETURN (CORBA::INTERNAL (TAO_DEFAULT_MINOR_CODE,
1682
CORBA::COMPLETED_NO),
1683
CORBA::ORB::_nil ());
1685
// Return a duplicate since the ORB_Core should release the last
1686
// reference to the ORB.
1687
return CORBA::ORB::_duplicate (oc->orb ());
1690
// ****************************************************************
1692
// Object reference stringification.
1694
CORBA::ORB::object_to_string (CORBA::Object_ptr obj
1697
// This method should not be called if the ORB has been shutdown.
1698
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1699
ACE_CHECK_RETURN (0);
1701
if (!CORBA::is_nil (obj) && obj->_is_local ())
1702
// @@ The CCM spec says one minor code, and the CORBA spec says
1703
// another. Which is the correct one?
1704
ACE_THROW_RETURN (CORBA::MARSHAL (CORBA::OMGVMCID | 4,
1705
CORBA::COMPLETED_NO),
1709
// Application writer controls what kind of objref strings they get,
1710
// maybe along with other things, by how they initialize the ORB.
1712
if (use_omg_ior_format_)
1714
// By default, orbs use IOR strings; these are ugly (and error
1715
// prone) but specified by CORBA.
1717
// XXX there should be a simple way to reuse this code in other
1718
// ORB implementations ...
1720
#if defined (ACE_HAS_PURIFY)
1721
char buf [ACE_CDR::DEFAULT_BUFSIZE] = { 0 };
1723
// Avoid the initialization overhead if not compiling with
1724
// support for Purify. There is no need to actually perform
1725
// initialization otherwise.
1726
char buf [ACE_CDR::DEFAULT_BUFSIZE];
1727
#endif /* ACE_HAS_PURIFY */
1729
TAO_OutputCDR cdr (buf, sizeof buf,
1730
TAO_ENCAP_BYTE_ORDER,
1731
this->orb_core_->output_cdr_buffer_allocator (),
1732
this->orb_core_->output_cdr_dblock_allocator (),
1733
this->orb_core_->output_cdr_msgblock_allocator (),
1734
this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
1736
TAO_DEF_GIOP_MINOR);
1738
// There is no translator currently available for stringifying an object
1739
// reference, since there is no transport with which to choose an NCS/TCS
1742
// support limited oref ACE_OS::strcmp.
1743
(void) ACE_OS::memset (buf, 0, sizeof (buf));
1745
// Marshal the objref into an encapsulation bytestream.
1746
(void) cdr.write_octet (TAO_ENCAP_BYTE_ORDER);
1747
if ((cdr << obj) == 0)
1748
ACE_THROW_RETURN (CORBA::MARSHAL (), 0);
1750
// Now hexify the encapsulated CDR data into a string, and
1751
// return that string.
1753
size_t total_len = cdr.total_length ();
1756
ACE_ALLOCATOR_RETURN (cp,
1757
CORBA::string_alloc (sizeof ior_prefix
1759
ACE_static_cast (CORBA::ULong,
1763
CORBA::String_var string = cp;
1765
ACE_OS::strcpy (cp, ior_prefix);
1766
cp += sizeof (ior_prefix) - 1;
1768
for (const ACE_Message_Block *i = cdr.begin ();
1772
const char *bytes = i->rd_ptr ();
1773
size_t len = i->length ();
1777
*cp++ = ACE::nibble2hex ((*bytes) >> 4);
1778
*cp++ = ACE::nibble2hex (*bytes);
1782
// Null terminate the string..
1785
return string._retn ();
1789
// It is perfectly valid to marshal a nil object reference.
1790
// However, it is not possible to convert a nil object reference
1791
// to a URL IOR, so throw an exception.
1792
if (CORBA::is_nil (obj) || obj->_stubobj () == 0)
1794
if (TAO_debug_level > 0)
1795
ACE_ERROR ((LM_ERROR,
1796
ACE_TEXT ("Nil object reference or TAO_Stub ")
1797
ACE_TEXT ("pointer is zero when converting\n")
1798
ACE_TEXT ("object reference to URL IOR.\n")));
1800
ACE_THROW_RETURN (CORBA::MARSHAL (
1801
CORBA::SystemException::_tao_minor_code (
1802
TAO_DEFAULT_MINOR_CODE,
1804
CORBA::COMPLETED_NO),
1808
TAO_MProfile &mp = obj->_stubobj ()->base_profiles ();
1810
if (mp.profile_count () == 0)
1812
if (TAO_debug_level > 0)
1813
ACE_ERROR ((LM_ERROR,
1814
ACE_TEXT ("(%P|%t) Cannot stringify given ")
1815
ACE_TEXT ("object. No profiles.\n")));
1818
ACE_THROW_RETURN (CORBA::MARSHAL (
1819
CORBA::SystemException::_tao_minor_code (
1820
TAO_DEFAULT_MINOR_CODE,
1822
CORBA::COMPLETED_NO),
1826
// For now we just use the first profile.
1827
TAO_Profile *profile = mp.get_profile (0);
1829
return profile->to_string (ACE_ENV_SINGLE_ARG_PARAMETER);
1833
// Destringify arbitrary objrefs. This method is called from
1834
// <resolve_name_service> with an IOR <multicast_to_service>.
1837
CORBA::ORB::string_to_object (const char *str
1840
// This method should not be called if the ORB has been shutdown.
1841
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1842
ACE_CHECK_RETURN (CORBA::Object::_nil ());
1844
// Check for NULL pointer
1846
ACE_THROW_RETURN (CORBA::INV_OBJREF (
1847
CORBA::SystemException::_tao_minor_code (
1848
TAO_DEFAULT_MINOR_CODE,
1850
CORBA::COMPLETED_NO),
1851
CORBA::Object::_nil ());
1853
TAO_IOR_Parser *ior_parser =
1854
this->orb_core_->parser_registry ()->match_parser (str);
1856
if (ior_parser != 0)
1858
return ior_parser->parse_string (str,
1860
ACE_ENV_ARG_PARAMETER);
1864
if (ACE_OS::strncmp (str,
1866
sizeof ior_prefix - 1) == 0)
1867
return this->ior_string_to_object (str + sizeof ior_prefix - 1
1868
ACE_ENV_ARG_PARAMETER);
1870
return this->url_ior_string_to_object (str
1871
ACE_ENV_ARG_PARAMETER);
1874
// ****************************************************************
1877
CORBA::ORB::id (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
1879
return CORBA::string_dup (this->orb_core_->orbid ());
1882
// ****************************************************************
1885
CORBA::ORB::create_policy (CORBA::PolicyType type,
1886
const CORBA::Any& val
1888
ACE_THROW_SPEC ((CORBA::SystemException,
1889
CORBA::PolicyError))
1891
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1892
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
1894
// Attempt to obtain the policy from the policy factory registry.
1896
this->orb_core_->policy_factory_registry ()->create_policy (
1899
ACE_ENV_ARG_PARAMETER);
1903
CORBA::ORB::_create_policy (CORBA::PolicyType type
1905
ACE_THROW_SPEC ((CORBA::SystemException,
1906
CORBA::PolicyError))
1908
this->check_shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
1909
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
1911
// Attempt to obtain the policy from the policy factory registry.
1913
this->orb_core_->policy_factory_registry ()->_create_policy (
1915
ACE_ENV_ARG_PARAMETER);
1918
// Destringify OMG-specified "IOR" string.
1920
// XXX there should be a simple way to reuse this code in other ORB
1921
// implementations ...
1924
CORBA::ORB::ior_string_to_object (const char *str
1927
// Unhex the bytes, and make a CDR deencapsulation stream from the
1929
ACE_Message_Block mb (ACE_OS::strlen ((char *) str) / 2 + 1
1930
+ ACE_CDR::MAX_ALIGNMENT + 1);
1932
ACE_CDR::mb_align (&mb);
1934
char *buffer = mb.rd_ptr ();
1935
const char *tmp = str;
1938
while (tmp [0] && tmp [1])
1940
// Some platforms define 'byte' as a macro, solve the problem
1945
if (!(isxdigit (tmp [0]) && isxdigit (tmp [1])))
1948
byte = (u_char) (ACE::hex2byte (tmp [0]) << 4);
1949
byte |= ACE::hex2byte (tmp [1]);
1951
buffer [len++] = byte;
1955
if (tmp [0] && !isspace (tmp [0]))
1957
ACE_THROW_RETURN (CORBA::BAD_PARAM (),
1958
CORBA::Object::_nil ());
1961
// Create deencapsulation stream ... then unmarshal objref from that
1964
int byte_order = *(mb.rd_ptr ());
1967
TAO_InputCDR stream (&mb,
1973
CORBA::Object_ptr objref = CORBA::Object::_nil ();
1978
// ****************************************************************
1980
// Convert an URL style IOR in an object
1983
CORBA::ORB::url_ior_string_to_object (const char* str
1986
TAO_MProfile mprofile;
1987
// It is safe to declare this on the stack since the contents of
1988
// mprofile get copied. No memory is allocated for profile storage
1989
// here. The Connector Registry will determine the exact number
1990
// of profiles and tell the MProfile object to allocate enough memory
1991
// to hold them all.
1993
TAO_Connector_Registry *conn_reg =
1994
this->orb_core_->connector_registry (ACE_ENV_SINGLE_ARG_PARAMETER);
1995
ACE_CHECK_RETURN (0);
1998
conn_reg->make_mprofile (str,
2000
ACE_ENV_ARG_PARAMETER);
2001
ACE_CHECK_RETURN (CORBA::Object::_nil ()); // Return nil.
2005
ACE_THROW_RETURN (CORBA::INV_OBJREF (
2006
CORBA::SystemException::_tao_minor_code (
2007
TAO_DEFAULT_MINOR_CODE,
2009
CORBA::COMPLETED_NO),
2010
CORBA::Object::_nil ());
2013
// Now make the TAO_Stub.
2014
TAO_Stub *data = this->orb_core_->create_stub ((char *) 0,
2016
ACE_ENV_ARG_PARAMETER);
2017
ACE_CHECK_RETURN (CORBA::Object::_nil ());
2019
TAO_Stub_Auto_Ptr safe_objdata (data);
2021
// Figure out if the servant is collocated.
2022
CORBA::Object_ptr obj =
2023
this->orb_core_->create_object (safe_objdata.get ());
2024
if (CORBA::is_nil (obj))
2025
return CORBA::Object::_nil ();
2027
// Transfer ownership to the CORBA::Object
2028
(void) safe_objdata.release ();
2033
// ****************************************************************
2036
CORBA::ORB::_optimize_collocation_objects (CORBA::Boolean opt)
2038
if (this->orb_core_ != 0)
2039
this->orb_core_->optimize_collocation_objects (opt);
2043
CORBA::ORB::_optimize_collocation_objects (void) const
2045
if (this->orb_core_ != 0)
2046
return this->orb_core_->optimize_collocation_objects ();
2048
return 0; // Need to return something
2052
CORBA::ORB::get_timeout (void)
2054
return this->timeout_;
2058
CORBA::ORB::set_timeout (ACE_Time_Value *timeout)
2060
this->timeout_ = timeout;
2063
// *************************************************************
2064
// Valuetype factory operations
2065
// *************************************************************
2068
CORBA::ORB::register_value_factory (const char *repository_id,
2069
CORBA::ValueFactory factory
2072
// %! guard, and ACE_Null_Mutex in the map
2073
// do _add_ref here not in map->rebind
2075
if (this->orb_core ()->valuetype_adapter () == 0)
2078
this->orb_core ()->valuetype_adapter () =
2079
ACE_Dynamic_Service<TAO_Valuetype_Adapter>::instance (
2080
TAO_ORB_Core::valuetype_adapter_name ()
2083
if (this->orb_core ()->valuetype_adapter () == 0)
2085
ACE_THROW_RETURN (CORBA::INTERNAL (),
2091
this->orb_core ()->valuetype_adapter ()->vf_map_rebind (repository_id,
2094
if (result == 0) // No previous factory found
2102
ACE_THROW_RETURN (CORBA::MARSHAL (),
2106
return factory; // previous factory was found
2110
CORBA::ORB::unregister_value_factory (const char *repository_id
2111
ACE_ENV_ARG_DECL_NOT_USED)
2113
if (this->orb_core ()->valuetype_adapter ())
2115
// Dont care whther it was successful or not!
2116
(void) this->orb_core ()->valuetype_adapter ()->vf_map_unbind (repository_id);
2121
CORBA::ORB::lookup_value_factory (const char *repository_id
2124
if (this->orb_core ()->valuetype_adapter () == 0)
2126
this->orb_core ()->valuetype_adapter () =
2127
ACE_Dynamic_Service<TAO_Valuetype_Adapter>::instance (
2128
TAO_ORB_Core::valuetype_adapter_name ()
2131
if (this->orb_core ()->valuetype_adapter () == 0)
2133
ACE_THROW_RETURN (CORBA::INTERNAL (),
2138
return this->orb_core ()->valuetype_adapter ()->vf_map_find (repository_id);
2141
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
2143
template class TAO_Pseudo_Var_T<CORBA::ORB>;
2144
template class TAO_Pseudo_Out_T<CORBA::ORB, CORBA::ORB_var>;
2146
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
2148
#pragma instantiate TAO_Pseudo_Var_T<CORBA::ORB>
2149
#pragma instantiate TAO_Pseudo_Out_T<CORBA::ORB, CORBA::ORB_var>
2151
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */