00001 #include "tao/Collocated_Invocation.h"
00002 #include "tao/Collocation_Proxy_Broker.h"
00003 #include "tao/ORB_Core.h"
00004 #include "tao/Request_Dispatcher.h"
00005 #include "tao/TAO_Server_Request.h"
00006 #include "tao/Stub.h"
00007 #include "tao/operation_details.h"
00008 #include "tao/PortableInterceptor.h"
00009 #include "tao/SystemException.h"
00010
00011 #if TAO_HAS_INTERCEPTORS == 1
00012 # include "tao/PortableInterceptorC.h"
00013 #endif
00014
00015 ACE_RCSID (tao,
00016 Collocated_Invocation,
00017 "$Id: Collocated_Invocation.cpp 81632 2008-05-07 09:19:05Z vzykov $")
00018
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 namespace TAO
00023 {
00024 Collocated_Invocation::Collocated_Invocation (CORBA::Object_ptr t,
00025 CORBA::Object_ptr et,
00026 TAO_Stub *stub,
00027 TAO_Operation_Details &detail,
00028 bool response_expected)
00029 : Invocation_Base (t,
00030 et,
00031 stub,
00032 detail,
00033 response_expected,
00034 false )
00035 {
00036 }
00037
00038 Invocation_Status
00039 Collocated_Invocation::invoke (Collocation_Proxy_Broker *cpb,
00040 Collocation_Strategy strat)
00041 {
00042 Invocation_Status s = TAO_INVOKE_FAILURE;
00043
00044
00045 #if TAO_HAS_INTERCEPTORS == 1
00046 s = this->send_request_interception ();
00047
00048 if (s != TAO_INVOKE_SUCCESS)
00049 return s;
00050 #endif
00051
00052 try
00053 {
00054 if (strat == TAO_CS_THRU_POA_STRATEGY)
00055 {
00056
00057 CORBA::ORB_var servant_orb =
00058 this->effective_target ()->_stubobj ()->servant_orb_ptr ();
00059 TAO_ORB_Core * const orb_core = servant_orb->orb_core ();
00060
00061 TAO_ServerRequest request (orb_core,
00062 this->details_,
00063 this->effective_target ());
00064
00065 TAO_Request_Dispatcher * const dispatcher =
00066 orb_core->request_dispatcher ();
00067
00068
00069
00070
00071
00072 orb_core->_incr_refcnt ();
00073 TAO_ORB_Core_Auto_Ptr my_orb_core (orb_core);
00074
00075 dispatcher->dispatch (orb_core,
00076 request,
00077 this->forwarded_to_.out ());
00078
00079 if (request.is_forwarded ())
00080 {
00081 this->reply_status_ = GIOP::LOCATION_FORWARD;
00082 }
00083 }
00084 else
00085 {
00086 bool is_forwarded = false;
00087
00088 cpb->dispatch (this->effective_target (),
00089 this->forwarded_to_.out (),
00090 is_forwarded,
00091 this->details_.args (),
00092 this->details_.args_num (),
00093 this->details_.opname (),
00094 this->details_.opname_len (),
00095 strat);
00096
00097 if (is_forwarded)
00098 {
00099 this->reply_status_ = GIOP::LOCATION_FORWARD;
00100 }
00101 }
00102
00103
00104 s = TAO_INVOKE_SUCCESS;
00105
00106 #if TAO_HAS_INTERCEPTORS == 1
00107 if (this->reply_status_ == GIOP::LOCATION_FORWARD ||
00108 this->response_expected_ == false)
00109 {
00110 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00111 this->invoke_status (TAO_INVOKE_RESTART);
00112
00113 s = this->receive_other_interception ();
00114 }
00115
00116 else if (this->response_expected ())
00117 {
00118 this->invoke_status (TAO_INVOKE_SUCCESS);
00119
00120 s = this->receive_reply_interception ();
00121 }
00122 if (s != TAO_INVOKE_SUCCESS)
00123 return s;
00124 #endif
00125 }
00126 catch ( ::CORBA::UserException& ex)
00127 {
00128
00129 if (this->response_expected_ == false)
00130 return TAO_INVOKE_SUCCESS;
00131
00132 #if TAO_HAS_INTERCEPTORS == 1
00133 PortableInterceptor::ReplyStatus const status =
00134 this->handle_any_exception (&ex);
00135
00136 if (status == PortableInterceptor::LOCATION_FORWARD ||
00137 status == PortableInterceptor::TRANSPORT_RETRY)
00138 s = TAO_INVOKE_RESTART;
00139 else
00140 #endif
00141 {
00142
00143
00144 if (!this->details_.has_exception (ex))
00145 {
00146 throw ::CORBA::UNKNOWN (CORBA::OMGVMCID | 1,
00147 CORBA::COMPLETED_MAYBE);
00148 }
00149 else
00150 {
00151 throw;
00152 }
00153 }
00154 }
00155 catch ( ::CORBA::SystemException& TAO_INTERCEPTOR (ex))
00156 {
00157
00158 if (this->response_expected_ == false)
00159 return TAO_INVOKE_SUCCESS;
00160
00161 #if TAO_HAS_INTERCEPTORS == 1
00162 PortableInterceptor::ReplyStatus const status =
00163 this->handle_any_exception (&ex);
00164
00165 if (status == PortableInterceptor::LOCATION_FORWARD ||
00166 status == PortableInterceptor::TRANSPORT_RETRY)
00167 s = TAO_INVOKE_RESTART;
00168 else
00169 #endif
00170 throw;
00171 }
00172 #if TAO_HAS_INTERCEPTORS == 1
00173 catch (...)
00174 {
00175
00176
00177 PortableInterceptor::ReplyStatus const st =
00178 this->handle_all_exception ();
00179
00180 if (st == PortableInterceptor::LOCATION_FORWARD ||
00181 st == PortableInterceptor::TRANSPORT_RETRY)
00182 s = TAO_INVOKE_RESTART;
00183 else
00184 throw;
00185 }
00186 #endif
00187
00188 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
00189 s = TAO_INVOKE_RESTART;
00190
00191 return s;
00192 }
00193
00194 }
00195
00196 TAO_END_VERSIONED_NAMESPACE_DECL