summaryrefslogtreecommitdiff
path: root/TAO/tao/Invocation_Base.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/Invocation_Base.cpp')
-rw-r--r--TAO/tao/Invocation_Base.cpp244
1 files changed, 244 insertions, 0 deletions
diff --git a/TAO/tao/Invocation_Base.cpp b/TAO/tao/Invocation_Base.cpp
new file mode 100644
index 00000000000..48a0a6f557a
--- /dev/null
+++ b/TAO/tao/Invocation_Base.cpp
@@ -0,0 +1,244 @@
+#include "tao/Invocation_Base.h"
+#include "tao/Stub.h"
+#include "tao/operation_details.h"
+#include "tao/ORB_Core.h"
+#include "tao/SystemException.h"
+#include "tao/PortableInterceptor.h" /* Must always be visible. */
+
+#include "ace/Dynamic_Service.h"
+
+#if TAO_HAS_INTERCEPTORS == 1
+# include "tao/PortableInterceptorC.h"
+# include "tao/ClientRequestInterceptor_Adapter_Factory.h"
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+
+#if !defined (__ACE_INLINE__)
+# include "tao/Invocation_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+
+ACE_RCSID (tao,
+ Invocation_Base,
+ "$Id$")
+
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace
+{
+ // Exception used to represent non-CORBA exceptions. A global
+ // instance is used since it will never be modified.
+ CORBA::UNKNOWN /* const */ unknown_exception;
+}
+
+namespace TAO
+{
+ Invocation_Base::Invocation_Base (CORBA::Object_ptr ot,
+ CORBA::Object_ptr t,
+ TAO_Stub *stub,
+ TAO_Operation_Details &details,
+ bool response_expected,
+ bool TAO_INTERCEPTOR (request_is_remote))
+ : details_ (details)
+ , forwarded_to_ (0)
+ , response_expected_ (response_expected)
+ , otarget_ (ot)
+ , target_ (t)
+ , orb_core_ (stub->orb_core ())
+ , stub_ (stub)
+#if TAO_HAS_INTERCEPTORS == 1
+ , adapter_ (orb_core_->clientrequestinterceptor_adapter ())
+ , stack_size_ (0)
+ , invoke_status_ (TAO_INVOKE_START)
+ , caught_exception_ (0)
+ , is_remote_request_ (request_is_remote)
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+ {
+ }
+
+ Invocation_Base::~Invocation_Base (void)
+ {
+#if TAO_HAS_INTERCEPTORS == 1
+ adapter_ = 0;
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+ }
+
+ void
+ Invocation_Base::reply_received (Invocation_Status TAO_INTERCEPTOR (s))
+ {
+ TAO_INTERCEPTOR (invoke_status_ = s);
+ }
+
+ TAO_Service_Context &
+ Invocation_Base::request_service_context (void)
+ {
+ return this->details_.request_service_context ();
+ }
+
+ TAO_Service_Context &
+ Invocation_Base::reply_service_context (void)
+ {
+ return this->details_.reply_service_context ();
+ }
+
+#if TAO_HAS_INTERCEPTORS == 1
+
+ Invocation_Status
+ Invocation_Base::send_request_interception (void)
+ {
+ if (adapter_ != 0)
+ {
+ try
+ {
+ // This is a begin interception point
+ this->adapter_->send_request (*this);
+ }
+ catch ( ::CORBA::Exception& ex)
+ {
+ (void) this->handle_any_exception (&ex);
+ throw;
+ }
+ catch (...)
+ {
+ (void) this->handle_all_exception ();
+ throw;
+ }
+
+ if (this->forwarded_to_.in ())
+ return TAO_INVOKE_RESTART;
+ }
+
+ // What are the other cases??
+ return TAO_INVOKE_SUCCESS;
+ }
+
+ Invocation_Status
+ Invocation_Base::receive_reply_interception (void)
+ {
+ if (adapter_ != 0)
+ {
+ try
+ {
+ this->adapter_->receive_reply (*this);
+ }
+ catch ( ::CORBA::Exception& ex)
+ {
+ (void) this->handle_any_exception (&ex);
+ throw;
+ }
+ catch (...)
+ {
+ (void) this->handle_all_exception ();
+ throw;
+ }
+
+ PortableInterceptor::ReplyStatus const status =
+ this->adapter_->reply_status (*this);
+
+ if (status == PortableInterceptor::LOCATION_FORWARD ||
+ status == PortableInterceptor::TRANSPORT_RETRY)
+ return TAO_INVOKE_RESTART;
+ }
+
+ return TAO_INVOKE_SUCCESS;
+ }
+
+
+ Invocation_Status
+ Invocation_Base::receive_other_interception (void)
+ {
+ if (adapter_ != 0)
+ {
+ try
+ {
+ this->adapter_->receive_other (*this);
+ }
+ catch ( ::CORBA::Exception& ex)
+ {
+ (void) this->handle_any_exception (&ex);
+ throw;
+ }
+ catch (...)
+ {
+ (void) this->handle_all_exception ();
+ throw;
+ }
+
+ if (this->forwarded_to_.in ())
+ return TAO_INVOKE_RESTART;
+ }
+
+ return TAO_INVOKE_SUCCESS;
+ }
+
+ PortableInterceptor::ReplyStatus
+ Invocation_Base::handle_any_exception (CORBA::Exception *ex)
+ {
+ this->exception (ex);
+
+ PortableInterceptor::ReplyStatus status =
+ PortableInterceptor::SYSTEM_EXCEPTION;
+
+ if (adapter_ != 0)
+ {
+ this->adapter_->receive_exception (*this);
+
+ if (this->forwarded_to_.in ())
+ {
+ status = PortableInterceptor::LOCATION_FORWARD;
+ }
+ else
+ {
+ status = this->adapter_->reply_status (*this);
+ }
+ }
+
+ return status;
+ }
+
+ PortableInterceptor::ReplyStatus
+ Invocation_Base::handle_all_exception (void)
+ {
+ this->exception (&unknown_exception);
+
+ PortableInterceptor::ReplyStatus status =
+ PortableInterceptor::SYSTEM_EXCEPTION;
+
+ if (adapter_ != 0)
+ {
+ this->adapter_->receive_exception (*this);
+
+ status = this->adapter_->reply_status (*this);
+ }
+
+ return status;
+ }
+
+ void
+ Invocation_Base::exception (CORBA::Exception *exception)
+ {
+ if (CORBA::SystemException::_downcast (exception) != 0)
+ this->invoke_status_ = TAO::TAO_INVOKE_SYSTEM_EXCEPTION;
+ else if (CORBA::UserException::_downcast (exception) != 0)
+ this->invoke_status_ = TAO::TAO_INVOKE_USER_EXCEPTION;
+
+ this->forwarded_to_ = CORBA::Object::_nil ();
+ this->caught_exception_ = exception;
+ }
+
+ PortableInterceptor::ReplyStatus
+ Invocation_Base::reply_status (void) const
+ {
+ if (adapter_ != 0)
+ {
+ return this->adapter_->reply_status (*this);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL