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 # include "tao/ClientRequestInterceptor_Adapter_Factory.h"
00013 #endif
00014
00015 #if !defined (__ACE_INLINE__)
00016 # include "tao/Invocation_Base.inl"
00017 #endif
00018
00019
00020 ACE_RCSID (tao,
00021 Invocation_Base,
00022 "Invocation_Base.cpp,v 1.18 2006/03/10 07:19:05 jtc Exp")
00023
00024
00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00026
00027 namespace TAO
00028 {
00029 Invocation_Base::Invocation_Base (CORBA::Object_ptr ot,
00030 CORBA::Object_ptr t,
00031 TAO_Stub *stub,
00032 TAO_Operation_Details &details,
00033 bool response_expected,
00034 bool request_is_remote)
00035 : details_ (details)
00036 , forwarded_to_ (0)
00037 , response_expected_ (response_expected)
00038 , otarget_ (ot)
00039 , target_ (t)
00040 , orb_core_ (stub->orb_core ())
00041 , stub_ (stub)
00042 #if TAO_HAS_INTERCEPTORS == 1
00043 , adapter_ (orb_core_->clientrequestinterceptor_adapter ())
00044 , stack_size_ (0)
00045 , invoke_status_ (TAO_INVOKE_START)
00046 , caught_exception_ (0)
00047 , is_remote_request_ (request_is_remote)
00048 #endif
00049 {
00050 #if TAO_HAS_INTERCEPTORS == 0
00051 ACE_UNUSED_ARG (request_is_remote);
00052 #endif
00053 }
00054
00055 Invocation_Base::~Invocation_Base (void)
00056 {
00057 #if TAO_HAS_INTERCEPTORS == 1
00058 adapter_ = 0;
00059 #endif
00060 }
00061
00062 void
00063 Invocation_Base::reply_received (Invocation_Status TAO_INTERCEPTOR (s))
00064 {
00065 TAO_INTERCEPTOR (invoke_status_ = s);
00066 }
00067
00068 TAO_Service_Context &
00069 Invocation_Base::request_service_context (void)
00070 {
00071 return this->details_.request_service_context ();
00072 }
00073
00074 TAO_Service_Context &
00075 Invocation_Base::reply_service_context (void)
00076 {
00077 return this->details_.reply_service_context ();
00078 }
00079
00080 #if TAO_HAS_INTERCEPTORS == 1
00081
00082 Invocation_Status
00083 Invocation_Base::send_request_interception (ACE_ENV_SINGLE_ARG_DECL)
00084 ACE_THROW_SPEC ((CORBA::SystemException))
00085 {
00086 if (adapter_ != 0)
00087 {
00088 ACE_TRY
00089 {
00090 this->adapter_->send_request (*this
00091 ACE_ENV_ARG_PARAMETER);
00092 ACE_TRY_CHECK;
00093 }
00094 ACE_CATCHANY
00095 {
00096 (void) this->handle_any_exception (&ACE_ANY_EXCEPTION
00097 ACE_ENV_ARG_PARAMETER);
00098 ACE_TRY_CHECK;
00099
00100
00101 ACE_RE_THROW;
00102 }
00103 # if defined (ACE_HAS_EXCEPTIONS) \
00104 && defined (ACE_HAS_BROKEN_UNEXPECTED_EXCEPTIONS)
00105 ACE_CATCHALL
00106 {
00107 (void) this->handle_all_exception (ACE_ENV_SINGLE_ARG_PARAMETER);
00108 ACE_TRY_CHECK;
00109
00110
00111 ACE_RE_THROW;
00112 }
00113 # endif
00114 ACE_ENDTRY;
00115 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00116
00117 if (this->forwarded_to_.in ())
00118 return TAO_INVOKE_RESTART;
00119 }
00120
00121
00122 return TAO_INVOKE_SUCCESS;
00123 }
00124
00125 Invocation_Status
00126 Invocation_Base::receive_reply_interception (ACE_ENV_SINGLE_ARG_DECL)
00127 ACE_THROW_SPEC ((CORBA::SystemException))
00128 {
00129 if (adapter_ != 0)
00130 {
00131 ACE_TRY
00132 {
00133 this->adapter_->receive_reply (*this
00134 ACE_ENV_ARG_PARAMETER);
00135 ACE_TRY_CHECK;
00136 }
00137 ACE_CATCHANY
00138 {
00139 (void) this->handle_any_exception (&ACE_ANY_EXCEPTION
00140 ACE_ENV_ARG_PARAMETER);
00141 ACE_TRY_CHECK;
00142
00143 ACE_RE_THROW;
00144 }
00145 # if defined (ACE_HAS_EXCEPTIONS) \
00146 && defined (ACE_HAS_BROKEN_UNEXPECTED_EXCEPTIONS)
00147 ACE_CATCHALL
00148 {
00149 (void) this->handle_all_exception (ACE_ENV_SINGLE_ARG_PARAMETER);
00150 ACE_TRY_CHECK;
00151
00152 ACE_RE_THROW;
00153 }
00154 # endif
00155 ACE_ENDTRY;
00156 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00157
00158 const PortableInterceptor::ReplyStatus status =
00159 this->adapter_->reply_status (*this);
00160
00161 if (status == PortableInterceptor::LOCATION_FORWARD ||
00162 status == PortableInterceptor::TRANSPORT_RETRY)
00163 return TAO_INVOKE_RESTART;
00164 }
00165
00166 return TAO_INVOKE_SUCCESS;
00167 }
00168
00169
00170 Invocation_Status
00171 Invocation_Base::receive_other_interception (ACE_ENV_SINGLE_ARG_DECL)
00172 ACE_THROW_SPEC ((CORBA::SystemException))
00173 {
00174 if (adapter_ != 0)
00175 {
00176 ACE_TRY
00177 {
00178 this->adapter_->receive_other (*this
00179 ACE_ENV_ARG_PARAMETER);
00180 ACE_TRY_CHECK;
00181 }
00182 ACE_CATCHANY
00183 {
00184 (void) this->handle_any_exception (&ACE_ANY_EXCEPTION
00185 ACE_ENV_ARG_PARAMETER);
00186 ACE_TRY_CHECK;
00187
00188 ACE_RE_THROW;
00189 }
00190 # if defined (ACE_HAS_EXCEPTIONS) \
00191 && defined (ACE_HAS_BROKEN_UNEXPECTED_EXCEPTIONS)
00192 ACE_CATCHALL
00193 {
00194 (void) this->handle_all_exception (ACE_ENV_SINGLE_ARG_PARAMETER);
00195 ACE_TRY_CHECK;
00196
00197 ACE_RE_THROW;
00198 }
00199 # endif
00200 ACE_ENDTRY;
00201 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00202
00203 if (this->forwarded_to_.in ())
00204 return TAO_INVOKE_RESTART;
00205 }
00206
00207 return TAO_INVOKE_SUCCESS;
00208 }
00209
00210 PortableInterceptor::ReplyStatus
00211 Invocation_Base::handle_any_exception (CORBA::Exception *ex
00212 ACE_ENV_ARG_DECL)
00213 {
00214 this->exception (ex);
00215
00216 PortableInterceptor::ReplyStatus status =
00217 PortableInterceptor::SYSTEM_EXCEPTION;
00218
00219 if (adapter_ != 0)
00220 {
00221 this->adapter_->receive_exception (*this
00222 ACE_ENV_ARG_PARAMETER);
00223 ACE_CHECK_RETURN (PortableInterceptor::UNKNOWN);
00224
00225 status =
00226 this->adapter_->reply_status (*this);
00227 }
00228
00229 return status;
00230 }
00231
00232 PortableInterceptor::ReplyStatus
00233 Invocation_Base::handle_all_exception (ACE_ENV_SINGLE_ARG_DECL)
00234 {
00235 CORBA::UNKNOWN ex;
00236 this->exception (&ex);
00237
00238 PortableInterceptor::ReplyStatus status =
00239 PortableInterceptor::SYSTEM_EXCEPTION;
00240
00241 if (adapter_ != 0)
00242 {
00243 this->adapter_->receive_exception (*this
00244 ACE_ENV_ARG_PARAMETER);
00245 ACE_CHECK_RETURN (PortableInterceptor::UNKNOWN);
00246
00247 status =
00248 this->adapter_->reply_status (*this);
00249 }
00250
00251 return status;
00252 }
00253
00254 void
00255 Invocation_Base::exception (CORBA::Exception *exception)
00256 {
00257 if (CORBA::SystemException::_downcast (exception) != 0)
00258 this->invoke_status_ = TAO::TAO_INVOKE_SYSTEM_EXCEPTION;
00259 else if (CORBA::UserException::_downcast (exception) != 0)
00260 this->invoke_status_ = TAO::TAO_INVOKE_USER_EXCEPTION;
00261
00262 this->caught_exception_ = exception;
00263 }
00264
00265 PortableInterceptor::ReplyStatus
00266 Invocation_Base::reply_status (void) const
00267 {
00268 if (adapter_ != 0)
00269 {
00270 return this->adapter_->reply_status (*this);
00271 }
00272 else
00273 {
00274 return -1;
00275 }
00276 }
00277 #endif
00278 }
00279
00280 TAO_END_VERSIONED_NAMESPACE_DECL