1 #include "tao/Invocation_Base.h"
3 #include "tao/operation_details.h"
4 #include "tao/ORB_Core.h"
5 #include "tao/SystemException.h"
6 #include "tao/PortableInterceptor.h" /* Must always be visible. */
8 #include "ace/Dynamic_Service.h"
10 #if TAO_HAS_INTERCEPTORS == 1
11 # include "tao/PortableInterceptorC.h"
12 #endif /* TAO_HAS_INTERCEPTORS == 1 */
14 #if !defined (__ACE_INLINE__)
15 # include "tao/Invocation_Base.inl"
16 #endif /* __ACE_INLINE__ */
18 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
22 // Exception used to represent non-CORBA exceptions. A global
23 // instance is used since it will never be modified.
24 CORBA::UNKNOWN
/* const */ unknown_exception
;
29 Invocation_Base::Invocation_Base (CORBA::Object_ptr ot
,
32 TAO_Operation_Details
&details
,
33 bool response_expected
,
34 bool TAO_INTERCEPTOR (request_is_remote
))
36 , forwarded_to_ (nullptr)
37 , response_expected_ (response_expected
)
38 , reply_status_ (GIOP::NO_EXCEPTION
)
42 #if TAO_HAS_INTERCEPTORS == 1
43 , cri_adapter_ (stub_
->orb_core ()->clientrequestinterceptor_adapter ())
44 , sri_adapter_ (stub_
->orb_core ()->serverrequestinterceptor_adapter ())
46 , invoke_status_ (TAO_INVOKE_START
)
47 , caught_exception_ (nullptr)
48 , is_remote_request_ (request_is_remote
)
49 #endif /* TAO_HAS_INTERCEPTORS == 1 */
53 Invocation_Base::~Invocation_Base ()
55 TAO_INTERCEPTOR (cri_adapter_
= nullptr);
56 TAO_INTERCEPTOR (sri_adapter_
= nullptr);
60 Invocation_Base::request_service_context ()
62 return this->details_
.request_service_context ();
66 Invocation_Base::reply_service_context ()
68 return this->details_
.reply_service_context ();
71 #if TAO_HAS_INTERCEPTORS == 1
73 Invocation_Base::send_request_interception ()
79 // This is a begin interception point
80 this->cri_adapter_
->send_request (*this);
82 catch ( ::CORBA::Exception
& ex
)
84 (void) this->handle_any_exception (&ex
);
89 (void) this->handle_all_exception ();
93 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
94 return TAO_INVOKE_RESTART
;
96 this->cri_adapter_
->pushTSC (this->stub_
->orb_core ());
98 else if (sri_adapter_
)
100 this->sri_adapter_
->pushTSC (this->stub_
->orb_core ());
103 // What are the other cases??
104 return TAO_INVOKE_SUCCESS
;
108 Invocation_Base::receive_reply_interception ()
114 this->cri_adapter_
->popTSC (this->stub_
->orb_core ());
115 this->cri_adapter_
->receive_reply (*this);
117 catch ( ::CORBA::Exception
& ex
)
119 (void) this->handle_any_exception (&ex
);
124 (void) this->handle_all_exception ();
128 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
129 return TAO_INVOKE_RESTART
;
131 else if (sri_adapter_
)
133 this->sri_adapter_
->popTSC (this->stub_
->orb_core ());
136 return TAO_INVOKE_SUCCESS
;
140 Invocation_Base::receive_other_interception ()
146 this->cri_adapter_
->popTSC (this->stub_
->orb_core ());
147 this->cri_adapter_
->receive_other (*this);
149 catch ( ::CORBA::Exception
& ex
)
151 (void) this->handle_any_exception (&ex
);
156 (void) this->handle_all_exception ();
160 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
161 return TAO_INVOKE_RESTART
;
163 else if (sri_adapter_
)
165 this->sri_adapter_
->popTSC (this->stub_
->orb_core ());
168 return TAO_INVOKE_SUCCESS
;
171 PortableInterceptor::ReplyStatus
172 Invocation_Base::handle_any_exception (CORBA::Exception
*ex
)
174 this->exception (ex
);
176 PortableInterceptor::ReplyStatus status
=
177 PortableInterceptor::SYSTEM_EXCEPTION
;
181 this->cri_adapter_
->popTSC (this->stub_
->orb_core ());
182 this->cri_adapter_
->receive_exception (*this);
184 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
186 status
= PortableInterceptor::LOCATION_FORWARD
;
190 status
= this->cri_adapter_
->pi_reply_status (*this);
193 else if (sri_adapter_
)
195 this->sri_adapter_
->popTSC (this->stub_
->orb_core ());
201 PortableInterceptor::ReplyStatus
202 Invocation_Base::handle_all_exception ()
204 this->exception (&unknown_exception
);
206 PortableInterceptor::ReplyStatus status
=
207 PortableInterceptor::SYSTEM_EXCEPTION
;
211 this->cri_adapter_
->popTSC (this->stub_
->orb_core ());
212 this->cri_adapter_
->receive_exception (*this);
214 status
= this->cri_adapter_
->pi_reply_status (*this);
216 else if (sri_adapter_
)
218 this->sri_adapter_
->popTSC (this->stub_
->orb_core ());
225 Invocation_Base::exception (CORBA::Exception
*exception
)
227 if (CORBA::SystemException::_downcast (exception
) != nullptr)
228 this->invoke_status_
= TAO::TAO_INVOKE_SYSTEM_EXCEPTION
;
229 else if (CORBA::UserException::_downcast (exception
) != nullptr)
230 this->invoke_status_
= TAO::TAO_INVOKE_USER_EXCEPTION
;
232 this->forwarded_to_
= CORBA::Object::_nil ();
233 this->reply_status_
= GIOP::NO_EXCEPTION
;
234 this->caught_exception_
= exception
;
237 PortableInterceptor::ReplyStatus
238 Invocation_Base::pi_reply_status () const
242 return this->cri_adapter_
->pi_reply_status (*this);
249 #endif /* TAO_HAS_INTERCEPTORS == 1 */
252 TAO_END_VERSIONED_NAMESPACE_DECL