ServerRequestInfo.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file ServerRequestInfo.h
00006  *
00007  * ServerRequestInfo.h,v 1.5 2006/04/19 09:43:46 jwillemsen Exp
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/ServerRequestInfoC.h"
00032 #include "tao/PI/PIForwardRequestC.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 (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00087       ACE_THROW_SPEC ((CORBA::SystemException));
00088 
00089     /// Return the operation name for the current request.
00090     virtual char * operation (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00091       ACE_THROW_SPEC ((CORBA::SystemException));
00092 
00093     /// Return the list of arguments passed to the current operation.
00094     virtual Dynamic::ParameterList * arguments (
00095         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00096       ACE_THROW_SPEC ((CORBA::SystemException));
00097 
00098     /// Return the list of exceptions the current operation is capable
00099     /// of throwing.
00100     virtual Dynamic::ExceptionList * exceptions (
00101         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00102       ACE_THROW_SPEC ((CORBA::SystemException));
00103 
00104     virtual Dynamic::ContextList * contexts (
00105         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00106       ACE_THROW_SPEC ((CORBA::SystemException));
00107 
00108     virtual Dynamic::RequestContext * operation_context (
00109         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00110       ACE_THROW_SPEC ((CORBA::SystemException));
00111 
00112     /// Return the result of the current request.  If there is no
00113     /// return value then an @c Any with @c tk_void @c TypeCode is
00114     /// returned.  This method is not valid for oneway operations.
00115     virtual CORBA::Any * result (
00116         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00117       ACE_THROW_SPEC ((CORBA::SystemException));
00118 
00119     /// Returns @c true for a two-way operation, and @c false otherwise.
00120     virtual CORBA::Boolean response_expected (
00121         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00122       ACE_THROW_SPEC ((CORBA::SystemException));
00123 
00124     /// Return the @c sync_scope policy value for the current one-way
00125     /// operation.  If the operation is not a one-way, a
00126     /// @c CORBA::BAD_INV_ORDER exception is thrown.
00127     virtual Messaging::SyncScope sync_scope (
00128         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00129       ACE_THROW_SPEC ((CORBA::SystemException));
00130 
00131     /// Return the reply status for the current request.
00132     /**
00133      * Statuses can be @c PortableInterceptor::SUCCESSFUL,
00134      * @c SYSTEM_EXCEPTION, @c USER_EXCEPTION, @c LOCATION_FORWARD,
00135      * @c TRANSPORT_RETRY, @c UNKNOWN..
00136      */
00137     virtual PortableInterceptor::ReplyStatus reply_status (
00138         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00139       ACE_THROW_SPEC ((CORBA::SystemException));
00140 
00141     /// If the reply status is
00142     /// @c PortableInterceptor::LOCATION_FORWARD return the
00143     /// object reference to which the request was forwarded.
00144     virtual CORBA::Object_ptr forward_reference (
00145         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00146       ACE_THROW_SPEC ((CORBA::SystemException)) ;
00147 
00148     /// Retrieve data from the "request scope" @c PICurrent object.
00149     virtual CORBA::Any * get_slot (
00150                                    PortableInterceptor::SlotId id
00151                                    ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00152       ACE_THROW_SPEC ((CORBA::SystemException,
00153                        PortableInterceptor::InvalidSlot));
00154 
00155     /// Return the @c IOP::ServiceContext with the given
00156     /// @c IOP::ServiceId from the request service context list.
00157     virtual IOP::ServiceContext * get_request_service_context (
00158         IOP::ServiceId id
00159         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00160       ACE_THROW_SPEC ((CORBA::SystemException));
00161 
00162     /// Return the @c IOP::ServiceContext with the given
00163     /// @c IOP::ServiceId from the reply service context list.
00164     virtual IOP::ServiceContext * get_reply_service_context (
00165         IOP::ServiceId id
00166         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00167       ACE_THROW_SPEC ((CORBA::SystemException));
00168 
00169     /// Return an @c Any containing the exception being sent, if any.
00170     /// Otherwise, throw a @c CORBA::BAD_INV_ORDER exception.
00171     /**
00172      * @note There is no trivial way to extract the exception from an
00173      *       @c Any.
00174      */
00175     virtual CORBA::Any * sending_exception (
00176         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00177       ACE_THROW_SPEC ((CORBA::SystemException));
00178 
00179     /// Return the @c ObjectId for the target object.
00180     virtual PortableInterceptor::ObjectId * object_id (
00181         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00182       ACE_THROW_SPEC ((CORBA::SystemException));
00183 
00184     /// Return the @c AdapterId for the POA handling the current
00185     /// request.
00186     virtual CORBA::OctetSeq * adapter_id (
00187         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00188       ACE_THROW_SPEC ((CORBA::SystemException));
00189 
00190     /// Return the server_id of the server. The value is passed to
00191     /// the ORB via @c -ORBServerId parameter.
00192     virtual char * server_id (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00193       ACE_THROW_SPEC ((CORBA::SystemException));
00194 
00195     /// Return the ORBId value that is passed to the @c ORB_init
00196     /// call.
00197     virtual char * orb_id (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00198       ACE_THROW_SPEC ((CORBA::SystemException));
00199 
00200     /// Return the name of the object adapter that services requests
00201     /// for the invoked object.
00202     virtual PortableInterceptor::AdapterName * adapter_name (
00203         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00204       ACE_THROW_SPEC ((CORBA::SystemException));
00205 
00206     /// Return the most derived interface of the target object.
00207     virtual char * target_most_derived_interface (
00208         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
00209       ACE_THROW_SPEC ((CORBA::SystemException));
00210 
00211     /// Return the policy of the given type in effect for the current
00212     /// request.
00213     virtual CORBA::Policy_ptr get_server_policy (
00214         CORBA::PolicyType type
00215         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00216       ACE_THROW_SPEC ((CORBA::SystemException));
00217 
00218     /// Insert data into the "request scope" @c PICurrent object.
00219     virtual void set_slot (PortableInterceptor::SlotId id,
00220                            const CORBA::Any & data
00221                            ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00222       ACE_THROW_SPEC ((CORBA::SystemException,
00223                        PortableInterceptor::InvalidSlot));
00224 
00225     /// Returns true if the target's type corresponds to the given
00226     /// @c RepositoryId.
00227     virtual CORBA::Boolean target_is_a (const char * id
00228                                         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00229       ACE_THROW_SPEC ((CORBA::SystemException));
00230 
00231     /// Add the @c IOP::ServiceContext to the reply (outgoing)
00232     /// @c IOP::ServiceContextList.
00233     virtual void add_reply_service_context (
00234         const IOP::ServiceContext & service_context,
00235         CORBA::Boolean replace
00236         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00237       ACE_THROW_SPEC ((CORBA::SystemException));
00238 
00239   public:
00240 
00241     /**
00242      * @name Helper methods specific to TAO.
00243      */
00244     //@{
00245 
00246     /// Extract the forward object reference from the
00247     /// @c PortableInterceptor::ForwardRequest exception, and set the
00248     /// reply status flag accordingly.
00249     void forward_reference (PortableInterceptor::ForwardRequest &exc);
00250 
00251     /// Set the forward reference associated with the current
00252     /// LOCATION_FORWARD reply.
00253     /**
00254      * @note This method is only invoked when a
00255      * @c PortableServer::ForwardRequest exception is thrown by a
00256      * servant manager.
00257      */
00258     void forward_reference (CORBA::Object_ptr obj);
00259 
00260     //@}
00261 
00262     /// Return a reference to the underlying @c TAO_ServerRequest
00263     /// object.
00264     TAO_ServerRequest &server_request (void);
00265 
00266   protected:
00267 
00268     /// Helper method to get the request and response service
00269     /// contexts.
00270     IOP::ServiceContext * get_service_context_i (
00271         TAO_Service_Context & service_context_list,
00272         IOP::ServiceId id
00273         ACE_ENV_ARG_DECL)
00274       ACE_THROW_SPEC ((CORBA::SystemException));
00275 
00276   protected:
00277 
00278     /// Underlying request object that contains much of the
00279     /// information encapsulated by this @c ServerRequestInfo
00280     /// implementation.
00281     TAO_ServerRequest & server_request_;
00282 
00283     /// Operation argument list.
00284     TAO::Argument * const * const args_;
00285 
00286     /// Number of element in the operation argument list.
00287     size_t const nargs_;
00288 
00289     /// Pointer to the @c Servant_Upcall object that contains the
00290     /// object ID, among other things.
00291     TAO::Portable_Server::Servant_Upcall * const servant_upcall_;
00292 
00293     /// Array of @c TypeCodes for user exceptions the operation is
00294     /// capable of raising.
00295     CORBA::TypeCode_ptr const * const exceptions_;
00296 
00297     /// The number of elements in the @c exceptions_ array.
00298     CORBA::ULong const nexceptions_;
00299   };
00300 
00301 }  // End namespace TAO
00302 
00303 TAO_END_VERSIONED_NAMESPACE_DECL
00304 
00305 # if defined (__ACE_INLINE__)
00306 #  include "tao/PI_Server/ServerRequestInfo.inl"
00307 # endif  /* __ACE_INLINE__ */
00308 
00309 #if defined(_MSC_VER)
00310 #pragma warning(pop)
00311 #endif /* _MSC_VER */
00312 
00313 #endif /* TAO_HAS_INTERCEPTORS == 1 */
00314 
00315 #include /**/ "ace/post.h"
00316 
00317 #endif /* TAO_SERVER_REQUEST_INFO_H */

Generated on Thu Nov 9 12:54:00 2006 for TAO_PI_Server by doxygen 1.3.6