Invocation_Base.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Invocation_Base.h
00006  *
00007  *  Invocation_Base.h,v 1.14 2006/03/10 07:19:05 jtc Exp
00008  *
00009  *
00010  *  @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
00011  */
00012 //=============================================================================
00013 
00014 #ifndef TAO_INVOCATION_BASE_H
00015 #define TAO_INVOCATION_BASE_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "tao/Object.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "tao/Invocation_Utils.h"
00026 
00027 #if TAO_HAS_INTERCEPTORS == 1
00028 #include "tao/PI_ForwardC.h"
00029 #include "tao/ClientRequestInterceptor_Adapter.h"
00030 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 class TAO_Service_Context;
00035 class TAO_Operation_Details;
00036 class TAO_Stub;
00037 
00038 namespace TAO
00039 {
00040   class Invocation_Adapter;
00041 
00042   /**
00043    * @class Invocation_Base
00044    *
00045    * @brief The base class for the invocation object
00046    *
00047    * This class is the base of the invocation object hiererachy. This
00048    * hierarchy is classified  based on the type of invocation and the
00049    * mode of invocation. One of the objects from the hierarchy is
00050    * created on the stack for every invocation.
00051    *
00052    * In addition this class encapsulates the essential details that
00053    * are required for PortableInterceptors to function
00054    * correctly. Further this class also provides some helper and
00055    * accessor methods that are used by clients.
00056    *
00057    */
00058   class TAO_Export Invocation_Base
00059   {
00060   public:
00061     virtual ~Invocation_Base (void);
00062 
00063     /// Accessor and mutator methods
00064     //@{
00065     TAO_ORB_Core *orb_core (void) const;
00066 
00067     TAO_Stub *stub (void) const;
00068 
00069     /// Accessor and mutator methods for forwarded object
00070     /// locations.
00071     /**
00072      * These access methods have to be public so that the
00073      * PortableInterceptor can use them
00074      */
00075     CORBA::Object_ptr forwarded_reference (void);
00076     void forwarded_reference (CORBA::Object_ptr o);
00077 
00078     /// Accessors for the service context list.
00079     /**
00080      * The service context lists are actually cached
00081      * elsewhere. Providing this accessor helps the PI to access this
00082      * list in both remote and collocated mode.
00083      */
00084     TAO_Service_Context &request_service_context (void);
00085     TAO_Service_Context &reply_service_context (void);
00086 
00087     /// Return the forwarded object location by loosing ownership.
00088     CORBA::Object_ptr steal_forwarded_reference (void);
00089 
00090     /// Did the invocation got forwarded to a new location?
00091     bool is_forwarded (void) const;
00092 
00093     /// Mutator to set the reply status of the invocation.
00094     void reply_received (Invocation_Status s);
00095 
00096     /// Return the effective target of the invocation.
00097     /**
00098      * Please see the PortableInterceptor specification in the CORBA
00099      * spec to understand what effective target means.
00100      */
00101     CORBA::Object_ptr effective_target (void) const;
00102 
00103     /// Return the target object
00104     CORBA::Object_ptr target (void) const;
00105 
00106     /// Does this invocation return a response?
00107     CORBA::Boolean response_expected (void) const;
00108 
00109     /// The operaton details of the invocation
00110     TAO_Operation_Details &operation_details (void);
00111     //@}
00112 
00113   protected:
00114     /**
00115      * @param otarget The original target on which this invocation
00116      * was started.
00117      *
00118      * @param target the target on which this invocation is flowing
00119      * ie. the effective target
00120      *
00121      * @param op operation details of the invocation on @a target
00122      *
00123      * @param response_expected flag to indicate whether the
00124      * operation encapsulated by @a op returns a response or not.
00125      */
00126     Invocation_Base (CORBA::Object_ptr otarget,
00127                      CORBA::Object_ptr target,
00128                      TAO_Stub *stub,
00129                      TAO_Operation_Details &op,
00130                      bool response_expected,
00131                      bool request_is_remote);
00132 
00133   protected:
00134     /// The operation details on which we are operating on.
00135     TAO_Operation_Details &details_;
00136 
00137     /// Forwarded object reference.
00138     CORBA::Object_var forwarded_to_;
00139 
00140     /// Is response expected?
00141     bool response_expected_;
00142 
00143   private:
00144 
00145     Invocation_Base (const Invocation_Base&);
00146     Invocation_Base & operator= (const Invocation_Base &);
00147 
00148   private:
00149     //@{
00150     /**
00151      * The following object reference pointers are *not*
00152      * duplicated. They are cached for portable interceptors, and they
00153      * just live for the lifetime of the request. Hence there is no
00154      * point in duplicating the pointers.
00155      */
00156     /// The original target on which the invocation was started.
00157     CORBA::Object_ptr otarget_;
00158 
00159     /// The effective target on which the invocation is on.
00160     CORBA::Object_ptr target_;
00161 
00162     /// Cache the ORB_Core
00163     TAO_ORB_Core *orb_core_;
00164 
00165     TAO_Stub *stub_;
00166     //@}
00167 
00168     /// Operations invoked by the
00169     /// PortableInterceptor::ClientRequestInfo object to get details
00170     /// about the operation and related stuff.
00171     //@{
00172 #if TAO_HAS_INTERCEPTORS == 1
00173   public:
00174     /// Return a reference to the number of interceptors pushed on to
00175     /// the current interceptor flow stack.
00176     /**
00177      * @note It is a reference since the Portable Interceptor flow stack
00178      *       code must be able to modify this value and use that value
00179      *       at a later time without being forced to use TSS.
00180      */
00181     size_t &stack_size (void);
00182 
00183     CORBA::Exception *caught_exception (void);
00184 
00185     /// Change the exception status.
00186     void exception (CORBA::Exception *exception);
00187 
00188     /// Invoke status
00189     TAO::Invocation_Status invoke_status (void) const;
00190 
00191     PortableInterceptor::ReplyStatus reply_status (void) const;
00192 
00193     /// Accessor used to determine if the current invocation is part
00194     /// of a remote request, and if not, it will be considered to be
00195     /// part of a collocated request.
00196     bool is_remote_request() const;
00197 
00198   protected:
00199     /// Helper method to invoke send_request interception call to all
00200     /// the registered interceptors.
00201     Invocation_Status send_request_interception (ACE_ENV_SINGLE_ARG_DECL)
00202       ACE_THROW_SPEC ((CORBA::SystemException));
00203 
00204     /// Helper method to invoke receive_reply interception call to all
00205     /// the registered interceptors.
00206     Invocation_Status receive_reply_interception (ACE_ENV_SINGLE_ARG_DECL)
00207       ACE_THROW_SPEC ((CORBA::SystemException));
00208 
00209     /// Helper method to invoke receive_other interception call to all
00210     /// the registered interceptors.
00211     Invocation_Status receive_other_interception (ACE_ENV_SINGLE_ARG_DECL)
00212       ACE_THROW_SPEC ((CORBA::SystemException));
00213 
00214     /// Helper methods to handle interception calls when exceptions
00215     /// are thrown by the PortableInterceptor.
00216     PortableInterceptor::ReplyStatus
00217         handle_any_exception (CORBA::Exception *e
00218                               ACE_ENV_ARG_DECL);
00219 
00220     PortableInterceptor::ReplyStatus
00221         handle_all_exception (ACE_ENV_SINGLE_ARG_DECL);
00222 
00223   protected:
00224     /// The client requestor adapter
00225     ClientRequestInterceptor_Adapter *adapter_;
00226 
00227     size_t stack_size_;
00228 
00229     TAO::Invocation_Status invoke_status_;
00230 
00231   private:
00232     /// Pointer to the caught exception.
00233     CORBA::Exception *caught_exception_;
00234 
00235     /// Flag used to distinguish a remote invocation versus a collocated
00236     /// (thru-poa) invocation.
00237     bool is_remote_request_;
00238 #endif /*TAO_HAS_INTERCEPTORS*/
00239     //@}
00240   };
00241 }
00242 
00243 TAO_END_VERSIONED_NAMESPACE_DECL
00244 
00245 #if defined (__ACE_INLINE__)
00246 # include "tao/Invocation_Base.inl"
00247 #endif /* __ACE_INLINE__ */
00248 
00249 #include /**/ "ace/post.h"
00250 
00251 #endif /*TAO_INVOCATION_BASE_H*/

Generated on Thu Nov 9 11:54:14 2006 for TAO by doxygen 1.3.6