summaryrefslogtreecommitdiff
path: root/TAO/tao/ClientInterceptorAdapter.cpp
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2001-05-31 04:50:42 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2001-05-31 04:50:42 +0000
commit6c772c1970174ed9c814b9499d9939a98e3eed08 (patch)
treeee58ee5a82223a090f15ad84fbdd71b0084c4e67 /TAO/tao/ClientInterceptorAdapter.cpp
parent0784e51467b07d534ad6722912a209bd4d2a0359 (diff)
downloadATCD-6c772c1970174ed9c814b9499d9939a98e3eed08.tar.gz
ChangeLogTag:Wed May 30 21:41:53 2001 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO/tao/ClientInterceptorAdapter.cpp')
-rw-r--r--TAO/tao/ClientInterceptorAdapter.cpp203
1 files changed, 203 insertions, 0 deletions
diff --git a/TAO/tao/ClientInterceptorAdapter.cpp b/TAO/tao/ClientInterceptorAdapter.cpp
new file mode 100644
index 00000000000..cebc2dd1549
--- /dev/null
+++ b/TAO/tao/ClientInterceptorAdapter.cpp
@@ -0,0 +1,203 @@
+// $Id$
+
+#include "ClientInterceptorAdapter.h"
+
+#if TAO_HAS_INTERCEPTORS == 1
+
+#if !defined (__ACE_INLINE__)
+#include "ClientInterceptorAdapter.inl"
+#endif /* defined INLINE */
+
+#include "ClientRequestInfo.h"
+#include "Invocation.h"
+
+ACE_RCSID (tao,
+ ClientInterceptorAdapter,
+ "$Id$")
+
+TAO_ClientRequestInterceptor_Adapter::
+~TAO_ClientRequestInterceptor_Adapter (void)
+{
+}
+
+void
+TAO_ClientRequestInterceptor_Adapter::
+send_request (TAO_ClientRequestInfo *ri,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // This method implements one of the "starting" client side
+ // interception point.
+
+
+ ACE_TRY
+ {
+ for (size_t i = 0 ; i < this->len_; ++i)
+ {
+ this->interceptors_[i]->send_request (ri
+ TAO_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // The starting interception point completed successfully.
+ // Push the interceptor on to the flow stack.
+ ++this->stack_size_;
+ }
+ }
+ ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
+ {
+ this->process_forward_request (ri, exc, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+TAO_ClientRequestInterceptor_Adapter::
+receive_reply (TAO_ClientRequestInfo *ri,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // This is an "ending" interception point so we only process the
+ // interceptors pushed on to the flow stack.
+
+ // Notice that the interceptors are processed in the opposite order
+ // they were pushed onto the stack since this is an "ending"
+ // interception point.
+
+ // Unwind the stack.
+ size_t len = this->stack_size_;
+ for (size_t i = 0; i < len; ++i)
+ {
+ // Pop the interceptor off of the flow stack before it is
+ // invoked. This is necessary to prevent an interceptor already
+ // invoked in this "ending" interception point from being
+ // invoked in another "ending" interception point.
+ --this->stack_size_;
+
+ this->interceptors_[this->stack_size_]->receive_reply (
+ ri
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+
+ ACE_UNUSED_ARG (ACE_TRY_ENV);
+
+ // The receive_reply() interception point does not raise a
+ // PortableInterceptor::ForwardRequest exception so there is no need
+ // to attempt to catch it here.
+}
+
+void
+TAO_ClientRequestInterceptor_Adapter::
+receive_exception (TAO_ClientRequestInfo *ri,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // This is an "ending" interception point so we only process the
+ // interceptors pushed on to the flow stack.
+
+ // Notice that the interceptors are processed in the opposite order
+ // they were pushed onto the stack since this is an "ending"
+ // interception point.
+
+ ACE_TRY
+ {
+ // Unwind the flow stack.
+ size_t len = this->stack_size_;
+ for (size_t i = 0; i < len; ++i)
+ {
+ // Pop the interceptor off of the flow stack before it is
+ // invoked. This is necessary to prevent an interceptor
+ // already invoked in this "ending" interception point from
+ // being invoked in another "ending" interception point.
+ --this->stack_size_;
+
+ this->interceptors_[this->stack_size_]->receive_exception (
+ ri
+ TAO_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
+ {
+ this->process_forward_request (ri, exc, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ // The receive_exception() interception point in the remaining
+ // interceptors must be called so call this method (not the
+ // interceptor's corresponding method) recursively. The call is
+ // made recursively since the caught exception must survive
+ // until the remaining interceptors have been called.
+
+ // Note that the recursion will stop once the flow stack size
+ // drops to zero, i.e., once each interceptor has been invoked.
+ // This prevents infinite recursion from occuring.
+
+ ri->exception (&ACE_ANY_EXCEPTION);
+
+ this->receive_exception (ri, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+TAO_ClientRequestInterceptor_Adapter::
+receive_other (TAO_ClientRequestInfo *ri,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // This is an "ending" interception point so we only process the
+ // interceptors pushed on to the flow stack.
+
+ // Notice that the interceptors are processed in the opposite order
+ // they were pushed onto the stack since this is an "ending"
+ // interception point.
+
+ ACE_TRY
+ {
+ // Unwind the stack.
+ size_t len = this->stack_size_;
+ for (size_t i = 0; i < len; ++i)
+ {
+ // Pop the interceptor off of the flow stack before it is
+ // invoked. This is necessary to prevent an interceptor
+ // already invoked in this "ending" interception point from
+ // being invoked in another "ending" interception point.
+ --this->stack_size_;
+
+ this->interceptors_[this->stack_size_]->receive_other (
+ ri
+ TAO_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
+ {
+ this->process_forward_request (ri, exc, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+TAO_ClientRequestInterceptor_Adapter::process_forward_request (
+ TAO_ClientRequestInfo *ri,
+ PortableInterceptor::ForwardRequest &exc,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ ri->forward_reference (exc);
+
+ this->invoke_status_ =
+ this->invocation_->location_forward (exc.forward.in (), ACE_TRY_ENV);
+ ACE_CHECK;
+
+ // receive_other() is potentially invoked recursively.
+ this->receive_other (ri,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+}
+
+#endif /* TAO_HAS_INTERCEPTORS == 1 */