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

ClientInterceptorAdapter.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 #include "ClientInterceptorAdapter.h"
00003 
00004 #if TAO_HAS_INTERCEPTORS == 1
00005 
00006 #if !defined (__ACE_INLINE__)
00007 #include "ClientInterceptorAdapter.inl"
00008 #endif /* defined INLINE */
00009 
00010 #include "ClientRequestInfo.h"
00011 #include "ClientRequestInfo_i.h"
00012 #include "Invocation.h"
00013 #include "ORB_Core.h"
00014 
00015 ACE_RCSID (tao,
00016            ClientInterceptorAdapter,
00017            "$Id: ClientInterceptorAdapter.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00018 
00019 
00020 TAO_ClientRequestInterceptor_Adapter::~TAO_ClientRequestInterceptor_Adapter (void)
00021 {
00022 }
00023 
00024 void
00025 
00026 TAO_ClientRequestInterceptor_Adapter::send_request (TAO_ClientRequestInfo_i *ri
00027               ACE_ENV_ARG_DECL)
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 }
00062 
00063 void
00064 
00065 TAO_ClientRequestInterceptor_Adapter::receive_reply (TAO_ClientRequestInfo_i *ri
00066                ACE_ENV_ARG_DECL)
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 }
00097 
00098 void
00099 
00100 TAO_ClientRequestInterceptor_Adapter::receive_exception (TAO_ClientRequestInfo_i *ri
00101                    ACE_ENV_ARG_DECL)
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 }
00166 
00167 void
00168 
00169 TAO_ClientRequestInterceptor_Adapter::receive_other (TAO_ClientRequestInfo_i *ri
00170                ACE_ENV_ARG_DECL)
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 }
00207 
00208 void
00209 TAO_ClientRequestInterceptor_Adapter::process_forward_request (
00210   TAO_ClientRequestInfo_i *ri,
00211   PortableInterceptor::ForwardRequest &exc
00212   ACE_ENV_ARG_DECL)
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 }
00226 
00227 #endif /* TAO_HAS_INTERCEPTORS == 1 */

Generated on Mon Jun 16 13:48:03 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002