1 #include "tao/AnyTypeCode/TypeCode.h"
2 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
3 #include "tao/DynamicInterface/DII_Invocation_Adapter.h"
4 #include "tao/DynamicInterface/DII_Invocation.h"
5 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
6 #include "tao/DynamicInterface/Request.h"
8 #include "tao/Exception.h"
9 #include "tao/Exception_Data.h"
10 #include "tao/ORB_Constants.h"
11 #include "tao/Profile_Transport_Resolver.h"
12 #include "tao/Transport.h"
13 #include "tao/GIOP_Message_Base.h"
14 #include "tao/SystemException.h"
15 #include "tao/operation_details.h"
17 #include "ace/os_include/os_errno.h"
19 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
23 DII_Invocation_Adapter::DII_Invocation_Adapter (CORBA::Object
*target
,
26 const char *operation
,
28 CORBA::ExceptionList
*excp
,
32 : Invocation_Adapter (target
,
37 TAO_CO_THRU_POA_STRATEGY
, // default through POA collocation is possible
38 TAO_TWOWAY_INVOCATION
,
40 , exception_list_ (excp
)
46 DII_Invocation_Adapter::~DII_Invocation_Adapter ()
52 DII_Invocation_Adapter::invoke (const TAO::Exception_Data
* /*ex_data*/,
53 unsigned long ex_count
)
55 // Convert DII exception list to a form the invocation can use
56 // to filter raised user exceptions.
57 ex_count
= this->exception_list_
->count ();
58 ACE_NEW_THROW_EX (this->ex_data_
,
59 TAO::Exception_Data
[ex_count
],
61 for (unsigned long l
=0; l
<ex_count
;++l
)
63 CORBA::TypeCode_var xtc
= this->exception_list_
->item (l
);
64 this->ex_data_
[l
].id
= xtc
->id ();
65 this->ex_data_
[l
].alloc
= nullptr;
66 #if TAO_HAS_INTERCEPTORS == 1
67 this->ex_data_
[l
].tc_ptr
= xtc
.in ();
71 Invocation_Adapter::invoke (this->ex_data_
, ex_count
);
75 DII_Invocation_Adapter::invoke_collocated_i (
77 TAO_Operation_Details
&details
,
78 CORBA::Object_var
&effective_target
,
79 Collocation_Strategy strat
)
81 TAO_DII_Arguments_Converter_Impl
* dii_arguments_converter
82 = ACE_Dynamic_Service
<TAO_DII_Arguments_Converter_Impl
>::instance (
83 "DII_Arguments_Converter");
84 details
.cac (dii_arguments_converter
);
86 return Invocation_Adapter::invoke_collocated_i (stub
,
93 DII_Invocation_Adapter::invoke_twoway (
94 TAO_Operation_Details
&op
,
95 CORBA::Object_var
&effective_target
,
96 Profile_Transport_Resolver
&r
,
97 ACE_Time_Value
*&max_wait_time
,
98 Invocation_Retry_State
*)
100 // Simple sanity check
101 if (this->mode_
!= TAO_DII_INVOCATION
||
102 this->type_
!= TAO_TWOWAY_INVOCATION
)
104 throw ::CORBA::INTERNAL (
105 CORBA::SystemException::_tao_minor_code (
108 CORBA::COMPLETED_NO
);
111 TAO_Transport
* const transport
= r
.transport ();
115 // Way back, we failed to find a profile we could connect to.
116 // We've come this far only so we reach the interception points
117 // in case they can fix things. Time to bail....
118 throw CORBA::TRANSIENT (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
121 TAO::DII_Invocation
synch (this->target_
,
124 this->exception_list_
,
127 // forward requested byte order
128 synch
._tao_byte_order (this->_tao_byte_order ());
130 Invocation_Status status
= synch
.remote_twoway (max_wait_time
);
132 if (status
== TAO_INVOKE_RESTART
&&
133 (synch
.reply_status () == GIOP::LOCATION_FORWARD
||
134 synch
.reply_status () == GIOP::LOCATION_FORWARD_PERM
))
136 CORBA::Boolean
const permanent_forward
=
137 (synch
.reply_status () == GIOP::LOCATION_FORWARD_PERM
);
139 effective_target
= synch
.steal_forwarded_reference ();
141 this->object_forwarded (effective_target
,
148 //================================================================
149 DII_Deferred_Invocation_Adapter::DII_Deferred_Invocation_Adapter (
150 CORBA::Object
*target
,
153 const char *operation
,
155 int collocation_opportunity
,
158 Invocation_Mode mode
)
159 : Invocation_Adapter (target
,
164 collocation_opportunity
,
165 TAO_TWOWAY_INVOCATION
,
174 DII_Deferred_Invocation_Adapter::invoke (
175 const TAO::Exception_Data
*ex
,
176 unsigned long ex_count
)
178 // New reply dispatcher on the heap, because we will go out of
179 // scope and hand over the reply dispatcher to the ORB.
180 // Manage it in a reference counting Auto_Functor based autopointer
181 // to prevent memory leaks. The invoke may encounter errors
182 // before being able to handover the dispatcher to the invocation
183 // using and managing it.
184 TAO_DII_Deferred_Reply_Dispatcher
*new_rd
= 0;
185 ACE_NEW_THROW_EX (new_rd
,
186 TAO_DII_Deferred_Reply_Dispatcher (this->request_
,
188 CORBA::NO_MEMORY ());
190 TAO_Asynch_Reply_Dispatcher_Base::intrusive_add_ref (new_rd
);
192 this->rd_
.reset (new_rd
);
194 Invocation_Adapter::invoke (ex
, ex_count
);
198 DII_Deferred_Invocation_Adapter::invoke_collocated_i (
200 TAO_Operation_Details
&details
,
201 CORBA::Object_var
&effective_target
,
202 Collocation_Strategy strat
)
204 TAO_DII_Arguments_Converter_Impl
* dii_arguments_converter
205 = ACE_Dynamic_Service
<TAO_DII_Arguments_Converter_Impl
>::instance (
206 "DII_Arguments_Converter");
207 details
.cac (dii_arguments_converter
);
209 return Invocation_Adapter::invoke_collocated_i (stub
,
216 DII_Deferred_Invocation_Adapter::invoke_twoway (
217 TAO_Operation_Details
&op
,
218 CORBA::Object_var
&effective_target
,
219 Profile_Transport_Resolver
&r
,
220 ACE_Time_Value
*&max_wait_time
,
221 Invocation_Retry_State
*)
223 // Simple sanity check
224 if (this->mode_
!= TAO_DII_DEFERRED_INVOCATION
||
225 this->type_
!= TAO_TWOWAY_INVOCATION
)
227 throw ::CORBA::INTERNAL (
228 CORBA::SystemException::_tao_minor_code (
231 CORBA::COMPLETED_NO
);
234 TAO_Transport
* const transport
= r
.transport ();
238 // Way back, we failed to find a profile we could connect to.
239 // We've come this far only so we reach the interception points
240 // in case they can fix things. Time to bail....
241 throw CORBA::TRANSIENT (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
244 TAO::DII_Deferred_Invocation
synch (
250 // forward requested byte order
251 synch
._tao_byte_order (this->_tao_byte_order ());
253 Invocation_Status
const status
= synch
.remote_invocation (max_wait_time
);
255 if (status
== TAO_INVOKE_RESTART
)
257 CORBA::Boolean
const is_permanent_forward
=
258 (synch
.reply_status () == GIOP::LOCATION_FORWARD_PERM
);
260 effective_target
= synch
.steal_forwarded_reference ();
262 this->object_forwarded (effective_target
,
264 is_permanent_forward
);
270 DII_Oneway_Invocation_Adapter::DII_Oneway_Invocation_Adapter (
271 CORBA::Object
*target
,
274 const char *operation
,
276 TAO::Invocation_Mode mode
)
277 : Invocation_Adapter (target
,
282 TAO_CO_THRU_POA_STRATEGY
,
283 TAO_ONEWAY_INVOCATION
,
289 DII_Oneway_Invocation_Adapter::invoke_collocated_i (
291 TAO_Operation_Details
&details
,
292 CORBA::Object_var
&effective_target
,
293 Collocation_Strategy strat
)
295 TAO_DII_Arguments_Converter_Impl
* dii_arguments_converter
296 = ACE_Dynamic_Service
<TAO_DII_Arguments_Converter_Impl
>::instance (
297 "DII_Arguments_Converter");
298 details
.cac (dii_arguments_converter
);
300 return Invocation_Adapter::invoke_collocated_i (stub
,
307 } // End namespace TAO
308 TAO_END_VERSIONED_NAMESPACE_DECL