Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / tao / PI_Server / ServerRequestInfo.h
blobaf0274b0509e2f22ee99fd582d4fde00296360cf
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file ServerRequestInfo.h
7 * This is the implementation of the
8 * @c PortableInterceptor::ServerRequestInfo interface.
10 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 * @author Ossama Othman
13 //=============================================================================
15 #ifndef TAO_SERVER_REQUEST_INFO_H
16 #define TAO_SERVER_REQUEST_INFO_H
18 #include /**/ "ace/pre.h"
20 #include "tao/orbconf.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #if (TAO_HAS_INTERCEPTORS == 1)
28 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
29 #include "tao/PI_Server/PI_Server_includeC.h"
30 #include "tao/PI/PI.h"
31 #include "tao/LocalObject.h"
32 #include "tao/OctetSeqC.h"
33 #include "tao/TAO_Server_Request.h"
34 #include "tao/PortableInterceptorC.h"
36 #if defined(_MSC_VER)
37 #pragma warning(push)
38 #pragma warning(disable:4250)
39 #endif /* _MSC_VER */
41 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
43 class TAO_ServerRequest;
44 class TAO_Service_Context;
46 namespace TAO
48 namespace Portable_Server
50 class Servant_Upcall;
54 namespace TAO
56 /**
57 * @class ServerRequestInfo
59 * @brief Implementation of the
60 * @c PortableInterceptor::ServerRequestInfo IDL interface.
62 * Implementation of the @c PortableInterceptor::ServerRequestInfo
63 * IDL interface.
65 * @note This class is currently not meant to be reference counted
66 * since it is instantiated on the stack.
68 class ServerRequestInfo
69 : public virtual PortableInterceptor::ServerRequestInfo
70 , public virtual ::CORBA::LocalObject
72 public:
74 /// Constructor.
75 ServerRequestInfo (TAO_ServerRequest & server_request,
76 TAO::Argument * const * args,
77 size_t nargs,
78 TAO::Portable_Server::Servant_Upcall *servant_upcall,
79 CORBA::TypeCode_ptr const * exceptions,
80 CORBA::ULong nexceptions);
82 /// Return an ID unique to the current request. This request ID may
83 /// or may not be the same as the GIOP request ID.
84 virtual CORBA::ULong request_id (void);
86 /// Return the operation name for the current request.
87 virtual char * operation (void);
89 /// Return the list of arguments passed to the current operation.
90 virtual Dynamic::ParameterList * arguments (void);
92 /// Return the list of exceptions the current operation is capable
93 /// of throwing.
94 virtual Dynamic::ExceptionList * exceptions (void);
96 virtual Dynamic::ContextList * contexts (void);
98 virtual Dynamic::RequestContext * operation_context (void);
100 /// Return the result of the current request. If there is no
101 /// return value then an @c Any with @c tk_void @c TypeCode is
102 /// returned. This method is not valid for oneway operations.
103 virtual CORBA::Any * result (void);
105 /// Returns @c true for a two-way operation, and @c false otherwise.
106 virtual CORBA::Boolean response_expected (void);
108 /// Return the @c sync_scope policy value for the current one-way
109 /// operation. If the operation is not a one-way, a
110 /// @c CORBA::BAD_INV_ORDER exception is thrown.
111 virtual Messaging::SyncScope sync_scope (void);
113 /// Return the reply status for the current request.
115 * Statuses can be @c PortableInterceptor::SUCCESSFUL,
116 * @c SYSTEM_EXCEPTION, @c USER_EXCEPTION, @c LOCATION_FORWARD,
117 * @c TRANSPORT_RETRY, @c UNKNOWN..
119 virtual PortableInterceptor::ReplyStatus reply_status (void);
121 /// If the reply status is
122 /// @c PortableInterceptor::LOCATION_FORWARD return the
123 /// object reference to which the request was forwarded.
124 virtual CORBA::Object_ptr forward_reference (void);
126 /// Retrieve data from the "request scope" @c PICurrent object.
127 virtual CORBA::Any * get_slot (PortableInterceptor::SlotId id);
129 /// Return the @c IOP::ServiceContext with the given
130 /// @c IOP::ServiceId from the request service context list.
131 virtual IOP::ServiceContext * get_request_service_context (
132 IOP::ServiceId id);
134 /// Return the @c IOP::ServiceContext with the given
135 /// @c IOP::ServiceId from the reply service context list.
136 virtual IOP::ServiceContext * get_reply_service_context (
137 IOP::ServiceId id);
139 /// Return an @c Any containing the exception being sent, if any.
140 /// Otherwise, throw a @c CORBA::BAD_INV_ORDER exception.
142 * @note There is no trivial way to extract the exception from an
143 * @c Any.
145 virtual CORBA::Any * sending_exception (void);
147 /// Return the @c ObjectId for the target object.
148 virtual PortableInterceptor::ObjectId * object_id (void);
150 /// Return the @c AdapterId for the POA handling the current
151 /// request.
152 virtual CORBA::OctetSeq * adapter_id (void);
154 /// Return the server_id of the server. The value is passed to
155 /// the ORB via @c -ORBServerId parameter.
156 virtual char * server_id (void);
158 /// Return the ORBId value that is passed to the @c ORB_init
159 /// call.
160 virtual char * orb_id (void);
162 /// Return the name of the object adapter that services requests
163 /// for the invoked object.
164 virtual PortableInterceptor::AdapterName * adapter_name (void);
166 /// Return the most derived interface of the target object.
167 virtual char * target_most_derived_interface (void);
169 /// Return the policy of the given type in effect for the current
170 /// request.
171 virtual CORBA::Policy_ptr get_server_policy (CORBA::PolicyType type);
173 /// Insert data into the "request scope" @c PICurrent object.
174 virtual void set_slot (PortableInterceptor::SlotId id,
175 const CORBA::Any & data);
177 /// Returns true if the target's type corresponds to the given
178 /// @c RepositoryId.
179 virtual CORBA::Boolean target_is_a (const char * id);
181 /// Add the @c IOP::ServiceContext to the reply (outgoing)
182 /// @c IOP::ServiceContextList.
183 virtual void add_reply_service_context (
184 const IOP::ServiceContext & service_context,
185 CORBA::Boolean replace);
187 public:
190 * @name Helper methods specific to TAO.
192 //@{
194 /// Extract the forward object reference from the
195 /// @c PortableInterceptor::ForwardRequest exception, and set the
196 /// reply status flag accordingly.
197 void forward_reference (PortableInterceptor::ForwardRequest &exc);
199 /// Set the forward reference associated with the current
200 /// LOCATION_FORWARD reply.
202 * @note This method is only invoked when a
203 * @c PortableServer::ForwardRequest exception is thrown by a
204 * servant manager.
206 void forward_reference (CORBA::Object_ptr obj);
208 //@}
210 /// Return a reference to the underlying @c TAO_ServerRequest
211 /// object.
212 TAO_ServerRequest &server_request (void);
214 protected:
216 /// Helper method to get the request and response service
217 /// contexts.
218 IOP::ServiceContext * get_service_context_i (
219 TAO_Service_Context & service_context_list,
220 IOP::ServiceId id);
222 protected:
224 /// Underlying request object that contains much of the
225 /// information encapsulated by this @c ServerRequestInfo
226 /// implementation.
227 TAO_ServerRequest & server_request_;
229 /// Operation argument list.
230 TAO::Argument * const * const args_;
232 /// Number of element in the operation argument list.
233 size_t const nargs_;
235 /// Pointer to the @c Servant_Upcall object that contains the
236 /// object ID, among other things.
237 TAO::Portable_Server::Servant_Upcall * const servant_upcall_;
239 /// Array of @c TypeCodes for user exceptions the operation is
240 /// capable of raising.
241 CORBA::TypeCode_ptr const * const exceptions_;
243 /// The number of elements in the @c exceptions_ array.
244 CORBA::ULong const nexceptions_;
247 } // End namespace TAO
249 TAO_END_VERSIONED_NAMESPACE_DECL
251 # if defined (__ACE_INLINE__)
252 # include "tao/PI_Server/ServerRequestInfo.inl"
253 # endif /* __ACE_INLINE__ */
255 #if defined(_MSC_VER)
256 #pragma warning(pop)
257 #endif /* _MSC_VER */
259 #endif /* TAO_HAS_INTERCEPTORS == 1 */
261 #include /**/ "ace/post.h"
263 #endif /* TAO_SERVER_REQUEST_INFO_H */