1 #include "AMH_DSI_Response_Handler.h"
3 #include "ExceptionList.h"
4 #include "DII_Invocation.h"
5 #include "Server_Request.h"
7 #include "tao/ORB_Core.h"
8 #include "tao/GIOP_Utils.h"
9 #include "tao/PortableServer/Root_POA.h"
10 #include "tao/Valuetype/ValueFactory.h"
11 #include "tao/Object.h"
12 #include "tao/Pluggable_Messaging_Utils.h"
13 #include "tao/AnyTypeCode/Any_Impl.h"
15 #include "ace/Truncate.h"
17 #if !defined (__ACE_INLINE__)
18 # include "AMH_DSI_Response_Handler.inl"
19 #endif /* ! __ACE_INLINE__ */
21 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 TAO_AMH_DSI_Exception_Holder::_tao_obv_static_repository_id ()
26 return "IDL:TAO_AMH_DSI_Exception_Holder:1.0";
29 TAO_AMH_DSI_Exception_Holder::TAO_AMH_DSI_Exception_Holder (CORBA::Exception
*ex
)
34 TAO_AMH_DSI_Exception_Holder::~TAO_AMH_DSI_Exception_Holder ()
39 TAO_AMH_DSI_Exception_Holder::_copy_value ()
41 ::CORBA::ValueBase
*ret_val
= 0;
44 TAO_AMH_DSI_Exception_Holder (
53 tao_TAO_AMH_DSI_Exception_Holder_add_ref (TAO_AMH_DSI_Exception_Holder
* p
)
59 tao_TAO_AMH_DSI_Exception_Holder_remove_ref (TAO_AMH_DSI_Exception_Holder
* p
)
61 CORBA::remove_ref (p
);
65 TAO_AMH_DSI_Exception_Holder_var::TAO_AMH_DSI_Exception_Holder_var ()
70 TAO_AMH_DSI_Exception_Holder_var::TAO_AMH_DSI_Exception_Holder_var (
71 TAO_AMH_DSI_Exception_Holder
* p
)
76 TAO_AMH_DSI_Exception_Holder_var::TAO_AMH_DSI_Exception_Holder_var (
77 const TAO_AMH_DSI_Exception_Holder
* p
)
78 : ptr_ (const_cast<TAO_AMH_DSI_Exception_Holder
*> (p
))
82 TAO_AMH_DSI_Exception_Holder
*
83 TAO_AMH_DSI_Exception_Holder_var::ptr () const
88 TAO_AMH_DSI_Exception_Holder_var::TAO_AMH_DSI_Exception_Holder_var (
89 const TAO_AMH_DSI_Exception_Holder_var
& p
)
91 CORBA::add_ref (p
.ptr ());
92 this->ptr_
= p
.ptr ();
95 TAO_AMH_DSI_Exception_Holder_var::~TAO_AMH_DSI_Exception_Holder_var ()
97 CORBA::remove_ref (this->ptr_
);
100 TAO_AMH_DSI_Exception_Holder_var
&
101 TAO_AMH_DSI_Exception_Holder_var::operator= (TAO_AMH_DSI_Exception_Holder
*p
)
103 CORBA::remove_ref (this->ptr_
);
108 TAO_AMH_DSI_Exception_Holder_var
&
109 TAO_AMH_DSI_Exception_Holder_var::operator= (
110 const TAO_AMH_DSI_Exception_Holder_var
& p
)
114 CORBA::remove_ref (this->ptr_
);
115 TAO_AMH_DSI_Exception_Holder
*tmp
= p
.ptr ();
116 CORBA::add_ref (tmp
);
123 TAO_AMH_DSI_Exception_Holder_var::operator const TAO_AMH_DSI_Exception_Holder
* () const // cast
128 TAO_AMH_DSI_Exception_Holder_var::operator TAO_AMH_DSI_Exception_Holder
*& ()
133 TAO_AMH_DSI_Exception_Holder
*
134 TAO_AMH_DSI_Exception_Holder_var::operator-> () const
139 TAO_AMH_DSI_Exception_Holder
*
140 TAO_AMH_DSI_Exception_Holder_var::in () const
145 TAO_AMH_DSI_Exception_Holder
*&
146 TAO_AMH_DSI_Exception_Holder_var::inout ()
151 TAO_AMH_DSI_Exception_Holder
*&
152 TAO_AMH_DSI_Exception_Holder_var::out ()
154 CORBA::remove_ref (this->ptr_
);
159 TAO_AMH_DSI_Exception_Holder
*
160 TAO_AMH_DSI_Exception_Holder_var::_retn ()
162 // yield ownership of managed obj reference
163 TAO_AMH_DSI_Exception_Holder
* tmp
= this->ptr_
;
169 TAO_AMH_DSI_Exception_Holder_var::tao_add_ref (TAO_AMH_DSI_Exception_Holder
*p
)
175 TAO_AMH_DSI_Exception_Holder_var::tao_remove_ref (
176 TAO_AMH_DSI_Exception_Holder
*p
)
178 CORBA::remove_ref (p
);
181 TAO_AMH_DSI_Exception_Holder_out::TAO_AMH_DSI_Exception_Holder_out (
182 TAO_AMH_DSI_Exception_Holder
* &p
)
188 TAO_AMH_DSI_Exception_Holder_out::TAO_AMH_DSI_Exception_Holder_out (
189 TAO_AMH_DSI_Exception_Holder_var
& p
)
192 CORBA::remove_ref (this->ptr_
);
196 TAO_AMH_DSI_Exception_Holder_out::TAO_AMH_DSI_Exception_Holder_out (
197 const TAO_AMH_DSI_Exception_Holder_out
&p
)
198 : ptr_ (const_cast<TAO_AMH_DSI_Exception_Holder_out
&> (p
).ptr_
)
201 TAO_AMH_DSI_Exception_Holder_out
&
202 TAO_AMH_DSI_Exception_Holder_out::operator= (
203 const TAO_AMH_DSI_Exception_Holder_out
&p
)
205 this->ptr_
= const_cast<TAO_AMH_DSI_Exception_Holder_out
&> (p
).ptr_
;
209 TAO_AMH_DSI_Exception_Holder_out
&
210 TAO_AMH_DSI_Exception_Holder_out::operator= (
211 const TAO_AMH_DSI_Exception_Holder_var
&p
)
213 TAO_AMH_DSI_Exception_Holder
*tmp
= p
.ptr ();
214 CORBA::add_ref (tmp
);
219 TAO_AMH_DSI_Exception_Holder_out
&
220 TAO_AMH_DSI_Exception_Holder_out::operator= (TAO_AMH_DSI_Exception_Holder
*p
)
226 TAO_AMH_DSI_Exception_Holder_out::operator TAO_AMH_DSI_Exception_Holder
*& ()
231 TAO_AMH_DSI_Exception_Holder
*&
232 TAO_AMH_DSI_Exception_Holder_out::ptr () // ptr
237 TAO_AMH_DSI_Exception_Holder
*
238 TAO_AMH_DSI_Exception_Holder_out::operator-> ()
243 TAO_AMH_DSI_Exception_Holder
*
244 TAO_AMH_DSI_Exception_Holder::_downcast (CORBA::ValueBase
* v
)
246 return dynamic_cast < TAO_AMH_DSI_Exception_Holder
* >(v
);
250 TAO_AMH_DSI_Exception_Holder::_tao_obv_repository_id () const
252 return this->_tao_obv_static_repository_id ();
256 TAO_AMH_DSI_Exception_Holder::_tao_any_destructor (void *_tao_void_pointer
)
258 TAO_AMH_DSI_Exception_Holder
*tmp
=
259 static_cast<TAO_AMH_DSI_Exception_Holder
*> (_tao_void_pointer
);
264 TAO_AMH_DSI_Exception_Holder::_tao_unmarshal (
266 TAO_AMH_DSI_Exception_Holder
*&new_object
)
268 ::CORBA::ValueBase
*base
= 0;
269 ::CORBA::Boolean is_indirected
= false;
270 ::CORBA::Boolean is_null_object
= false;
271 ::CORBA::Boolean
const retval
=
272 ::CORBA::ValueBase::_tao_unmarshal_pre (
275 TAO_AMH_DSI_Exception_Holder::_tao_obv_static_repository_id (),
279 ::CORBA::ValueBase_var
owner (base
);
287 if (!is_indirected
&& base
!= 0 && ! base
->_tao_unmarshal_v (strm
))
290 // Now base must be null or point to the unmarshaled object.
291 // Align the pointer to the right subobject.
292 new_object
= TAO_AMH_DSI_Exception_Holder::_downcast (base
);
294 new_object
->_add_ref ();
301 TAO_AMH_DSI_Exception_Holder::raise_invoke ()
303 std::unique_ptr
< ::CORBA::Exception
> safety (this->exception_
);
304 this->exception_
->_raise ();
307 // The pseudo-object _nil method.
308 TAO_AMH_DSI_Response_Handler_ptr
309 TAO_AMH_DSI_Response_Handler::_nil ()
315 TAO_AMH_DSI_Response_Handler::TAO_AMH_DSI_Response_Handler (
316 TAO_ServerRequest
& sr
)
317 : TAO_AMH_Response_Handler (),
318 orb_core_ (sr
.orb_core ())
322 TAO_AMH_DSI_Response_Handler::~TAO_AMH_DSI_Response_Handler ()
327 TAO_AMH_DSI_Response_Handler::invoke_reply (CORBA::NVList_ptr args
,
328 CORBA::NamedValue_ptr result
)
332 this->_tao_rh_init_reply ();
334 // Send the return value, if any.
335 if (result
!= 0 && result
->value () != 0)
337 result
->value ()->impl ()->marshal_value (this->_tao_out
);
340 // Send the "inout" and "out" parameters.
343 args
->_tao_encode (this->_tao_out
, CORBA::ARG_INOUT
| CORBA::ARG_OUT
);
345 this->_tao_rh_send_reply ();
347 catch (const CORBA::Exception
&)
354 TAO_AMH_DSI_Response_Handler::invoke_excep (TAO_AMH_DSI_Exception_Holder
* h
)
360 catch (const CORBA::Exception
& ex
)
362 this->_tao_rh_send_exception (ex
);
367 TAO_AMH_DSI_Response_Handler::invoke_location_forward (CORBA::Object_ptr fwd
,
368 CORBA::Boolean is_perm
)
370 this->_tao_rh_send_location_forward (fwd
,is_perm
);
374 TAO_AMH_DSI_Response_Handler::gateway_exception_reply (
375 CORBA::ULong reply_status
,
376 TAO_OutputCDR
& encap
)
378 // for this to be effective, ACE & TAO must be built with
379 // ACE_ENABLE_SWAP_ON_WRITE defined in ace/config.h
380 this->_tao_out
.reset_byte_order (encap
.byte_order ());
381 // This reply path handles only user exceptions.
382 switch (reply_status
)
384 case TAO_AMI_REPLY_USER_EXCEPTION
:
385 this->reply_status_
= GIOP::USER_EXCEPTION
;
387 case TAO_AMI_REPLY_SYSTEM_EXCEPTION
:
388 this->reply_status_
= GIOP::SYSTEM_EXCEPTION
;
391 // TODO: we don't handle location forward at this moment.
392 // need to be addressed later.
394 //case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD:
395 // this->exception_type_ = TAO_GIOP_LOCATION_FORWARD;
400 this->_tao_rh_init_reply ();
402 // We know nothing about this exception, so we marshal it as a block
403 // of bytes. The outgoing stream's byte order has already been matched
404 // to the original source of the reply.
405 this->_tao_out
.write_char_array (encap
.buffer (),
406 ACE_Utils::truncate_cast
<ACE_CDR::ULong
> (encap
.length ()));
407 // This will prevent the marshaling of any parameters into this reply.
408 // this->sent_gateway_exception_ = true;
409 this->_tao_rh_send_reply ();
411 catch (const CORBA::Exception
&)
419 TAO_AMH_DSI_Response_Handler::gateway_exception_reply (
420 CORBA::ULong reply_status
,
423 // for this to be effective, ACE & TAO must be built with
424 // ACE_ENABLE_SWAP_ON_WRITE defined in ace/config.h
425 this->_tao_out
.reset_byte_order(encap
.byte_order());
426 // This reply path handles only user exceptions.
427 switch (reply_status
)
429 //case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION:
430 case TAO_AMI_REPLY_USER_EXCEPTION
:
431 this->reply_status_
= GIOP::USER_EXCEPTION
;
433 case TAO_AMI_REPLY_SYSTEM_EXCEPTION
:
434 this->reply_status_
= GIOP::SYSTEM_EXCEPTION
;
437 // we don't handle location forward at this moment.
438 // need to be addressed later.
440 //case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD:
441 // this->exception_type_ = TAO_GIOP_LOCATION_FORWARD;
446 this->_tao_rh_init_reply ();
448 // We know nothing about this exception, so we marshal it as a block
449 // of bytes. The outgoing stream's byte order has already been matched
450 // to the original source of the reply.
451 this->_tao_out
.write_octet_array_mb (encap
.start());
452 // This will prevent the marshaling of any parameters into this reply.
453 // this->sent_gateway_exception_ = true;
454 this->_tao_rh_send_reply ();
456 catch (const CORBA::Exception
&)
464 TAO_AMH_DSI_Response_Handler::_downcast (const char *)
469 TAO_AMH_DSI_Response_Handler_ptr
470 TAO_AMH_DSI_Response_Handler::_narrow (CORBA::Object_ptr obj
)
472 return TAO_AMH_DSI_Response_Handler::_unchecked_narrow (obj
);
475 TAO_AMH_DSI_Response_Handler_ptr
476 TAO_AMH_DSI_Response_Handler::_unchecked_narrow (CORBA::Object_ptr obj
)
478 if (CORBA::is_nil (obj
))
479 return TAO_AMH_DSI_Response_Handler::_nil ();
481 return dynamic_cast <TAO_AMH_DSI_Response_Handler_ptr
> (obj
);
485 TAO_AMH_DSI_Response_Handler::_interface_repository_id () const
491 TAO_AMH_DSI_Exception_Holder::_tao_type () const
497 TAO_AMH_DSI_Exception_Holder::_tao_obv_truncatable_repo_ids (
498 Repository_Id_List
&) const
503 TAO_AMH_DSI_Exception_Holder::_tao_match_formal_type (ptrdiff_t ) const
509 TAO_AMH_DSI_Exception_Holder::_tao_marshal_v (TAO_OutputCDR
&) const
515 TAO_AMH_DSI_Exception_Holder::_tao_unmarshal_v (TAO_InputCDR
&)
521 TAO_AMH_DSI_Exception_Holder::_tao_marshal__Test_TAO_AMH_DSI_Exception_Holder (
528 TAO_AMH_DSI_Exception_Holder::_tao_unmarshal__Test_TAO_AMH_DSI_Exception_Holder (
534 TAO_END_VERSIONED_NAMESPACE_DECL