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"
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
19 Collocated_Invocation::Collocated_Invocation (CORBA::Object_ptr t
,
22 TAO_Operation_Details
&detail
,
23 bool response_expected
)
29 false /* request_is_remote */ )
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
)
44 #endif /*TAO_HAS_INTERCEPTORS */
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
,
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
66 orb_core
->_incr_refcnt ();
67 TAO_ORB_Core_Auto_Ptr
my_orb_core (orb_core
);
69 dispatcher
->dispatch (orb_core
, request
, this->forwarded_to_
.out ());
71 if (request
.is_forwarded ())
73 this->reply_status_
= GIOP::LOCATION_FORWARD
;
78 bool is_forwarded
= false;
80 this->effective_target ()->_servant()->_collocated_dispatch (
81 this->effective_target (),
82 this->forwarded_to_
.out (),
84 this->details_
.args (),
85 this->details_
.args_num (),
86 this->details_
.opname (),
87 this->details_
.opname_len (),
92 this->reply_status_
= GIOP::LOCATION_FORWARD
;
96 // Invocation completed successfully
97 s
= TAO_INVOKE_SUCCESS
;
99 #if TAO_HAS_INTERCEPTORS == 1
100 if (this->reply_status_
== GIOP::LOCATION_FORWARD
||
101 this->response_expected_
== false)
103 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
104 this->invoke_status (TAO_INVOKE_RESTART
);
106 s
= this->receive_other_interception ();
108 // NOTE: Any other condition that needs handling?
109 else if (this->response_expected ())
111 this->invoke_status (TAO_INVOKE_SUCCESS
);
113 s
= this->receive_reply_interception ();
115 if (s
!= TAO_INVOKE_SUCCESS
)
117 #endif /*TAO_HAS_INTERCEPTORS */
119 catch ( ::CORBA::UserException
& ex
)
121 // Ignore CORBA exceptions for oneways
122 if (this->response_expected_
== false)
123 return TAO_INVOKE_SUCCESS
;
125 #if TAO_HAS_INTERCEPTORS == 1
126 PortableInterceptor::ReplyStatus
const status
=
127 this->handle_any_exception (&ex
);
129 if (status
== PortableInterceptor::LOCATION_FORWARD
||
130 status
== PortableInterceptor::TRANSPORT_RETRY
)
131 s
= TAO_INVOKE_RESTART
;
133 #endif /* TAO_HAS_INTERCEPTORS */
135 // Check whether the user exception thrown matches the signature
136 // list, if not, then throw an Unknown exception
137 if (!this->details_
.has_exception (ex
))
139 throw ::CORBA::UNKNOWN (CORBA::OMGVMCID
| 1,
140 CORBA::COMPLETED_MAYBE
);
148 catch ( ::CORBA::SystemException
& TAO_INTERCEPTOR (ex
))
150 // Ignore CORBA exceptions for oneways
151 if (this->response_expected_
== false)
152 return TAO_INVOKE_SUCCESS
;
154 #if TAO_HAS_INTERCEPTORS == 1
155 PortableInterceptor::ReplyStatus
const status
=
156 this->handle_any_exception (&ex
);
158 if (status
== PortableInterceptor::LOCATION_FORWARD
||
159 status
== PortableInterceptor::TRANSPORT_RETRY
)
160 s
= TAO_INVOKE_RESTART
;
162 #endif /* TAO_HAS_INTERCEPTORS */
165 #if TAO_HAS_INTERCEPTORS == 1
168 // Notify interceptors of non-CORBA exception, and propagate
169 // that exception to the caller.
170 PortableInterceptor::ReplyStatus
const st
=
171 this->handle_all_exception ();
173 if (st
== PortableInterceptor::LOCATION_FORWARD
||
174 st
== PortableInterceptor::TRANSPORT_RETRY
)
175 s
= TAO_INVOKE_RESTART
;
179 #endif /* TAO_HAS_INTERCEPTORS == 1 */
181 if (this->reply_status_
== GIOP::LOCATION_FORWARD
)
182 s
= TAO_INVOKE_RESTART
;
189 TAO_END_VERSIONED_NAMESPACE_DECL