Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_ClientRequestInterceptor_Adapter Class Reference

A convenient helper class to invoke registered client request interceptors in client stubs. More...

#include <ClientInterceptorAdapter.h>

Collaboration diagram for TAO_ClientRequestInterceptor_Adapter:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_ClientRequestInterceptor_Adapter (TAO_ClientRequestInterceptor_List::TYPE &interceptors, TAO_GIOP_Invocation *invocation, int &_invoke_status)
 ~TAO_ClientRequestInterceptor_Adapter (void)
PortableInterceptor Client Side Interception Points
Each of these methods corresponds to a client side interception point. There are no "intermediate" interception points on the client side, only "starting" and "ending" interception points.

Todo:
The "send_poll()" and "receive_other()" (for AMI) PortableInterceptor interception points are missing.


void send_request (TAO_ClientRequestInfo_i *ri ACE_ENV_ARG_DECL)
 This method implements one of the "starting" client side interception points. More...

void receive_reply (TAO_ClientRequestInfo_i *ri ACE_ENV_ARG_DECL)
 This method implements one of the "ending" client side interception point. More...

void receive_exception (TAO_ClientRequestInfo_i *ri ACE_ENV_ARG_DECL)
 This method implements one of the "ending" client side interception point. More...

void receive_other (TAO_ClientRequestInfo_i *ri ACE_ENV_ARG_DECL)
 This method implements one of the "ending" client side interception point. More...


Protected Methods

void process_forward_request (TAO_ClientRequestInfo_i *ri, PortableInterceptor::ForwardRequest &exc ACE_ENV_ARG_DECL)
 Process the given PortableInterceptor::ForwardRequest exception, i.e. invoke the receive_other() interception point, in addition to notifying the Invocation object of the LOCATION_FORWARD. More...


Private Attributes

TAO_ClientRequestInterceptor_List::TYPEinterceptors_
 Reference to the list of registered interceptors. More...

TAO_GIOP_Invocationinvocation_
 Pointer to the GIOP invocation object for the current request. More...

int & invoke_status_
 Reference to the invocation status obtained from and returned to the stub. Needed to support the PortableInterceptor::ForwardRequest exception. More...

const size_t len_
 Cache the length of the interceptor list so that we don't have to compute it at each stage of the current interception. More...

size_t stack_size_
 The number of interceptors "pushed" onto the logical flow stack. This is used when unwinding the flow stack. More...

TAO_ClientRequestInfoinfo_
 Pointer to the PortableInterceptor::ClientRequestInfo implementation. More...


Detailed Description

A convenient helper class to invoke registered client request interceptors in client stubs.

This class invokes all registered interceptors at interception point, and enforces flow rules dictated by the Portable Interceptor specification/chapter.

Definition at line 50 of file ClientInterceptorAdapter.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_ClientRequestInterceptor_Adapter::TAO_ClientRequestInterceptor_Adapter TAO_ClientRequestInterceptor_List::TYPE   interceptors,
TAO_GIOP_Invocation   invocation,
int &    _invoke_status
 

Definition at line 7 of file ClientInterceptorAdapter.inl.

References TAO_ClientRequestInterceptor_List::TYPE.

00010     : interceptors_ (interceptors),
00011       invocation_ (invocation),
00012       invoke_status_ (invoke_status),
00013       len_ (interceptors.size ()),
00014       stack_size_ (0),
00015       info_ (0)
00016 {
00017 }

TAO_ClientRequestInterceptor_Adapter::~TAO_ClientRequestInterceptor_Adapter void   
 

Definition at line 20 of file ClientInterceptorAdapter.cpp.

00021 {
00022 }


Member Function Documentation

void TAO_ClientRequestInterceptor_Adapter::process_forward_request TAO_ClientRequestInfo_i   ri,
PortableInterceptor::ForwardRequest &exc    ACE_ENV_ARG_DECL
[protected]
 

Process the given PortableInterceptor::ForwardRequest exception, i.e. invoke the receive_other() interception point, in addition to notifying the Invocation object of the LOCATION_FORWARD.

Definition at line 209 of file ClientInterceptorAdapter.cpp.

References ACE_CHECK, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, TAO_ClientRequestInfo_i::forward_reference, invocation_, invoke_status_, TAO_GIOP_Invocation::location_forward, and receive_other.

Referenced by receive_exception, receive_other, and send_request.

00213 {
00214   ri->forward_reference (exc);
00215 
00216   this->invoke_status_ =
00217     this->invocation_->location_forward (exc.forward.in ()
00218                                          ACE_ENV_ARG_PARAMETER);
00219   ACE_CHECK;
00220 
00221   // receive_other() is potentially invoked recursively.
00222   this->receive_other (ri
00223                        ACE_ENV_ARG_PARAMETER);
00224   ACE_CHECK;
00225 }

void TAO_ClientRequestInterceptor_Adapter::receive_exception TAO_ClientRequestInfo_i *ri    ACE_ENV_ARG_DECL
 

This method implements one of the "ending" client side interception point.

Definition at line 100 of file ClientInterceptorAdapter.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCH, ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_RE_THROW, ACE_TRY, ACE_TRY_CHECK, interceptors_, process_forward_request, and stack_size_.

Referenced by CORBA::_TAO_Policy_Remote_Proxy_Impl::copy, CORBA::_TAO_Policy_Remote_Proxy_Impl::destroy, CORBA::_TAO_DomainManager_Remote_Proxy_Impl::get_domain_policy, CORBA::_TAO_ConstructionPolicy_Remote_Proxy_Impl::make_domain_manager, and CORBA::_TAO_Policy_Remote_Proxy_Impl::policy_type.

00102 {
00103   // This is an "ending" interception point so we only process the
00104   // interceptors pushed on to the flow stack.
00105 
00106   // Notice that the interceptors are processed in the opposite order
00107   // they were pushed onto the stack since this is an "ending"
00108   // interception point.
00109 
00110   ACE_TRY
00111     {
00112       TAO_ClientRequestInfo_Guard info_guard (this->info_, ri);
00113 
00114       // Unwind the flow stack.
00115       size_t len = this->stack_size_;
00116       for (size_t i = 0; i < len; ++i)
00117         {
00118           // Pop the interceptor off of the flow stack before it is
00119           // invoked.  This is necessary to prevent an interceptor
00120           // already invoked in this "ending" interception point from
00121           // being invoked in another "ending" interception point.
00122           --this->stack_size_;
00123 
00124           this->interceptors_[this->stack_size_]->receive_exception (
00125             this->info_
00126             ACE_ENV_ARG_PARAMETER);
00127           ACE_TRY_CHECK;
00128         }
00129     }
00130   ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
00131     {
00132       this->process_forward_request (ri, exc ACE_ENV_ARG_PARAMETER);
00133       ACE_TRY_CHECK;
00134     }
00135   ACE_CATCHANY
00136     {
00137       // The receive_exception() interception point in the remaining
00138       // interceptors must be called so call this method (not the
00139       // interceptor's corresponding method) recursively.  The call is
00140       // made recursively since the caught exception must survive
00141       // until the remaining interceptors have been called.
00142 
00143       // Note that the recursion will stop once the flow stack size
00144       // drops to zero, i.e., once each interceptor has been invoked.
00145       // This prevents infinite recursion from occuring.
00146 
00147       ri->exception (&ACE_ANY_EXCEPTION);
00148 
00149       this->receive_exception (ri ACE_ENV_ARG_PARAMETER);
00150       ACE_TRY_CHECK;
00151 
00152       PortableInterceptor::ReplyStatus status =
00153         ri->reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);
00154       ACE_TRY_CHECK;
00155 
00156       // Only re-throw the exception if it hasn't been transformed by
00157       // the receive_exception() interception point (e.g. to a
00158       // LOCATION_FORWARD).
00159       if (status == PortableInterceptor::SYSTEM_EXCEPTION
00160           || status == PortableInterceptor::USER_EXCEPTION)
00161         ACE_RE_THROW;
00162     }
00163   ACE_ENDTRY;
00164   ACE_CHECK;
00165 }

void TAO_ClientRequestInterceptor_Adapter::receive_other TAO_ClientRequestInfo_i *ri    ACE_ENV_ARG_DECL
 

This method implements one of the "ending" client side interception point.

Definition at line 169 of file ClientInterceptorAdapter.cpp.

References ACE_CATCH, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, interceptors_, process_forward_request, and stack_size_.

Referenced by CORBA::_TAO_Policy_Remote_Proxy_Impl::copy, CORBA::_TAO_Policy_Remote_Proxy_Impl::destroy, CORBA::_TAO_DomainManager_Remote_Proxy_Impl::get_domain_policy, CORBA::_TAO_ConstructionPolicy_Remote_Proxy_Impl::make_domain_manager, CORBA::_TAO_Policy_Remote_Proxy_Impl::policy_type, and process_forward_request.

00171 {
00172   // This is an "ending" interception point so we only process the
00173   // interceptors pushed on to the flow stack.
00174 
00175   // Notice that the interceptors are processed in the opposite order
00176   // they were pushed onto the stack since this is an "ending"
00177   // interception point.
00178 
00179   ACE_TRY
00180     {
00181       TAO_ClientRequestInfo_Guard info_guard (this->info_, ri);
00182 
00183       // Unwind the stack.
00184       size_t len = this->stack_size_;
00185       for (size_t i = 0; i < len; ++i)
00186         {
00187           // Pop the interceptor off of the flow stack before it is
00188           // invoked.  This is necessary to prevent an interceptor
00189           // already invoked in this "ending" interception point from
00190           // being invoked in another "ending" interception point.
00191           --this->stack_size_;
00192 
00193           this->interceptors_[this->stack_size_]->receive_other (
00194             this->info_
00195             ACE_ENV_ARG_PARAMETER);
00196           ACE_TRY_CHECK;
00197         }
00198     }
00199   ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
00200     {
00201       this->process_forward_request (ri, exc ACE_ENV_ARG_PARAMETER);
00202       ACE_TRY_CHECK;
00203     }
00204   ACE_ENDTRY;
00205   ACE_CHECK;
00206 }

void TAO_ClientRequestInterceptor_Adapter::receive_reply TAO_ClientRequestInfo_i *ri    ACE_ENV_ARG_DECL
 

This method implements one of the "ending" client side interception point.

Definition at line 65 of file ClientInterceptorAdapter.cpp.

References ACE_CHECK, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, interceptors_, and stack_size_.

Referenced by CORBA::_TAO_Policy_Remote_Proxy_Impl::copy, CORBA::_TAO_Policy_Remote_Proxy_Impl::destroy, CORBA::_TAO_DomainManager_Remote_Proxy_Impl::get_domain_policy, CORBA::_TAO_ConstructionPolicy_Remote_Proxy_Impl::make_domain_manager, and CORBA::_TAO_Policy_Remote_Proxy_Impl::policy_type.

00067 {
00068   // This is an "ending" interception point so we only process the
00069   // interceptors pushed on to the flow stack.
00070 
00071   // Notice that the interceptors are processed in the opposite order
00072   // they were pushed onto the stack since this is an "ending"
00073   // interception point.
00074 
00075   TAO_ClientRequestInfo_Guard info_guard (this->info_, ri);
00076 
00077   // Unwind the stack.
00078   size_t len = this->stack_size_;
00079   for (size_t i = 0; i < len; ++i)
00080     {
00081       // Pop the interceptor off of the flow stack before it is
00082       // invoked.  This is necessary to prevent an interceptor already
00083       // invoked in this "ending" interception point from being
00084       // invoked in another "ending" interception point.
00085       --this->stack_size_;
00086 
00087       this->interceptors_[this->stack_size_]->receive_reply (
00088         this->info_
00089         ACE_ENV_ARG_PARAMETER);
00090       ACE_CHECK;
00091     }
00092 
00093   // The receive_reply() interception point does not raise a
00094   // PortableInterceptor::ForwardRequest exception so there is no need
00095   // to attempt to catch it here.
00096 }

void TAO_ClientRequestInterceptor_Adapter::send_request TAO_ClientRequestInfo_i *ri    ACE_ENV_ARG_DECL
 

This method implements one of the "starting" client side interception points.

Definition at line 26 of file ClientInterceptorAdapter.cpp.

References ACE_CATCH, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, info_, interceptors_, invocation_, len_, TAO_GIOP_Invocation::orb_core, process_forward_request, and stack_size_.

Referenced by CORBA::_TAO_Policy_Remote_Proxy_Impl::copy, CORBA::_TAO_Policy_Remote_Proxy_Impl::destroy, CORBA::_TAO_DomainManager_Remote_Proxy_Impl::get_domain_policy, CORBA::_TAO_ConstructionPolicy_Remote_Proxy_Impl::make_domain_manager, and CORBA::_TAO_Policy_Remote_Proxy_Impl::policy_type.

00028 {
00029   // This method implements one of the "starting" client side
00030   // interception point.
00031 
00032   ACE_TRY
00033     {
00034       // Only perform the TSS access if interceptors were registered
00035       // with the ORB.
00036       if (this->len_ > 0)
00037         this->info_ =
00038           this->invocation_->orb_core ()->
00039           get_tss_resources ()->client_request_info_;
00040 
00041       TAO_ClientRequestInfo_Guard info_guard (this->info_, ri);
00042 
00043       for (size_t i = 0 ; i < this->len_; ++i)
00044         {
00045           this->interceptors_[i]->send_request (this->info_
00046                                                 ACE_ENV_ARG_PARAMETER);
00047           ACE_TRY_CHECK;
00048 
00049           // The starting interception point completed successfully.
00050           // Push  the interceptor on to the flow stack.
00051           ++this->stack_size_;
00052         }
00053     }
00054   ACE_CATCH (PortableInterceptor::ForwardRequest, exc)
00055     {
00056       this->process_forward_request (ri, exc ACE_ENV_ARG_PARAMETER);
00057       ACE_TRY_CHECK;
00058     }
00059   ACE_ENDTRY;
00060   ACE_CHECK;
00061 }


Member Data Documentation

TAO_ClientRequestInfo* TAO_ClientRequestInterceptor_Adapter::info_ [private]
 

Pointer to the PortableInterceptor::ClientRequestInfo implementation.

Note:
The fact that a pointer to the PortableInterceptor::ClientRequestInfo object in TSS is cached here assumes that all client side interception points are invoked in the same thread. This may not be the case for AMI! In that case, we'll have to perform a TSS access in each interception point.

Definition at line 135 of file ClientInterceptorAdapter.h.

Referenced by send_request.

TAO_ClientRequestInterceptor_List::TYPE& TAO_ClientRequestInterceptor_Adapter::interceptors_ [private]
 

Reference to the list of registered interceptors.

Definition at line 107 of file ClientInterceptorAdapter.h.

Referenced by receive_exception, receive_other, receive_reply, and send_request.

TAO_GIOP_Invocation* TAO_ClientRequestInterceptor_Adapter::invocation_ [private]
 

Pointer to the GIOP invocation object for the current request.

Definition at line 110 of file ClientInterceptorAdapter.h.

Referenced by process_forward_request, and send_request.

int& TAO_ClientRequestInterceptor_Adapter::invoke_status_ [private]
 

Reference to the invocation status obtained from and returned to the stub. Needed to support the PortableInterceptor::ForwardRequest exception.

Definition at line 115 of file ClientInterceptorAdapter.h.

Referenced by process_forward_request.

const size_t TAO_ClientRequestInterceptor_Adapter::len_ [private]
 

Cache the length of the interceptor list so that we don't have to compute it at each stage of the current interception.

Definition at line 119 of file ClientInterceptorAdapter.h.

Referenced by send_request.

size_t TAO_ClientRequestInterceptor_Adapter::stack_size_ [private]
 

The number of interceptors "pushed" onto the logical flow stack. This is used when unwinding the flow stack.

Definition at line 123 of file ClientInterceptorAdapter.h.

Referenced by receive_exception, receive_other, receive_reply, and send_request.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:08:16 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002