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 76995 2007-02-11 12:51:42Z johnnyw $")
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 else
00080 {
00081 cpb->dispatch (this->effective_target (),
00082 this->forwarded_to_.out (),
00083 this->details_.args (),
00084 this->details_.args_num (),
00085 this->details_.opname (),
00086 this->details_.opname_len (),
00087 strat);
00088 }
00089
00090
00091 s = TAO_INVOKE_SUCCESS;
00092
00093 #if TAO_HAS_INTERCEPTORS == 1
00094 if (this->forwarded_to_.in () ||
00095 this->response_expected_ == false)
00096 {
00097 if (this->forwarded_to_.in ())
00098 this->reply_received (TAO_INVOKE_RESTART);
00099
00100 s = this->receive_other_interception ();
00101 }
00102
00103 else if (this->response_expected ())
00104 {
00105 this->reply_received (TAO_INVOKE_SUCCESS);
00106
00107 s = this->receive_reply_interception ();
00108 }
00109 if (s != TAO_INVOKE_SUCCESS)
00110 return s;
00111 #endif
00112 }
00113 catch ( ::CORBA::UserException& ex)
00114 {
00115
00116 if (this->response_expected_ == false)
00117 return TAO_INVOKE_SUCCESS;
00118
00119 #if TAO_HAS_INTERCEPTORS == 1
00120 PortableInterceptor::ReplyStatus const status =
00121 this->handle_any_exception (&ex);
00122
00123 if (status == PortableInterceptor::LOCATION_FORWARD ||
00124 status == PortableInterceptor::TRANSPORT_RETRY)
00125 s = TAO_INVOKE_RESTART;
00126 else
00127 #endif
00128 {
00129
00130
00131 if (!this->details_.has_exception (ex))
00132 {
00133 throw ::CORBA::UNKNOWN (CORBA::OMGVMCID | 1,
00134 CORBA::COMPLETED_MAYBE);
00135 }
00136 else
00137 {
00138 throw;
00139 }
00140 }
00141 }
00142 catch ( ::CORBA::SystemException& TAO_INTERCEPTOR (ex))
00143 {
00144
00145 if (this->response_expected_ == false)
00146 return TAO_INVOKE_SUCCESS;
00147
00148 #if TAO_HAS_INTERCEPTORS == 1
00149 PortableInterceptor::ReplyStatus const status =
00150 this->handle_any_exception (&ex);
00151
00152 if (status == PortableInterceptor::LOCATION_FORWARD ||
00153 status == PortableInterceptor::TRANSPORT_RETRY)
00154 s = TAO_INVOKE_RESTART;
00155 else
00156 #endif
00157 throw;
00158 }
00159 #if TAO_HAS_INTERCEPTORS == 1
00160 catch (...)
00161 {
00162
00163
00164 PortableInterceptor::ReplyStatus const st =
00165 this->handle_all_exception ();
00166
00167 if (st == PortableInterceptor::LOCATION_FORWARD ||
00168 st == PortableInterceptor::TRANSPORT_RETRY)
00169 s = TAO_INVOKE_RESTART;
00170 else
00171 throw;
00172 }
00173 #endif
00174
00175 if (this->forwarded_to_.in () != 0)
00176 s = TAO_INVOKE_RESTART;
00177
00178 return s;
00179 }
00180
00181 }
00182
00183 TAO_END_VERSIONED_NAMESPACE_DECL