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

ClientRequestInfo.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file ClientRequestInfo.h
00006  *
00007  * $Id: ClientRequestInfo.h,v 1.1.1.2.2.2 2003/04/01 14:45:51 chad Exp $
00008  *
00009  * This is the implementation of the
00010  * PortableInterceptor::ClientRequestInfo interface.
00011  *
00012  * @author Ossama Othman <ossama@uci.edu>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef TAO_CLIENT_REQUEST_INFO_H
00017 #define TAO_CLIENT_REQUEST_INFO_H
00018 
00019 #include "ace/pre.h"
00020 
00021 #include "tao/orbconf.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #if (TAO_HAS_INTERCEPTORS == 1)
00028 
00029 #if defined(_MSC_VER)
00030 #if (_MSC_VER >= 1200)
00031 #pragma warning(push)
00032 #endif /* _MSC_VER >= 1200 */
00033 #pragma warning(disable:4250)
00034 #endif /* _MSC_VER */
00035 
00036 #include "tao/PortableInterceptorC.h"
00037 #include "tao/LocalObject.h"
00038 
00039 class TAO_ClientRequestInfo_i;
00040 class TAO_GIOP_Invocation;
00041 
00042 /**
00043  * @class TAO_ClientRequestInfo
00044  *
00045  * @brief Implementation of the PortableInterceptor::ClientRequestInfo
00046  *        interface.
00047  *
00048  * This class forwards all method calls to the underlying
00049  * ClientRequestInfo implementation.
00050  * @par
00051  * An instance of this class is placed in TSS, where as the underlying
00052  * implementation is instantiated on the stack during each CORBA
00053  * request.  During each request invocation, a pointer to the stack
00054  * instantiated implementation is placed in the instance of this
00055  * class.
00056  * @par
00057  * This may seem unnecessary.  However, it is necessary to avoid
00058  * instantiating an object that inherits from CORBA::Object in the
00059  * critical path.  Such an instantiation would cause a lock to be
00060  * initialized (not acquired) in the critical path, which can degrade
00061  * performance significantly.
00062  */
00063 class TAO_ClientRequestInfo
00064   : public virtual PortableInterceptor::ClientRequestInfo,
00065     public virtual TAO_Local_RefCounted_Object
00066 {
00067 public:
00068 
00069   TAO_ClientRequestInfo (void);
00070 
00071   /// Return an ID unique to the current request.  This request ID may
00072   /// or may not be the same as the GIOP request ID.
00073   virtual CORBA::ULong request_id (
00074       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00075     ACE_THROW_SPEC ((CORBA::SystemException));
00076 
00077   /// Return the operation name for the current request.
00078   virtual char * operation (
00079       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00080     ACE_THROW_SPEC ((CORBA::SystemException));
00081 
00082   /// Return the list of arguments passed to the current operation.
00083   virtual Dynamic::ParameterList * arguments (
00084       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00085     ACE_THROW_SPEC ((CORBA::SystemException));
00086 
00087   /// Return the list of exceptions the current operation is capable
00088   /// of throwing.
00089   virtual Dynamic::ExceptionList * exceptions (
00090       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00091     ACE_THROW_SPEC ((CORBA::SystemException));
00092 
00093   virtual Dynamic::ContextList * contexts (
00094       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00095     ACE_THROW_SPEC ((CORBA::SystemException));
00096 
00097   virtual Dynamic::RequestContext * operation_context (
00098       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00099     ACE_THROW_SPEC ((CORBA::SystemException));
00100 
00101   /// Return the result of the current request.  If there is no return
00102   /// value then an Any with tk_void TypeCode is returned.  This is
00103   /// method is not valid for oneway operations.
00104   virtual CORBA::Any * result (
00105       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00106     ACE_THROW_SPEC ((CORBA::SystemException));
00107 
00108   /// Returns true for a two-way operation, and false otherwise.
00109   virtual CORBA::Boolean response_expected (
00110       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00111     ACE_THROW_SPEC ((CORBA::SystemException)) ;
00112 
00113   /// Return the sync_scope policy value for the current one-way
00114   /// operation.  If the operation is not a one-way, a
00115   /// CORBA::BAD_INV_ORDER exception is thrown.
00116   virtual Messaging::SyncScope sync_scope (
00117       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00118     ACE_THROW_SPEC ((CORBA::SystemException));
00119 
00120   /// Return the reply status for the current request.  Statuses can
00121   /// be PortableInterceptor::SUCCESSFUL, SYSTEM_EXCEPTION,
00122   /// USER_EXCEPTION, LOCATION_FORWARD, LOCATION_FORWARD_PERMANENT,
00123   /// TRANSPORT_RETRY.
00124   virtual PortableInterceptor::ReplyStatus reply_status (
00125       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00126     ACE_THROW_SPEC ((CORBA::SystemException));
00127 
00128   /// If the reply status is PortableInterceptor::LOCATION_FORWARD or
00129   /// PortableInterceptor::LOCATION_FORWARD_PERMANENT, return the
00130   /// object reference to which the request was forwarded.
00131   virtual CORBA::Object_ptr forward_reference (
00132       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00133     ACE_THROW_SPEC ((CORBA::SystemException)) ;
00134 
00135   virtual CORBA::Any * get_slot (
00136       PortableInterceptor::SlotId id
00137       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00138     ACE_THROW_SPEC ((CORBA::SystemException,
00139                      PortableInterceptor::InvalidSlot));
00140 
00141   /// Return the IOP::ServiceContext with the given IOP::ServiceId
00142   /// from the request service context list.
00143   virtual IOP::ServiceContext * get_request_service_context (
00144       IOP::ServiceId id
00145       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00146     ACE_THROW_SPEC ((CORBA::SystemException));
00147 
00148   /// Return the IOP::ServiceContext with the given IOP::ServiceId
00149   /// from the reply service context list.
00150   virtual IOP::ServiceContext * get_reply_service_context (
00151       IOP::ServiceId id
00152       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00153     ACE_THROW_SPEC ((CORBA::SystemException));
00154 
00155   /// Return the (initial, non-forwarded, or permanently forwarded)
00156   /// object reference of the target.
00157   virtual CORBA::Object_ptr target (
00158       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00159     ACE_THROW_SPEC ((CORBA::SystemException));
00160 
00161   /// Return the object reference for the current target.  The target
00162   /// may change in the even of a location forward.
00163   virtual CORBA::Object_ptr effective_target (
00164       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00165     ACE_THROW_SPEC ((CORBA::SystemException));
00166 
00167   virtual IOP::TaggedProfile * effective_profile (
00168       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00169     ACE_THROW_SPEC ((CORBA::SystemException));
00170 
00171   /// Return an Any containing the received exception, if any.
00172   /// Otherwise, throw a CORBA::BAD_INV_ORDER exception.
00173   /**
00174    * @note There is no trivial way to extract the exception from an Any.
00175    */
00176   virtual CORBA::Any * received_exception (
00177       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00178     ACE_THROW_SPEC ((CORBA::SystemException));
00179 
00180   /// Return the repository ID for the received exception.
00181   virtual char * received_exception_id (
00182       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00183     ACE_THROW_SPEC ((CORBA::SystemException));
00184 
00185   /// Return the first IOP::TaggedComponent that matches the given
00186   /// IOP::ComponentId in the object reference for the current
00187   /// target.
00188   virtual IOP::TaggedComponent * get_effective_component (
00189       IOP::ComponentId id
00190       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00191     ACE_THROW_SPEC ((CORBA::SystemException));
00192 
00193   /// Return all IOP::TaggedComponent(s) that match the given
00194   /// IOP::ComponentId in the object reference for the current
00195   /// target.
00196   virtual IOP::TaggedComponentSeq * get_effective_components (
00197       IOP::ComponentId id
00198       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00199     ACE_THROW_SPEC ((CORBA::SystemException));
00200 
00201   /// Return the policy of the given type in effect for the current
00202   /// request.
00203   virtual CORBA::Policy_ptr get_request_policy (
00204       CORBA::PolicyType type
00205       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00206     ACE_THROW_SPEC ((CORBA::SystemException));
00207 
00208   /// Add the IOP::ServiceContext to the request (outgoing)
00209   /// IOP::ServiceContextList.
00210   virtual void add_request_service_context (
00211       const IOP::ServiceContext & service_context,
00212       CORBA::Boolean replace
00213       ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00214      ACE_THROW_SPEC ((CORBA::SystemException));
00215 
00216   /// Set the ClientRequestInfo implementation which this class
00217   /// forwards all method call to.
00218   void info (TAO_ClientRequestInfo_i *info);
00219 
00220   /// Get the ClientRequestInfo implementation which this class
00221   /// forwards all method call to.
00222   TAO_ClientRequestInfo_i * info (void) const;
00223 
00224   /// Accessor to underlying invocation_
00225   TAO_GIOP_Invocation *invocation ();
00226 
00227 private:
00228 
00229   /// Check if this ClientRequestInfo object is called within the
00230   /// context of a request.
00231   void check_validity (ACE_ENV_SINGLE_ARG_DECL);
00232 
00233 private:
00234 
00235   /// Pointer to the object that actually implements the
00236   /// ClientRequestInfo functionality.
00237   TAO_ClientRequestInfo_i * info_;
00238 
00239   /// Pointer to the GIOP invocation object.
00240   TAO_GIOP_Invocation *invocation_;
00241 
00242 };
00243 
00244 
00245 // -------------------------------------------------------------------
00246 
00247 
00248 /**
00249  * @class TAO_ClientRequestInfo_Guard
00250  *
00251  * @brief Guard for exception safe TAO_ClientRequestInfo_i pointer
00252  *        swapping.
00253  *
00254  * This class is used to ensure the swapping of
00255  * TAO_ClientRequestInfo_i pointers in a TAO_ClientRequestInfo object
00256  * is performed in an exception-safe manner when interception points
00257  * are being invoked.
00258  */
00259 class TAO_ClientRequestInfo_Guard
00260 {
00261 public:
00262 
00263   /// Constructor.
00264   TAO_ClientRequestInfo_Guard (TAO_ClientRequestInfo *info,
00265                                TAO_ClientRequestInfo_i *ri);
00266 
00267   /// Destructor.
00268   ~TAO_ClientRequestInfo_Guard (void);
00269 
00270 private:
00271 
00272   /// Pointer to the TAO_ClientRequestInfo object upon which pointer
00273   /// swaps will occur.
00274   TAO_ClientRequestInfo * info_;
00275 
00276   /// Pointer to the TAO_ClientRequestInfo_i object that was
00277   /// previously stored in the TAO_ClientRequestInfo object.
00278   TAO_ClientRequestInfo_i * previous_info_;
00279 
00280 };
00281 
00282 
00283 # if defined (__ACE_INLINE__)
00284 #  include "ClientRequestInfo.inl"
00285 # endif  /* __ACE_INLINE__ */
00286 
00287 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00288 #pragma warning(pop)
00289 #endif /* _MSC_VER */
00290 
00291 #endif /* TAO_HAS_INTERCEPTORS == 1 */
00292 
00293 #include "ace/post.h"
00294 
00295 #endif /* TAO_CLIENT_REQUEST_INFO_H */

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