ServerRequestInfo.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file ServerRequestInfo.h
00006  *
00007  * $Id: ServerRequestInfo.h 81663 2008-05-09 12:43:47Z johnnyw $
00008  *
00009  * This is the implementation of the
00010  * @c PortableInterceptor::ServerRequestInfo interface.
00011  *
00012  * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
00013  * @author Ossama Othman
00014  */
00015 //=============================================================================
00016 
00017 #ifndef TAO_SERVER_REQUEST_INFO_H
00018 #define TAO_SERVER_REQUEST_INFO_H
00019 
00020 #include /**/ "ace/pre.h"
00021 
00022 #include "tao/orbconf.h"
00023 
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #if (TAO_HAS_INTERCEPTORS == 1)
00029 
00030 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
00031 #include "tao/PI_Server/PI_Server_includeC.h"
00032 #include "tao/PI/PI.h"
00033 #include "tao/LocalObject.h"
00034 #include "tao/OctetSeqC.h"
00035 #include "tao/TAO_Server_Request.h"
00036 #include "tao/PortableInterceptorC.h"
00037 
00038 #if defined(_MSC_VER)
00039 #pragma warning(push)
00040 #pragma warning(disable:4250)
00041 #endif /* _MSC_VER */
00042 
00043 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00044 
00045 class TAO_ServerRequest;
00046 class TAO_Service_Context;
00047 
00048 namespace TAO
00049 {
00050   namespace Portable_Server
00051   {
00052     class Servant_Upcall;
00053   }
00054 }
00055 
00056 namespace TAO
00057 {
00058   /**
00059    * @class ServerRequestInfo
00060    *
00061    * @brief Implementation of the
00062    *        @c PortableInterceptor::ServerRequestInfo IDL interface.
00063    *
00064    * Implementation of the @c PortableInterceptor::ServerRequestInfo
00065    * IDL interface.
00066    *
00067    * @note This class is currently not meant to be reference counted
00068    *       since it is instantiated on the stack.
00069    */
00070   class ServerRequestInfo
00071     : public virtual PortableInterceptor::ServerRequestInfo
00072     , public virtual ::CORBA::LocalObject
00073   {
00074   public:
00075 
00076     /// Constructor.
00077     ServerRequestInfo (TAO_ServerRequest & server_request,
00078                        TAO::Argument * const * args,
00079                        size_t nargs,
00080                        void * servant_upcall,
00081                        CORBA::TypeCode_ptr const * exceptions,
00082                        CORBA::ULong nexceptions);
00083 
00084     /// Return an ID unique to the current request.  This request ID may
00085     /// or may not be the same as the GIOP request ID.
00086     virtual CORBA::ULong request_id (void);
00087 
00088     /// Return the operation name for the current request.
00089     virtual char * operation (void);
00090 
00091     /// Return the list of arguments passed to the current operation.
00092     virtual Dynamic::ParameterList * arguments (void);
00093 
00094     /// Return the list of exceptions the current operation is capable
00095     /// of throwing.
00096     virtual Dynamic::ExceptionList * exceptions (void);
00097 
00098     virtual Dynamic::ContextList * contexts (void);
00099 
00100     virtual Dynamic::RequestContext * operation_context (void);
00101 
00102     /// Return the result of the current request.  If there is no
00103     /// return value then an @c Any with @c tk_void @c TypeCode is
00104     /// returned.  This method is not valid for oneway operations.
00105     virtual CORBA::Any * result (void);
00106 
00107     /// Returns @c true for a two-way operation, and @c false otherwise.
00108     virtual CORBA::Boolean response_expected (void);
00109 
00110     /// Return the @c sync_scope policy value for the current one-way
00111     /// operation.  If the operation is not a one-way, a
00112     /// @c CORBA::BAD_INV_ORDER exception is thrown.
00113     virtual Messaging::SyncScope sync_scope (void);
00114 
00115     /// Return the reply status for the current request.
00116     /**
00117      * Statuses can be @c PortableInterceptor::SUCCESSFUL,
00118      * @c SYSTEM_EXCEPTION, @c USER_EXCEPTION, @c LOCATION_FORWARD,
00119      * @c TRANSPORT_RETRY, @c UNKNOWN..
00120      */
00121     virtual PortableInterceptor::ReplyStatus reply_status (void);
00122 
00123     /// If the reply status is
00124     /// @c PortableInterceptor::LOCATION_FORWARD return the
00125     /// object reference to which the request was forwarded.
00126     virtual CORBA::Object_ptr forward_reference (void);
00127 
00128     /// Retrieve data from the "request scope" @c PICurrent object.
00129     virtual CORBA::Any * get_slot (PortableInterceptor::SlotId id);
00130 
00131     /// Return the @c IOP::ServiceContext with the given
00132     /// @c IOP::ServiceId from the request service context list.
00133     virtual IOP::ServiceContext * get_request_service_context (
00134         IOP::ServiceId id);
00135 
00136     /// Return the @c IOP::ServiceContext with the given
00137     /// @c IOP::ServiceId from the reply service context list.
00138     virtual IOP::ServiceContext * get_reply_service_context (
00139         IOP::ServiceId id);
00140 
00141     /// Return an @c Any containing the exception being sent, if any.
00142     /// Otherwise, throw a @c CORBA::BAD_INV_ORDER exception.
00143     /**
00144      * @note There is no trivial way to extract the exception from an
00145      *       @c Any.
00146      */
00147     virtual CORBA::Any * sending_exception (void);
00148 
00149     /// Return the @c ObjectId for the target object.
00150     virtual PortableInterceptor::ObjectId * object_id (void);
00151 
00152     /// Return the @c AdapterId for the POA handling the current
00153     /// request.
00154     virtual CORBA::OctetSeq * adapter_id (void);
00155 
00156     /// Return the server_id of the server. The value is passed to
00157     /// the ORB via @c -ORBServerId parameter.
00158     virtual char * server_id (void);
00159 
00160     /// Return the ORBId value that is passed to the @c ORB_init
00161     /// call.
00162     virtual char * orb_id (void);
00163 
00164     /// Return the name of the object adapter that services requests
00165     /// for the invoked object.
00166     virtual PortableInterceptor::AdapterName * adapter_name (void);
00167 
00168     /// Return the most derived interface of the target object.
00169     virtual char * target_most_derived_interface (void);
00170 
00171     /// Return the policy of the given type in effect for the current
00172     /// request.
00173     virtual CORBA::Policy_ptr get_server_policy (CORBA::PolicyType type);
00174 
00175     /// Insert data into the "request scope" @c PICurrent object.
00176     virtual void set_slot (PortableInterceptor::SlotId id,
00177                            const CORBA::Any & data);
00178 
00179     /// Returns true if the target's type corresponds to the given
00180     /// @c RepositoryId.
00181     virtual CORBA::Boolean target_is_a (const char * id);
00182 
00183     /// Add the @c IOP::ServiceContext to the reply (outgoing)
00184     /// @c IOP::ServiceContextList.
00185     virtual void add_reply_service_context (
00186         const IOP::ServiceContext & service_context,
00187         CORBA::Boolean replace
00188         );
00189 
00190   public:
00191 
00192     /**
00193      * @name Helper methods specific to TAO.
00194      */
00195     //@{
00196 
00197     /// Extract the forward object reference from the
00198     /// @c PortableInterceptor::ForwardRequest exception, and set the
00199     /// reply status flag accordingly.
00200     void forward_reference (PortableInterceptor::ForwardRequest &exc);
00201 
00202     /// Set the forward reference associated with the current
00203     /// LOCATION_FORWARD reply.
00204     /**
00205      * @note This method is only invoked when a
00206      * @c PortableServer::ForwardRequest exception is thrown by a
00207      * servant manager.
00208      */
00209     void forward_reference (CORBA::Object_ptr obj);
00210 
00211     //@}
00212 
00213     /// Return a reference to the underlying @c TAO_ServerRequest
00214     /// object.
00215     TAO_ServerRequest &server_request (void);
00216 
00217   protected:
00218 
00219     /// Helper method to get the request and response service
00220     /// contexts.
00221     IOP::ServiceContext * get_service_context_i (
00222         TAO_Service_Context & service_context_list,
00223         IOP::ServiceId id);
00224 
00225   protected:
00226 
00227     /// Underlying request object that contains much of the
00228     /// information encapsulated by this @c ServerRequestInfo
00229     /// implementation.
00230     TAO_ServerRequest & server_request_;
00231 
00232     /// Operation argument list.
00233     TAO::Argument * const * const args_;
00234 
00235     /// Number of element in the operation argument list.
00236     size_t const nargs_;
00237 
00238     /// Pointer to the @c Servant_Upcall object that contains the
00239     /// object ID, among other things.
00240     TAO::Portable_Server::Servant_Upcall * const servant_upcall_;
00241 
00242     /// Array of @c TypeCodes for user exceptions the operation is
00243     /// capable of raising.
00244     CORBA::TypeCode_ptr const * const exceptions_;
00245 
00246     /// The number of elements in the @c exceptions_ array.
00247     CORBA::ULong const nexceptions_;
00248   };
00249 
00250 }  // End namespace TAO
00251 
00252 TAO_END_VERSIONED_NAMESPACE_DECL
00253 
00254 # if defined (__ACE_INLINE__)
00255 #  include "tao/PI_Server/ServerRequestInfo.inl"
00256 # endif  /* __ACE_INLINE__ */
00257 
00258 #if defined(_MSC_VER)
00259 #pragma warning(pop)
00260 #endif /* _MSC_VER */
00261 
00262 #endif /* TAO_HAS_INTERCEPTORS == 1 */
00263 
00264 #include /**/ "ace/post.h"
00265 
00266 #endif /* TAO_SERVER_REQUEST_INFO_H */

Generated on Tue Feb 2 17:42:14 2010 for TAO_PI_Server by  doxygen 1.4.7