Go to the documentation of this file.00001 #include "tao/Invocation_Base.h"
00002 #include "tao/Stub.h"
00003 #include "tao/operation_details.h"
00004 #include "tao/ORB_Core.h"
00005 #include "tao/SystemException.h"
00006 #include "tao/PortableInterceptor.h"
00007
00008 #include "ace/Dynamic_Service.h"
00009
00010 #if TAO_HAS_INTERCEPTORS == 1
00011 # include "tao/PortableInterceptorC.h"
00012 #endif
00013
00014 #if !defined (__ACE_INLINE__)
00015 # include "tao/Invocation_Base.inl"
00016 #endif
00017
00018 ACE_RCSID (tao,
00019 Invocation_Base,
00020 "$Id: Invocation_Base.cpp 85400 2009-05-19 12:13:48Z sma $")
00021
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024 namespace
00025 {
00026
00027
00028 CORBA::UNKNOWN unknown_exception;
00029 }
00030
00031 namespace TAO
00032 {
00033 Invocation_Base::Invocation_Base (CORBA::Object_ptr ot,
00034 CORBA::Object_ptr t,
00035 TAO_Stub *stub,
00036 TAO_Operation_Details &details,
00037 bool response_expected,
00038 bool TAO_INTERCEPTOR (request_is_remote))
00039 : details_ (details)
00040 , forwarded_to_ (0)
00041 , response_expected_ (response_expected)
00042 , reply_status_ (GIOP::NO_EXCEPTION)
00043 , otarget_ (ot)
00044 , target_ (t)
00045 , stub_ (stub)
00046 #if TAO_HAS_INTERCEPTORS == 1
00047 , cri_adapter_ (stub_->orb_core ()->clientrequestinterceptor_adapter ())
00048 , sri_adapter_ (stub_->orb_core ()->serverrequestinterceptor_adapter ())
00049 , stack_size_ (0)
00050 , invoke_status_ (TAO_INVOKE_START)
00051 , caught_exception_ (0)
00052 , is_remote_request_ (request_is_remote)
00053 #endif
00054 {
00055 }
00056
00057 Invocation_Base::~Invocation_Base (void)
00058 {
00059 TAO_INTERCEPTOR (cri_adapter_= 0);
00060 TAO_INTERCEPTOR (sri_adapter_= 0);
00061 }
00062
00063 TAO_Service_Context &
00064 Invocation_Base::request_service_context (void)
00065 {
00066 return this->details_.request_service_context ();
00067 }
00068
00069 TAO_Service_Context &
00070 Invocation_Base::reply_service_context (void)
00071 {
00072 return this->details_.reply_service_context ();
00073 }
00074
00075 #if TAO_HAS_INTERCEPTORS == 1
00076 Invocation_Status
00077 Invocation_Base::send_request_interception (void)
00078 {
00079 if (cri_adapter_)
00080 {
00081 try
00082 {
00083
00084 this->cri_adapter_->send_request (*this);
00085 }
00086 catch ( ::CORBA::Exception& ex)
00087 {
00088 (void) this->handle_any_exception (&ex);
00089 throw;
00090 }
00091 catch (...)
00092 {
00093 (void) this->handle_all_exception ();
00094 throw;
00095 }
00096
00097 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00098 return TAO_INVOKE_RESTART;
00099
00100 this->cri_adapter_->pushTSC (this->stub_->orb_core ());
00101 }
00102 else if (sri_adapter_)
00103 {
00104 this->sri_adapter_->pushTSC (this->stub_->orb_core ());
00105 }
00106
00107
00108 return TAO_INVOKE_SUCCESS;
00109 }
00110
00111 Invocation_Status
00112 Invocation_Base::receive_reply_interception (void)
00113 {
00114 if (cri_adapter_)
00115 {
00116 try
00117 {
00118 this->cri_adapter_->popTSC (this->stub_->orb_core ());
00119 this->cri_adapter_->receive_reply (*this);
00120 }
00121 catch ( ::CORBA::Exception& ex)
00122 {
00123 (void) this->handle_any_exception (&ex);
00124 throw;
00125 }
00126 catch (...)
00127 {
00128 (void) this->handle_all_exception ();
00129 throw;
00130 }
00131
00132 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00133 return TAO_INVOKE_RESTART;
00134 }
00135 else if (sri_adapter_)
00136 {
00137 this->sri_adapter_->popTSC (this->stub_->orb_core ());
00138 }
00139
00140 return TAO_INVOKE_SUCCESS;
00141 }
00142
00143 Invocation_Status
00144 Invocation_Base::receive_other_interception (void)
00145 {
00146 if (cri_adapter_)
00147 {
00148 try
00149 {
00150 this->cri_adapter_->popTSC (this->stub_->orb_core ());
00151 this->cri_adapter_->receive_other (*this);
00152 }
00153 catch ( ::CORBA::Exception& ex)
00154 {
00155 (void) this->handle_any_exception (&ex);
00156 throw;
00157 }
00158 catch (...)
00159 {
00160 (void) this->handle_all_exception ();
00161 throw;
00162 }
00163
00164 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00165 return TAO_INVOKE_RESTART;
00166 }
00167 else if (sri_adapter_)
00168 {
00169 this->sri_adapter_->popTSC (this->stub_->orb_core ());
00170 }
00171
00172 return TAO_INVOKE_SUCCESS;
00173 }
00174
00175 PortableInterceptor::ReplyStatus
00176 Invocation_Base::handle_any_exception (CORBA::Exception *ex)
00177 {
00178 this->exception (ex);
00179
00180 PortableInterceptor::ReplyStatus status =
00181 PortableInterceptor::SYSTEM_EXCEPTION;
00182
00183 if (cri_adapter_)
00184 {
00185 this->cri_adapter_->popTSC (this->stub_->orb_core ());
00186 this->cri_adapter_->receive_exception (*this);
00187
00188 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00189 {
00190 status = PortableInterceptor::LOCATION_FORWARD;
00191 }
00192 else
00193 {
00194 status = this->cri_adapter_->pi_reply_status (*this);
00195 }
00196 }
00197 else if (sri_adapter_)
00198 {
00199 this->sri_adapter_->popTSC (this->stub_->orb_core ());
00200 }
00201
00202 return status;
00203 }
00204
00205 PortableInterceptor::ReplyStatus
00206 Invocation_Base::handle_all_exception (void)
00207 {
00208 this->exception (&unknown_exception);
00209
00210 PortableInterceptor::ReplyStatus status =
00211 PortableInterceptor::SYSTEM_EXCEPTION;
00212
00213 if (cri_adapter_)
00214 {
00215 this->cri_adapter_->popTSC (this->stub_->orb_core ());
00216 this->cri_adapter_->receive_exception (*this);
00217
00218 status = this->cri_adapter_->pi_reply_status (*this);
00219 }
00220 else if (sri_adapter_)
00221 {
00222 this->sri_adapter_->popTSC (this->stub_->orb_core ());
00223 }
00224
00225 return status;
00226 }
00227
00228 void
00229 Invocation_Base::exception (CORBA::Exception *exception)
00230 {
00231 if (CORBA::SystemException::_downcast (exception) != 0)
00232 this->invoke_status_ = TAO::TAO_INVOKE_SYSTEM_EXCEPTION;
00233 else if (CORBA::UserException::_downcast (exception) != 0)
00234 this->invoke_status_ = TAO::TAO_INVOKE_USER_EXCEPTION;
00235
00236 this->forwarded_to_ = CORBA::Object::_nil ();
00237 this->reply_status_ = GIOP::NO_EXCEPTION;
00238 this->caught_exception_ = exception;
00239 }
00240
00241 PortableInterceptor::ReplyStatus
00242 Invocation_Base::pi_reply_status (void) const
00243 {
00244 if (cri_adapter_)
00245 {
00246 return this->cri_adapter_->pi_reply_status (*this);
00247 }
00248 else
00249 {
00250 return -1;
00251 }
00252 }
00253 #endif
00254 }
00255
00256 TAO_END_VERSIONED_NAMESPACE_DECL