Invocation_Base.h

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

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7