s/Uint/UInt/g
[ACE_TAO.git] / TAO / tao / Collocated_Invocation.cpp
blobe4b01c4a8820757a086af01a2cf4fb19ca1568a6
1 #include "tao/Collocated_Invocation.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/Request_Dispatcher.h"
4 #include "tao/TAO_Server_Request.h"
5 #include "tao/Stub.h"
6 #include "tao/operation_details.h"
7 #include "tao/PortableInterceptor.h"
8 #include "tao/SystemException.h"
9 #include "tao/Abstract_Servant_Base.h"
11 #if TAO_HAS_INTERCEPTORS == 1
12 # include "tao/PortableInterceptorC.h"
13 #endif /*TAO_HAS_INTERCEPTORS */
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 namespace TAO
19 Collocated_Invocation::Collocated_Invocation (CORBA::Object_ptr t,
20 CORBA::Object_ptr et,
21 TAO_Stub *stub,
22 TAO_Operation_Details &detail,
23 bool response_expected)
24 : Invocation_Base (t,
25 et,
26 stub,
27 detail,
28 response_expected,
29 false /* request_is_remote */ )
33 Invocation_Status
34 Collocated_Invocation::invoke (Collocation_Strategy strat)
36 Invocation_Status s = TAO_INVOKE_FAILURE;
38 /// Start the interception point
39 #if TAO_HAS_INTERCEPTORS == 1
40 s = this->send_request_interception ();
42 if (s != TAO_INVOKE_SUCCESS)
43 return s;
44 #endif /*TAO_HAS_INTERCEPTORS */
46 try
48 if (strat == TAO_CS_THRU_POA_STRATEGY)
50 // Perform invocations on the servant through the servant's ORB.
51 CORBA::ORB_var servant_orb =
52 this->effective_target ()->_stubobj ()->servant_orb_ptr ();
53 TAO_ORB_Core * const orb_core = servant_orb->orb_core ();
55 TAO_ServerRequest request (orb_core,
56 this->details_,
57 this->effective_target ());
59 TAO_Request_Dispatcher * const dispatcher =
60 orb_core->request_dispatcher ();
62 // Retain ownership of the servant's ORB_Core in case
63 // another thread attempts to destroy it (e.g. via
64 // CORBA::ORB::destroy()) before this thread complete the
65 // invocation.
66 orb_core->_incr_refcnt ();
67 TAO_ORB_Core_Auto_Ptr my_orb_core (orb_core);
69 dispatcher->dispatch (orb_core,
70 request,
71 this->forwarded_to_.out ());
73 if (request.is_forwarded ())
75 this->reply_status_ = GIOP::LOCATION_FORWARD;
78 else
80 bool is_forwarded = false;
82 this->effective_target ()->_servant()->_collocated_dispatch (
83 this->effective_target (),
84 this->forwarded_to_.out (),
85 is_forwarded,
86 this->details_.args (),
87 this->details_.args_num (),
88 this->details_.opname (),
89 this->details_.opname_len (),
90 strat);
92 if (is_forwarded)
94 this->reply_status_ = GIOP::LOCATION_FORWARD;
98 // Invocation completed successfully
99 s = TAO_INVOKE_SUCCESS;
101 #if TAO_HAS_INTERCEPTORS == 1
102 if (this->reply_status_ == GIOP::LOCATION_FORWARD ||
103 this->response_expected_ == false)
105 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
106 this->invoke_status (TAO_INVOKE_RESTART);
108 s = this->receive_other_interception ();
110 // NOTE: Any other condition that needs handling?
111 else if (this->response_expected ())
113 this->invoke_status (TAO_INVOKE_SUCCESS);
115 s = this->receive_reply_interception ();
117 if (s != TAO_INVOKE_SUCCESS)
118 return s;
119 #endif /*TAO_HAS_INTERCEPTORS */
121 catch ( ::CORBA::UserException& ex)
123 // Ignore CORBA exceptions for oneways
124 if (this->response_expected_ == false)
125 return TAO_INVOKE_SUCCESS;
127 #if TAO_HAS_INTERCEPTORS == 1
128 PortableInterceptor::ReplyStatus const status =
129 this->handle_any_exception (&ex);
131 if (status == PortableInterceptor::LOCATION_FORWARD ||
132 status == PortableInterceptor::TRANSPORT_RETRY)
133 s = TAO_INVOKE_RESTART;
134 else
135 #endif /* TAO_HAS_INTERCEPTORS */
137 // Check whether the user exception thrown matches the signature
138 // list, if not, then throw an Unknown exception
139 if (!this->details_.has_exception (ex))
141 throw ::CORBA::UNKNOWN (CORBA::OMGVMCID | 1,
142 CORBA::COMPLETED_MAYBE);
144 else
146 throw;
150 catch ( ::CORBA::SystemException& TAO_INTERCEPTOR (ex))
152 // Ignore CORBA exceptions for oneways
153 if (this->response_expected_ == false)
154 return TAO_INVOKE_SUCCESS;
156 #if TAO_HAS_INTERCEPTORS == 1
157 PortableInterceptor::ReplyStatus const status =
158 this->handle_any_exception (&ex);
160 if (status == PortableInterceptor::LOCATION_FORWARD ||
161 status == PortableInterceptor::TRANSPORT_RETRY)
162 s = TAO_INVOKE_RESTART;
163 else
164 #endif /* TAO_HAS_INTERCEPTORS */
165 throw;
167 #if TAO_HAS_INTERCEPTORS == 1
168 catch (...)
170 // Notify interceptors of non-CORBA exception, and propagate
171 // that exception to the caller.
172 PortableInterceptor::ReplyStatus const st =
173 this->handle_all_exception ();
175 if (st == PortableInterceptor::LOCATION_FORWARD ||
176 st == PortableInterceptor::TRANSPORT_RETRY)
177 s = TAO_INVOKE_RESTART;
178 else
179 throw;
181 #endif /* TAO_HAS_INTERCEPTORS == 1 */
183 if (this->reply_status_ == GIOP::LOCATION_FORWARD)
184 s = TAO_INVOKE_RESTART;
186 return s;
191 TAO_END_VERSIONED_NAMESPACE_DECL