Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / PI_Server / ServerRequestInfo.h
blob47b36ca9678054d8ffd79894152dc037989a5ce4
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:
73 /// Constructor.
74 ServerRequestInfo (TAO_ServerRequest & server_request,
75 TAO::Argument * const * args,
76 size_t nargs,
77 TAO::Portable_Server::Servant_Upcall *servant_upcall,
78 CORBA::TypeCode_ptr const * exceptions,
79 CORBA::ULong nexceptions);
81 /// Return an ID unique to the current request. This request ID may
82 /// or may not be the same as the GIOP request ID.
83 virtual CORBA::ULong request_id ();
85 /// Return the operation name for the current request.
86 virtual char * operation ();
88 /// Return the list of arguments passed to the current operation.
89 virtual Dynamic::ParameterList * arguments ();
91 /// Return the list of exceptions the current operation is capable
92 /// of throwing.
93 virtual Dynamic::ExceptionList * exceptions ();
95 virtual Dynamic::ContextList * contexts ();
97 virtual Dynamic::RequestContext * operation_context ();
99 /// Return the result of the current request. If there is no
100 /// return value then an @c Any with @c tk_void @c TypeCode is
101 /// returned. This method is not valid for oneway operations.
102 virtual CORBA::Any * result ();
104 /// Returns @c true for a two-way operation, and @c false otherwise.
105 virtual CORBA::Boolean response_expected ();
107 /// Return the @c sync_scope policy value for the current one-way
108 /// operation. If the operation is not a one-way, a
109 /// @c CORBA::BAD_INV_ORDER exception is thrown.
110 virtual ::Messaging::SyncScope sync_scope ();
112 /// Return the reply status for the current request.
114 * Statuses can be @c PortableInterceptor::SUCCESSFUL,
115 * @c SYSTEM_EXCEPTION, @c USER_EXCEPTION, @c LOCATION_FORWARD,
116 * @c TRANSPORT_RETRY, @c UNKNOWN..
118 virtual PortableInterceptor::ReplyStatus reply_status ();
120 /// If the reply status is
121 /// @c PortableInterceptor::LOCATION_FORWARD return the
122 /// object reference to which the request was forwarded.
123 virtual CORBA::Object_ptr forward_reference ();
125 /// Retrieve data from the "request scope" @c PICurrent object.
126 virtual CORBA::Any * get_slot (PortableInterceptor::SlotId id);
128 /// Return the @c IOP::ServiceContext with the given
129 /// @c IOP::ServiceId from the request service context list.
130 virtual IOP::ServiceContext * get_request_service_context (
131 IOP::ServiceId id);
133 /// Return the @c IOP::ServiceContext with the given
134 /// @c IOP::ServiceId from the reply service context list.
135 virtual IOP::ServiceContext * get_reply_service_context (
136 IOP::ServiceId id);
138 /// Return an @c Any containing the exception being sent, if any.
139 /// Otherwise, throw a @c CORBA::BAD_INV_ORDER exception.
141 * @note There is no trivial way to extract the exception from an
142 * @c Any.
144 virtual CORBA::Any * sending_exception ();
146 /// Return the @c ObjectId for the target object.
147 virtual PortableInterceptor::ObjectId * object_id ();
149 /// Return the @c AdapterId for the POA handling the current
150 /// request.
151 virtual CORBA::OctetSeq * adapter_id ();
153 /// Return the server_id of the server. The value is passed to
154 /// the ORB via @c -ORBServerId parameter.
155 virtual char * server_id ();
157 /// Return the ORBId value that is passed to the @c ORB_init
158 /// call.
159 virtual char * orb_id ();
161 /// Return the name of the object adapter that services requests
162 /// for the invoked object.
163 virtual PortableInterceptor::AdapterName * adapter_name ();
165 /// Return the most derived interface of the target object.
166 virtual char * target_most_derived_interface ();
168 /// Return the policy of the given type in effect for the current
169 /// request.
170 virtual CORBA::Policy_ptr get_server_policy (CORBA::PolicyType type);
172 /// Insert data into the "request scope" @c PICurrent object.
173 virtual void set_slot (PortableInterceptor::SlotId id,
174 const CORBA::Any & data);
176 /// Returns true if the target's type corresponds to the given
177 /// @c RepositoryId.
178 virtual CORBA::Boolean target_is_a (const char * id);
180 /// Add the @c IOP::ServiceContext to the reply (outgoing)
181 /// @c IOP::ServiceContextList.
182 virtual void add_reply_service_context (
183 const IOP::ServiceContext & service_context,
184 CORBA::Boolean replace);
186 public:
188 * @name Helper methods specific to TAO.
190 //@{
191 /// Extract the forward object reference from the
192 /// @c PortableInterceptor::ForwardRequest exception, and set the
193 /// reply status flag accordingly.
194 void forward_reference (PortableInterceptor::ForwardRequest &exc);
196 /// Set the forward reference associated with the current
197 /// LOCATION_FORWARD reply.
199 * @note This method is only invoked when a
200 * @c PortableServer::ForwardRequest exception is thrown by a
201 * servant manager.
203 void forward_reference (CORBA::Object_ptr obj);
205 //@}
207 /// Return a reference to the underlying @c TAO_ServerRequest
208 /// object.
209 TAO_ServerRequest &server_request ();
211 protected:
212 /// Helper method to get the request and response service
213 /// contexts.
214 IOP::ServiceContext * get_service_context_i (
215 TAO_Service_Context & service_context_list,
216 IOP::ServiceId id);
218 protected:
219 /// Underlying request object that contains much of the
220 /// information encapsulated by this @c ServerRequestInfo
221 /// implementation.
222 TAO_ServerRequest & server_request_;
224 /// Operation argument list.
225 TAO::Argument * const * const args_;
227 /// Number of element in the operation argument list.
228 size_t const nargs_;
230 /// Pointer to the @c Servant_Upcall object that contains the
231 /// object ID, among other things.
232 TAO::Portable_Server::Servant_Upcall * const servant_upcall_;
234 /// Array of @c TypeCodes for user exceptions the operation is
235 /// capable of raising.
236 CORBA::TypeCode_ptr const * const exceptions_;
238 /// The number of elements in the @c exceptions_ array.
239 CORBA::ULong const nexceptions_;
241 } // End namespace TAO
243 TAO_END_VERSIONED_NAMESPACE_DECL
245 # if defined (__ACE_INLINE__)
246 # include "tao/PI_Server/ServerRequestInfo.inl"
247 # endif /* __ACE_INLINE__ */
249 #if defined(_MSC_VER)
250 #pragma warning(pop)
251 #endif /* _MSC_VER */
253 #endif /* TAO_HAS_INTERCEPTORS == 1 */
255 #include /**/ "ace/post.h"
257 #endif /* TAO_SERVER_REQUEST_INFO_H */