3 // Copyright 1994-1995 by Sun Microsystems Inc.
4 // Copyright 1997-2002 by Washington University
7 // ORB: CORBA::Object operations
9 #include "tao/Object.h"
11 #include "tao/Profile.h"
12 #include "tao/ORB_Core.h"
13 #include "tao/Connector_Registry.h"
14 #include "tao/LocateRequest_Invocation_Adapter.h"
15 #include "tao/debug.h"
16 #include "tao/Dynamic_Adapter.h"
17 #include "tao/IFR_Client_Adapter.h"
18 #include "tao/Remote_Object_Proxy_Broker.h"
20 #include "tao/SystemException.h"
21 #include "tao/PolicyC.h"
23 #include "ace/Dynamic_Service.h"
24 #include "ace/OS_NS_string.h"
25 #include "ace/CORBA_macros.h"
27 #if !defined (__ACE_INLINE__)
28 # include "tao/Object.inl"
29 #endif /* ! __ACE_INLINE__ */
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 CORBA::Object::~Object ()
35 if (this->protocol_proxy_
)
36 (void) this->protocol_proxy_
->_decr_refcnt ();
39 CORBA::Object::Object (TAO_Stub
* protocol_proxy
,
40 CORBA::Boolean collocated
,
41 TAO_Abstract_ServantBase
* servant
,
42 TAO_ORB_Core
*orb_core
)
45 , is_evaluated_ (true)
47 , orb_core_ (orb_core
)
48 , protocol_proxy_ (protocol_proxy
)
50 /// This constructor should not be called when the protocol proxy is
51 /// null ie. when the object is a LocalObject. Assert that
53 ACE_ASSERT (this->protocol_proxy_
!= nullptr);
55 if (this->orb_core_
== nullptr)
56 this->orb_core_
= this->protocol_proxy_
->orb_core ();
58 // Set the collocation marker on the stub. This may not be news to it.
59 // This may also change the stub's object proxy broker.
60 this->protocol_proxy_
->is_collocated (collocated
);
62 // Set the collocated servant pointer (null if not collocated) on the stub.
63 this->protocol_proxy_
->collocated_servant (servant
);
66 CORBA::Object::Object (IOP::IOR
*ior
,
67 TAO_ORB_Core
*orb_core
)
70 , is_evaluated_ (false)
72 , orb_core_ (orb_core
)
73 , protocol_proxy_ (nullptr)
77 // Too lazy to do this check in every method properly! This is useful
78 // only for lazily evaluated IOR's
79 #define TAO_OBJECT_IOR_EVALUATE \
80 if (!this->is_evaluated_) \
82 ACE_GUARD (TAO_SYNCH_MUTEX , mon, this->object_init_lock_); \
83 if (!this->is_evaluated_) \
84 CORBA::Object::tao_object_initialize (this); \
87 #define TAO_OBJECT_IOR_EVALUATE_RETURN \
88 if (!this->is_evaluated_) \
90 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX , mon, this->object_init_lock_, 0); \
91 if (!this->is_evaluated_) \
92 CORBA::Object::tao_object_initialize (this); \
96 CORBA::Object::_add_ref ()
102 CORBA::Object::_remove_ref ()
104 if (--this->refcount_
== 0)
111 CORBA::Object::_refcount_value() const
113 return this->refcount_
;
117 CORBA::Object::_tao_any_destructor (void *x
)
119 CORBA::Object_ptr tmp
= static_cast<CORBA::Object_ptr
> (x
);
120 ::CORBA::release (tmp
);
123 // virtual -- do not inline
125 CORBA::Object::marshal (TAO_OutputCDR
&cdr
)
127 return (cdr
<< this);
130 /*static*/ CORBA::Boolean
131 CORBA::Object::marshal (const CORBA::Object_ptr x
, TAO_OutputCDR
&cdr
)
135 // NIL objrefs ... marshal as empty type hint, no elements.
137 cdr
.write_char ('\0');
139 return cdr
.good_bit ();
142 return x
->marshal (cdr
);
145 #if defined (GEN_OSTREAM_OPS)
147 /*static*/ std::ostream
&
148 CORBA::Object::_tao_stream (std::ostream
&strm
,
149 const CORBA::Object_ptr _tao_objref
)
151 return _tao_objref
->_tao_stream_v (strm
);
155 CORBA::Object::_tao_stream_v (std::ostream
&strm
) const
157 return strm
<< "\"IDL:omg.org/CORBA/Object:1.0\"";
160 #endif /* GEN_OSTREAM_OPS */
163 CORBA::Object::can_convert_to_ior () const
165 // By default, objects can not be stringified if they are local
166 return !this->_is_local ();
170 CORBA::Object::convert_to_ior (bool, const char*) const
175 TAO_Abstract_ServantBase
*
176 CORBA::Object::_servant () const
178 if (this->protocol_proxy_
== nullptr)
180 // No stub set. Should not happen.
184 return this->protocol_proxy_
->collocated_servant ();
187 // IS_A ... ask the object if it's an instance of the type whose
188 // logical type ID is passed as a parameter.
191 CORBA::Object::_is_a (const char *type_id
)
193 TAO_OBJECT_IOR_EVALUATE_RETURN
;
195 // NOTE: if _stub->type_id is nonzero and we have local knowledge of
196 // it, we can answer this question without a costly remote call.
198 // That "local knowledge" could come from stubs or skeletons linked
199 // into this process in the best case, or a "near" repository in a
200 // slightly worse case. Or in a trivial case, if the ID being asked
201 // about is the ID we have recorded, we don't need to ask about the
202 // inheritance relationships at all!
204 // In real systems having local knowledge will be common, though as
205 // the systems built atop ORBs become richer it'll also become
206 // common to have the "real type ID" not be directly understood
207 // because it's more deeply derived than any locally known types.
209 // XXX if type_id is that of CORBA::Object, "yes, we comply" :-)
211 if (this->protocol_proxy_
== nullptr)
213 if (TAO_debug_level
> 0)
214 TAOLIB_ERROR ((LM_ERROR
,
215 ACE_TEXT ("TAO (%P|%t) - No protocol proxy for %C\n"),
218 throw ::CORBA::NO_IMPLEMENT ();
221 if (this->_stubobj ()->type_id
.in () != nullptr
222 && ACE_OS::strcmp (type_id
,
223 this->_stubobj ()->type_id
.in ()) == 0)
226 return this->proxy_broker ()->_is_a (this, type_id
);
230 CORBA::Object::_interface_repository_id () const
232 return "IDL:omg.org/CORBA/Object:1.0";
236 CORBA::Object::_is_collocated () const
238 if (this->protocol_proxy_
)
240 return this->protocol_proxy_
->is_collocated ();
247 CORBA::Object::_is_local () const
249 return this->is_local_
;
253 CORBA::Object::_stubobj () const
255 return this->protocol_proxy_
;
259 CORBA::Object::_stubobj ()
261 TAO_OBJECT_IOR_EVALUATE_RETURN
;
262 return this->protocol_proxy_
;
266 CORBA::Object::_hash (CORBA::ULong maximum
)
268 TAO_OBJECT_IOR_EVALUATE_RETURN
;
270 if (this->protocol_proxy_
!= nullptr)
271 return this->protocol_proxy_
->hash (maximum
);
274 // Locality-constrained object.
276 // Note that we reinterpret_cast to an "unsigned long" instead
277 // of CORBA::ULong since we need to first cast to an integer
278 // large enough to hold an address to avoid compile-time
279 // warnings on some 64-bit platforms.
280 const CORBA::ULong hash
=
281 static_cast<CORBA::ULong
> (reinterpret_cast<ptrdiff_t> (this));
283 return hash
% maximum
;
288 CORBA::Object::_is_equivalent (CORBA::Object_ptr other_obj
)
290 if (other_obj
== nullptr)
295 if (other_obj
== this)
300 TAO_OBJECT_IOR_EVALUATE_RETURN
;
302 if (this->protocol_proxy_
!= nullptr)
303 return this->protocol_proxy_
->is_equivalent (other_obj
);
311 CORBA::Object::_key ()
313 TAO_OBJECT_IOR_EVALUATE_RETURN
;
315 if (this->_stubobj () && this->_stubobj ()->profile_in_use ())
316 return this->_stubobj ()->profile_in_use ()->_key ();
318 if (TAO_debug_level
> 2)
320 TAOLIB_ERROR ((LM_ERROR
,
321 ACE_TEXT ("TAO (%P|%t) Null object key return from ")
322 ACE_TEXT ("profile in use\n")));
325 throw ::CORBA::INTERNAL (
326 CORBA::SystemException::_tao_minor_code (
329 CORBA::COMPLETED_NO
);
333 CORBA::Object::_proxy_broker (TAO::Object_Proxy_Broker
*proxy_broker
)
335 this->protocol_proxy_
->object_proxy_broker (proxy_broker
);
339 CORBA::Object::is_nil_i (CORBA::Object_ptr obj
)
341 // If the profile length is zero for a non-evaluated IOR it is a
343 if ((!obj
->is_evaluated ()) && obj
->ior ().profiles
.length () == 0)
346 // To accommodate new definitions.
349 return obj
->orb_core_
->object_is_nil (obj
);
355 #if (TAO_HAS_MINIMUM_CORBA == 0)
357 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
359 CORBA::Object::_create_request (CORBA::Context_ptr ctx
,
360 const char *operation
,
361 CORBA::NVList_ptr arg_list
,
362 CORBA::NamedValue_ptr result
,
363 CORBA::Request_ptr
&request
,
364 CORBA::Flags req_flags
)
366 TAO_OBJECT_IOR_EVALUATE
;
368 // Since we don't really support Context, anything but a null pointer
370 // Neither can we create a request object from locality constrained
371 // object references.
372 if (ctx
!= nullptr || this->protocol_proxy_
== nullptr)
374 if (TAO_debug_level
> 0)
375 TAOLIB_ERROR ((LM_ERROR
,
376 ACE_TEXT ("TAO (%P|%t) - No protocol proxy for %C\n"),
379 throw ::CORBA::NO_IMPLEMENT ();
382 TAO_Dynamic_Adapter
*dynamic_adapter
=
383 ACE_Dynamic_Service
<TAO_Dynamic_Adapter
>::instance (
384 TAO_ORB_Core::dynamic_adapter_name ()
387 dynamic_adapter
->create_request (
389 this->protocol_proxy_
->orb_core ()-> orb (),
399 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
401 CORBA::Object::_create_request (CORBA::Context_ptr ctx
,
402 const char *operation
,
403 CORBA::NVList_ptr arg_list
,
404 CORBA::NamedValue_ptr result
,
405 CORBA::ExceptionList_ptr exceptions
,
406 CORBA::ContextList_ptr
,
407 CORBA::Request_ptr
&request
,
408 CORBA::Flags req_flags
)
410 TAO_OBJECT_IOR_EVALUATE
;
412 // Since we don't really support Context, anything but a null pointer
414 // Neither can we create a request object from locality constrained
415 // object references.
416 if (ctx
!= nullptr || this->protocol_proxy_
== nullptr)
418 if (TAO_debug_level
> 0)
419 TAOLIB_ERROR ((LM_ERROR
,
420 ACE_TEXT ("TAO (%P|%t) - No protocol proxy for %C\n"),
423 throw ::CORBA::NO_IMPLEMENT ();
426 TAO_Dynamic_Adapter
*dynamic_adapter
=
427 ACE_Dynamic_Service
<TAO_Dynamic_Adapter
>::instance (
428 TAO_ORB_Core::dynamic_adapter_name ()
431 dynamic_adapter
->create_request (
433 this->protocol_proxy_
->orb_core ()-> orb (),
443 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
445 CORBA::Object::_request (const char *operation
)
447 TAO_OBJECT_IOR_EVALUATE_RETURN
;
448 if (this->protocol_proxy_
)
450 TAO_Dynamic_Adapter
*dynamic_adapter
=
451 ACE_Dynamic_Service
<TAO_Dynamic_Adapter
>::instance (
452 TAO_ORB_Core::dynamic_adapter_name ());
454 return dynamic_adapter
->request (
456 this->protocol_proxy_
->orb_core ()->orb (),
461 if (TAO_debug_level
> 0)
462 TAOLIB_ERROR ((LM_ERROR
,
463 ACE_TEXT ("TAO (%P|%t) - No protocol proxy for %C\n"),
466 throw ::CORBA::NO_IMPLEMENT ();
471 // NON_EXISTENT ... send a simple call to the object, which will
472 // either elicit a false response or a OBJECT_NOT_EXIST exception. In
473 // the latter case, return true.
476 CORBA::Object::_non_existent ()
478 TAO_OBJECT_IOR_EVALUATE_RETURN
;
480 CORBA::Boolean retval
= false;
484 retval
= this->proxy_broker ()->_non_existent (this);
486 catch (const ::CORBA::OBJECT_NOT_EXIST
&)
495 #if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO)
496 CORBA::InterfaceDef_ptr
497 CORBA::Object::_get_interface ()
499 TAO_OBJECT_IOR_EVALUATE_RETURN
;
500 return this->proxy_broker ()->_get_interface (this);
504 CORBA::Object::_get_component ()
506 TAO_OBJECT_IOR_EVALUATE_RETURN
;
507 return this->proxy_broker ()->_get_component (this);
512 CORBA::Object::_repository_id ()
514 TAO_OBJECT_IOR_EVALUATE_RETURN
;
515 return this->proxy_broker ()->_repository_id (this);
518 #endif /* TAO_HAS_MINIMUM_CORBA */
520 // ****************************************************************
522 // @@ Does it make sense to support policy stuff for locality constrained
523 // objects? Also, does it make sense to bind policies with stub object?
526 #if (TAO_HAS_CORBA_MESSAGING == 1)
529 CORBA::Object::_get_policy (CORBA::PolicyType type
)
531 TAO_OBJECT_IOR_EVALUATE_RETURN
;
533 if (this->protocol_proxy_
)
534 return this->protocol_proxy_
->get_policy (type
);
537 if (TAO_debug_level
> 0)
538 TAOLIB_ERROR ((LM_ERROR
,
539 ACE_TEXT ("TAO (%P|%t) - No protocol proxy in _get_policy\n")));
541 throw ::CORBA::NO_IMPLEMENT ();
546 CORBA::Object::_get_cached_policy (TAO_Cached_Policy_Type type
)
548 TAO_OBJECT_IOR_EVALUATE_RETURN
;
550 if (this->protocol_proxy_
)
551 return this->protocol_proxy_
->get_cached_policy (type
);
554 if (TAO_debug_level
> 0)
555 TAOLIB_ERROR ((LM_ERROR
,
556 ACE_TEXT ("TAO (%P|%t) - No protocol proxy in _get_policy\n")));
558 throw ::CORBA::NO_IMPLEMENT ();
563 CORBA::Object::_set_policy_overrides (
564 const CORBA::PolicyList
& policies
,
565 CORBA::SetOverrideType set_add
)
567 TAO_OBJECT_IOR_EVALUATE_RETURN
;
569 if (!this->protocol_proxy_
)
571 if (TAO_debug_level
> 0)
572 TAOLIB_ERROR ((LM_ERROR
,
573 ACE_TEXT ("TAO (%P|%t) - No protocol proxy in _get_policy\n")));
575 throw ::CORBA::NO_IMPLEMENT ();
579 this->protocol_proxy_
->set_policy_overrides (policies
, set_add
);
581 TAO_Stub_Auto_Ptr
safe_stub (stub
);
583 CORBA::Object_ptr obj
= CORBA::Object::_nil ();
585 ACE_NEW_THROW_EX (obj
,
587 this->_is_collocated ()),
589 CORBA::SystemException::_tao_minor_code (
592 CORBA::COMPLETED_MAYBE
));
594 // If the stub is collocated and we don't have a collocated server we need
595 // to reinitialize it to get it.
596 if (stub
->is_collocated () && stub
->collocated_servant () == nullptr)
598 obj
->orb_core ()->reinitialize_object (stub
);
601 (void) safe_stub
.release ();
607 CORBA::Object::_get_policy_overrides (const CORBA::PolicyTypeSeq
& types
)
609 TAO_OBJECT_IOR_EVALUATE_RETURN
;
610 if (this->protocol_proxy_
)
611 return this->protocol_proxy_
->get_policy_overrides (types
);
614 if (TAO_debug_level
> 0)
615 TAOLIB_ERROR ((LM_ERROR
,
616 ACE_TEXT ("TAO (%P|%t) - No protocol proxy in _get_policy\n")));
618 throw ::CORBA::NO_IMPLEMENT ();
623 CORBA::Object::_validate_connection (
624 CORBA::PolicyList_out inconsistent_policies
)
626 TAO_OBJECT_IOR_EVALUATE_RETURN
;
628 inconsistent_policies
= nullptr;
629 CORBA::Boolean retval
= true;
631 #if (TAO_HAS_MINIMUM_CORBA == 0)
632 // Note that the OBJECT_NOT_EXIST exception should be propagated to
633 // the caller rather than return false, which is why we do not use
634 // CORBA::Object::_non_existent(). This behavior is consistent
635 // with the non-collocated case.
636 if (this->_is_collocated ())
637 return !(this->proxy_broker ()->_non_existent (this));
639 TAO::LocateRequest_Invocation_Adapter
tao_call (this);
644 catch (const ::CORBA::INV_POLICY
&)
646 inconsistent_policies
= tao_call
.get_inconsistent_policies ();
651 #endif /* TAO_HAS_MINIMUM_CORBA */
656 #endif /* TAO_HAS_CORBA_MESSAGING == 1 */
660 CORBA::Object::_get_orb ()
662 if (this->orb_core_
!= nullptr)
664 return CORBA::ORB::_duplicate (this->orb_core_
->orb ());
668 TAO_OBJECT_IOR_EVALUATE_RETURN
;
669 if (this->protocol_proxy_
)
670 return CORBA::ORB::_duplicate (this->protocol_proxy_
->orb_core ()->orb ());
673 if (TAO_debug_level
> 0)
674 TAOLIB_ERROR ((LM_ERROR
,
675 ACE_TEXT ("TAO (%P|%t) - No protocol proxy in _get_policy\n")));
677 throw ::CORBA::NO_IMPLEMENT ();
682 TAO::Object_Proxy_Broker
*
683 CORBA::Object::proxy_broker () const
685 // Paranoid check. We *should* never access the proxy_broker
686 // when the object has not been initialised so there *should*
687 // always be a stub, but just in case...
688 if (this->protocol_proxy_
)
690 return this->protocol_proxy_
->object_proxy_broker ();
693 // We have no stub. We cannot be collocated.
694 return the_tao_remote_object_proxy_broker ();
697 /*****************************************************************
699 ****************************************************************/
702 operator<< (TAO_OutputCDR
& cdr
, const CORBA::Object
* x
)
706 // NIL objrefs ... marshal as empty type hint, no elements.
708 cdr
.write_char ('\0');
710 return cdr
.good_bit ();
713 if (!x
->is_evaluated ())
715 // @@ This is too inefficient. Need to speed this up if this is
717 cdr
<< const_cast<IOP::IOR
&> (x
->ior ());
718 return cdr
.good_bit ();
721 TAO_Stub
*stubobj
= x
->_stubobj ();
723 if (stubobj
== nullptr)
726 return (stubobj
->marshal (cdr
));
730 CORBA::Object::tao_object_initialize (CORBA::Object
*obj
)
732 CORBA::ULong
const profile_count
=
733 obj
->ior_
->profiles
.length ();
735 // Assumption is that after calling this method, folks should test
736 // for protocol_proxy_ or whatever to make sure that things have
738 if (profile_count
== 0)
741 // get a profile container to store all profiles in the IOR.
742 TAO_MProfile
mp (profile_count
);
744 TAO_ORB_Core
*&orb_core
= obj
->orb_core_
;
745 if (orb_core
== nullptr)
747 orb_core
= TAO_ORB_Core_instance ();
748 if (TAO_debug_level
> 0)
750 TAOLIB_DEBUG ((LM_WARNING
,
751 ACE_TEXT ("TAO (%P|%t) - Object::tao_object_initialize ")
752 ACE_TEXT ("WARNING: extracting object from ")
753 ACE_TEXT ("default ORB_Core\n")));
757 TAO_Stub
*objdata
= nullptr;
761 TAO_Connector_Registry
*connector_registry
=
762 orb_core
->connector_registry ();
764 for (CORBA::ULong i
= 0; i
!= profile_count
; ++i
)
766 IOP::TaggedProfile
&tpfile
= obj
->ior_
->profiles
[i
];
768 // NOTE: This is a place for optimizations. Here we have an
769 // 2 allocations and 2 copies. Future optimizations should
770 // target this place.
775 TAO_InputCDR
cdr (o_cdr
,
776 orb_core
->input_cdr_buffer_allocator (),
777 orb_core
->input_cdr_dblock_allocator (),
778 orb_core
->input_cdr_msgblock_allocator (),
781 TAO_Profile
*pfile
= connector_registry
->create_profile (cdr
);
783 if (pfile
!= nullptr)
785 if (mp
.give_profile (pfile
) == -1)
787 TAOLIB_ERROR ((LM_ERROR
,
788 ACE_TEXT ("TAO (%P|%t) ERROR: give_profile\n")
789 ACE_TEXT (" returned -1\n")));
794 // Make sure we got some profiles!
795 if (mp
.profile_count () != profile_count
)
797 // @@ This occurs when profile creation fails when decoding the
798 // profile from the IOR.
799 TAOLIB_ERROR ((LM_ERROR
,
800 ACE_TEXT ("TAO (%P|%t) ERROR: XXXXX Could not create all ")
801 ACE_TEXT ("profiles while extracting object\n")
802 ACE_TEXT ("TAO (%P|%t) ERROR: reference from the ")
803 ACE_TEXT ("CDR stream.\n")));
807 objdata
= orb_core
->create_stub (obj
->ior_
->type_id
.in (), mp
);
809 catch (const ::CORBA::Exception
& ex
)
811 if (TAO_debug_level
> 0)
812 ex
._tao_print_exception (
813 ACE_TEXT ("TAO - ERROR creating stub ")
814 ACE_TEXT ("object when demarshaling object ")
815 ACE_TEXT ("reference."));
820 TAO_Stub_Auto_Ptr
safe_objdata (objdata
);
822 // This call will set the stub proxy broker if necessary
823 if (orb_core
->initialize_object (safe_objdata
.get (), obj
) == -1)
826 obj
->protocol_proxy_
= objdata
;
828 obj
->is_evaluated_
= true;
830 // Release the contents of the ior to keep memory consumption down.
833 // Transfer ownership to the CORBA::Object
834 (void) safe_objdata
.release ();
838 operator>> (TAO_InputCDR
& cdr
, CORBA::Object
*& x
)
840 bool lazy_strategy
= false;
841 TAO_ORB_Core
*orb_core
= cdr
.orb_core ();
843 if (orb_core
== nullptr)
845 orb_core
= TAO_ORB_Core_instance ();
846 if (TAO_debug_level
> 0)
848 TAOLIB_DEBUG ((LM_WARNING
,
849 ACE_TEXT ("TAO (%P|%t) WARNING: extracting object from ")
850 ACE_TEXT ("default ORB_Core\n")));
855 if (orb_core
->resource_factory ()->resource_usage_strategy () ==
856 TAO_Resource_Factory::TAO_LAZY
)
858 lazy_strategy
= true;
864 // If the user has set up a eager strategy..
865 CORBA::String_var type_hint
;
866 if (!(cdr
>> type_hint
.inout ()))
869 CORBA::ULong profile_count
;
870 if (!(cdr
>> profile_count
))
873 if (profile_count
== 0)
875 x
= CORBA::Object::_nil ();
876 return cdr
.good_bit ();
879 // get a profile container to store all profiles in the IOR.
880 TAO_MProfile
mp (profile_count
);
882 TAO_ORB_Core
*orb_core
= cdr
.orb_core ();
883 if (orb_core
== nullptr)
885 orb_core
= TAO_ORB_Core_instance ();
886 if (TAO_debug_level
> 0)
888 TAOLIB_DEBUG ((LM_WARNING
,
889 ACE_TEXT ("TAO (%P|%t) - Object::tao_object_initialize ")
890 ACE_TEXT ("WARNING: extracting object from ")
891 ACE_TEXT ("default ORB_Core\n")));
895 // Ownership of type_hint is given to TAO_Stub
896 // TAO_Stub will make a copy of mp!
897 TAO_Stub
*objdata
= nullptr;
901 TAO_Connector_Registry
*connector_registry
=
902 orb_core
->connector_registry ();
904 for (CORBA::ULong i
= 0; i
!= profile_count
&& cdr
.good_bit (); ++i
)
906 TAO_Profile
*pfile
= connector_registry
->create_profile (cdr
);
907 if (pfile
!= nullptr)
909 if (mp
.give_profile (pfile
) == -1)
911 TAOLIB_ERROR ((LM_ERROR
,
912 ACE_TEXT ("TAO (%P|%t) ERROR: give_profile\n")
913 ACE_TEXT (" returned -1\n")));
918 // Make sure we got some profiles!
919 if (mp
.profile_count () != profile_count
)
921 // @@ This occurs when profile creation fails when decoding the
922 // profile from the IOR.
923 TAOLIB_ERROR_RETURN ((LM_ERROR
,
924 ACE_TEXT ("TAO (%P|%t) - ERROR: Could not create all ")
925 ACE_TEXT ("profiles while extracting object [%d, %d] ")
926 ACE_TEXT ("reference from the CDR stream.\n"),
927 mp
.profile_count (), profile_count
),
931 objdata
= orb_core
->create_stub (type_hint
.in (), mp
);
933 catch (const ::CORBA::Exception
& ex
)
935 if (TAO_debug_level
> 0)
936 ex
._tao_print_exception (
937 ACE_TEXT ("TAO (%P|%t) - ERROR creating stub ")
938 ACE_TEXT ("object when demarshaling object ")
939 ACE_TEXT ("reference.\n"));
944 TAO_Stub_Auto_Ptr
safe_objdata (objdata
);
946 x
= orb_core
->create_object (safe_objdata
.get ());
952 // Transfer ownership to the CORBA::Object
953 (void) safe_objdata
.release ();
958 IOP::IOR
*ior
= nullptr;
966 // Can't extract the IOR, so delete the already allocated
967 // ior to not have a memory leak
972 x
= new (std::nothrow
) CORBA::Object (ior
, orb_core
);
976 // Can't allocate a CORBA Object so delete first the
977 // memory we already allocated before we return
983 return cdr
.good_bit ();
986 #if defined (GEN_OSTREAM_OPS)
989 operator<< (std::ostream
&strm
, CORBA::Object_ptr _tao_objref
)
991 return CORBA::Object::_tao_stream (strm
, _tao_objref
);
994 #endif /* GEN_OSTREAM_OPS */
996 // =========================================================
997 // Traits specializations for CORBA::Object.
1000 void In_Object_Argument_Cloner_T
<CORBA::InterfaceDef_ptr
>::duplicate
1001 (CORBA::InterfaceDef_ptr
)
1005 void In_Object_Argument_Cloner_T
<CORBA::InterfaceDef_ptr
>::release
1006 (CORBA::InterfaceDef_ptr
)
1011 Objref_Traits
<CORBA::Object
>::duplicate (CORBA::Object_ptr p
)
1013 return CORBA::Object::_duplicate (p
);
1017 Objref_Traits
<CORBA::Object
>::release (CORBA::Object_ptr p
)
1019 ::CORBA::release (p
);
1023 Objref_Traits
<CORBA::Object
>::nil ()
1025 return CORBA::Object::_nil ();
1029 Objref_Traits
<CORBA::Object
>::marshal (const CORBA::Object_ptr p
,
1030 TAO_OutputCDR
& cdr
)
1032 return ::CORBA::Object::marshal (p
, cdr
);
1034 } // close TAO namespace
1036 TAO::Object_Proxy_Broker
* (*_TAO_Object_Proxy_Broker_Factory_function_pointer
) () = nullptr;
1038 TAO_END_VERSIONED_NAMESPACE_DECL