2 #include "tao/LocateRequest_Invocation_Adapter.h"
3 #include "tao/Profile_Transport_Resolver.h"
4 #include "tao/operation_details.h"
5 #include "tao/LocateRequest_Invocation.h"
6 #include "tao/Transport.h"
7 #include "tao/Transport_Mux_Strategy.h"
8 #include "tao/GIOP_Utils.h"
9 #include "tao/ORB_Core.h"
11 #include "tao/SystemException.h"
12 #include "ace/Service_Config.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 LocateRequest_Invocation_Adapter::LocateRequest_Invocation_Adapter (
19 CORBA::Object_ptr target
)
26 LocateRequest_Invocation_Adapter::invoke ()
28 CORBA::Object_var effective_target
=
29 CORBA::Object::_duplicate (this->target_
);
31 TAO_Stub
* const stub
=
32 this->target_
->_stubobj ();
34 throw ::CORBA::INTERNAL (
35 CORBA::SystemException::_tao_minor_code (
40 // The invocation has got to be within the context of the
41 // corresponding ORB's configuration. Otherwise things like
42 // timeout hooks, etc may not work as expected. Especially if
43 // there are multiple ORB instances in the process, each with its
44 // own, local configuration.
45 ACE_Service_Config_Guard
scg (stub
->orb_core ()->configuration ());
47 ACE_Time_Value tmp_wait_time
;
48 ACE_Time_Value
*max_wait_time
= nullptr;
50 if (this->get_timeout (tmp_wait_time
))
51 max_wait_time
= &tmp_wait_time
;
53 Invocation_Status s
= TAO_INVOKE_START
;
55 while (s
== TAO_INVOKE_START
|| s
== TAO_INVOKE_RESTART
)
57 Profile_Transport_Resolver
resolver (effective_target
.in (), stub
, true);
61 resolver
.init_inconsistent_policies ();
63 resolver
.resolve (max_wait_time
);
65 if (!resolver
.transport ())
67 // We failed to find a profile we could connect to.
68 throw CORBA::TRANSIENT (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
71 // Dummy operation details that is used to instantiate the
72 // LocateRequest class.
73 TAO_Operation_Details
op (nullptr, 0);
75 op
.request_id (resolver
.transport ()->tms ()->request_id ());
76 TAO::LocateRequest_Invocation
synch (this->target_
, resolver
, op
);
78 s
= synch
.invoke (max_wait_time
);
79 if (s
== TAO_INVOKE_RESTART
&&
80 (synch
.reply_status () == GIOP::LOCATION_FORWARD
||
81 synch
.reply_status () == GIOP::LOCATION_FORWARD_PERM
))
83 CORBA::Boolean
const is_permanent_forward
=
84 (synch
.reply_status () == GIOP::LOCATION_FORWARD_PERM
);
86 effective_target
= synch
.steal_forwarded_reference ();
88 this->object_forwarded (effective_target
,
90 is_permanent_forward
);
93 catch (const ::CORBA::INV_POLICY
&)
95 this->list_
= resolver
.steal_inconsistent_policies ();
104 LocateRequest_Invocation_Adapter::get_inconsistent_policies ()
106 return this->list_
._retn ();
110 LocateRequest_Invocation_Adapter::get_timeout (ACE_Time_Value
&timeout
)
112 bool has_timeout
= false;
113 this->target_
->orb_core ()->call_timeout_hook (this->target_
->_stubobj (),
121 LocateRequest_Invocation_Adapter::object_forwarded (
122 CORBA::Object_var
&effective_target
,
124 CORBA::Boolean permanent_forward
)
126 // The object pointer has to be changed to a TAO_Stub pointer
127 // in order to obtain the profiles.
128 TAO_Stub
*stubobj
= nullptr;
130 bool nil_forward_ref
= false;
131 if (CORBA::is_nil (effective_target
.in ()))
132 nil_forward_ref
= true;
136 effective_target
->_stubobj ();
138 if (stubobj
&& stubobj
->base_profiles ().size () == 0)
139 nil_forward_ref
= true;
143 throw ::CORBA::TRANSIENT (
144 CORBA::SystemException::_tao_minor_code (
145 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE
,
147 CORBA::COMPLETED_NO
);
149 if (stubobj
== nullptr)
150 throw ::CORBA::INTERNAL (
151 CORBA::SystemException::_tao_minor_code (
152 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE
,
154 CORBA::COMPLETED_NO
);
156 // Reset the profile in the stubs
157 stub
->add_forward_profiles (stubobj
->base_profiles (), permanent_forward
);
159 if (stub
->next_profile () == nullptr)
160 throw ::CORBA::TRANSIENT (
161 CORBA::SystemException::_tao_minor_code (
162 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE
,
164 CORBA::COMPLETED_NO
);
169 } // End namespace TAO
171 TAO_END_VERSIONED_NAMESPACE_DECL