3 //=============================================================================
5 * @file TAO_Server_Request.h
7 * Header file for CORBA's Server Skeleton Interface's
8 * "Server Request" type.
11 * @author Copyright 1994-1995 by Sun Microsystems Inc.
12 * @author Chris Cleeland
13 * @author Aniruddha Gokhale
15 //=============================================================================
17 #ifndef TAO_SERVER_REQUEST_H
18 #define TAO_SERVER_REQUEST_H
20 #include /**/ "ace/pre.h"
21 #include "ace/SString.h"
23 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 #include "tao/Tagged_Profile.h"
28 #include "tao/Service_Context.h"
29 #include "tao/Object.h"
30 #include "tao/Transport_Selection_Guard.h"
31 #include "tao/GIOPC.h"
33 #if TAO_HAS_INTERCEPTORS == 1
35 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
42 TAO_END_VERSIONED_NAMESPACE_DECL
44 #include "tao/PortableInterceptorC.h"
46 #endif /* TAO_HAS_INTERCEPTORS == 1 */
48 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
50 class TAO_GIOP_Message_Base
;
52 class TAO_AMH_Response_Handler
;
66 class FW_Server_Request_Wrapper
;
70 class TAO_Operation_Details
;
73 * @class TAO_ServerRequest
75 * @brief Class representing a ServerRequest object.
77 * Encapsulates CDR, transport and pluggable messaging
78 * components on the server side.
80 class TAO_Export TAO_ServerRequest
83 /// Declare FW_Server_Request_Wrapper a friend
84 /// This friendship makes the FW_Server_Request_Wrapper be able to
85 /// clone the TAO_ServerRequest.
86 friend class TAO::CSD::FW_Server_Request_Wrapper
;
88 /// Declare TAO_AMH_Response_Handler a friend
90 * The TAO_AMH_Response_Handler class needs to copy part of the
91 * state in a TAO_ServerRequest, however, we do not want to expose
92 * that state as public members of this class, neither do we want to
93 * add modifiers to the TAO_AMH_Response_Handler class that would
94 * allow us (the TAO_ServerRequest class) to set the state.
96 * Lucky for us, C++ is a language for adult developers, and allow
97 * us to use the evil "friend" declaration.
100 friend class TAO_AMH_Response_Handler
;
104 TAO_ServerRequest (TAO_GIOP_Message_Base
*mesg_base
,
106 TAO_OutputCDR
&output
,
107 TAO_Transport
*transport
,
108 TAO_ORB_Core
*orb_core
);
110 TAO_ServerRequest (TAO_GIOP_Message_Base
*mesg_base
,
111 CORBA::ULong request_id
,
112 CORBA::Boolean response_expected
,
113 CORBA::Boolean deferred_flag
,
114 TAO::ObjectKey
&object_key
,
115 const char *operation
,
116 TAO_OutputCDR
&output
,
117 TAO_Transport
*transport
,
118 TAO_ORB_Core
*orb_core
,
121 /// Constructor used by thru-POA collocated invocation path.
122 TAO_ServerRequest (TAO_ORB_Core
* orb_core
,
123 TAO_Operation_Details
const & details
,
124 CORBA::Object_ptr target
);
127 ~TAO_ServerRequest ();
130 * @name Request attributes.
133 /// Return the operation name.
134 const char *operation () const;
136 /// Set the operation name.
137 void operation (const char *operation
, size_t length
, int release
);
139 /// Return the length of the operation.
140 size_t operation_length () const;
143 /// Return the underlying ORB.
144 CORBA::ORB_ptr
orb ();
146 /// Return the ORB core pointer member.
147 TAO_ORB_Core
*orb_core () const;
149 /// Start a Reply message.
152 /// Retrieve the incoming stream.
153 TAO_InputCDR
* incoming () const;
155 /// Retrieve the outgoing stream.
156 TAO_OutputCDR
* outgoing () const;
158 /// Is the response expected?
159 CORBA::Boolean
response_expected () const;
161 /// Should the reply be deferred?
162 CORBA::Boolean
deferred_reply () const;
164 /// Set the response expected flag.
165 void response_expected (CORBA::Boolean response
);
167 /// Should we return before dispatching the servant?
168 CORBA::Boolean
sync_with_server () const;
170 /// Set the sync_with_server flag.
171 void sync_with_server (CORBA::Boolean sync_flag
);
173 /// Is the request at risk of being queued?
174 CORBA::Boolean
is_queued () const;
176 /// Set the queued flag.
177 void is_queued (CORBA::Boolean qeueued_flag
);
179 /// Send a sync reply if needed after _dispatch is called
180 void sync_after_dispatch ();
182 /// Send a sync reply if needed before _dispatch is called to avoid
183 /// possible queuing first.
184 void sync_before_dispatch ();
186 /// Used with reliable oneway requests.
187 void send_no_exception_reply ();
189 TAO::ObjectKey
&object_key ();
191 /// Return the request TAO_Service_Context
192 TAO_Service_Context
&request_service_context ();
194 /// Return the reply TAO_Service_Context
195 TAO_Service_Context
&reply_service_context ();
197 IOP::ServiceContextList
&reply_service_info ();
199 IOP::ServiceContextList
&request_service_info ();
201 /// Return the underlying transport
202 TAO_Transport
*transport ();
204 /// To handle System Exceptions at the lowest level, a method
205 /// returning the request_id_ is needed.
207 CORBA::ULong
request_id ();
208 void request_id (CORBA::ULong req
);
212 * Set the reference to the object the request should be forwarded
213 * to. This reference will only be used if set prior to calling
216 void forward_location (CORBA::Object_ptr forward_reference
);
218 /// Get the forward_location.
219 CORBA::Object_ptr
forward_location ();
222 * Since forward location is allowed to be nil then this is a proper
223 * method to check if the request is being forwarded.
225 bool is_forwarded () const;
227 /// Get the reply status
228 GIOP::ReplyStatusType
reply_status ();
230 /// Set the reply status
231 void reply_status (GIOP::ReplyStatusType except_type
);
233 /// Set the requesting principal
234 void requesting_principal (const CORBA::OctetSeq
& principal
);
236 /// Return the reference to the tagged profile
237 TAO_Tagged_Profile
&profile ();
239 void tao_send_reply ();
241 void tao_send_reply_exception (const CORBA::Exception
& ex
);
243 /// Set the boolean member to true.
247 void dsi_nvlist_align (ptrdiff_t alignment
);
249 /// Get the operation details for the current request.
250 TAO_Operation_Details
const * operation_details () const;
252 /// Set the argument_flag
253 void argument_flag (CORBA::Boolean flag
);
255 /// Get the argument_flag
256 CORBA::Boolean
argument_flag ();
258 /// Returns @c true if the current request is collocated.
259 bool collocated () const;
261 #if TAO_HAS_INTERCEPTORS == 1
262 /// Send cached reply. Used in scenarios where the FTORB thinks that
263 /// this request is a duplicate
264 void send_cached_reply (CORBA::OctetSeq
&ocs
);
266 /// Return a reference to the number of interceptors pushed on to
267 /// the current interceptor flow stack.
269 * @note It is a reference since the Portable Interceptor flow stack
270 * code must be able to modify this value and use that value
271 * at a later time without being forced to use TSS.
273 size_t & interceptor_count ();
275 /// Return a reference to the "request scope" PICurrent object.
276 TAO::PICurrent_Impl
*rs_pi_current ();
278 CORBA::Exception
*caught_exception ();
280 void caught_exception (CORBA::Exception
*exception
);
282 /// Set the status of the received reply.
283 void pi_reply_status (PortableInterceptor::ReplyStatus s
);
285 /// Get the status of the received reply.
286 PortableInterceptor::ReplyStatus
pi_reply_status ();
287 #endif /* TAO_HAS_INTERCEPTORS == 1 */
289 #if TAO_HAS_ZIOP == 1
290 CORBA::Policy_ptr
clientCompressionEnablingPolicy ();
291 void clientCompressionEnablingPolicy (CORBA::Policy_ptr
);
292 CORBA::Policy_ptr
clientCompressorIdLevelListPolicy ();
293 void clientCompressorIdLevelListPolicy (CORBA::Policy_ptr
);
294 #endif /* TAO_HAS_ZIOP == 1 */
297 /// Default ctor only used to create a TAO_ServerRequest that is about
298 /// to be the target of a clone operation.
299 TAO_ServerRequest ();
301 TAO_GIOP_Message_Base
*mesg_base_
;
304 const char* operation_
;
306 /// Operation length.
307 size_t operation_len_
;
309 /// Do we own the memory associated with operation_?
310 bool release_operation_
;
312 CORBA::Object_var forward_location_
;
317 TAO_InputCDR
*incoming_
;
320 TAO_OutputCDR
*outgoing_
;
322 /// false: oneway (SYNC_NONE or SYNC_WITH_TRANSPORT)
323 /// true: twoway, or oneway (SYNC_WITH_SERVER or SYNC_WITH_TARGET)
324 CORBA::Boolean response_expected_
;
327 * false: Reply would be sent by the object of this class which is the
329 * true: Reply would not be prepared by this class and it would be
330 * deferred for somebody.
332 CORBA::Boolean deferred_reply_
;
334 /// true: oneway (SYNC_WITH_SERVER)
335 /// false: anything else
336 CORBA::Boolean sync_with_server_
;
338 /// true: this request is (or may be) queued by the POA
339 /// false: no POA queuing involved
340 CORBA::Boolean is_queued_
;
342 /// Did we get passed to a CORBA::ServerRequest?
343 CORBA::Boolean is_dsi_
;
345 /// Reply status (will be NO_EXCEPTION in the majority of the cases).
346 GIOP::ReplyStatusType reply_status_
;
348 /// A pointer to the ORB Core for the context where the request was
350 TAO_ORB_Core
*orb_core_
;
352 /// Service Context info
353 TAO_Service_Context request_service_context_
;
354 TAO_Service_Context reply_service_context_
;
356 /// Unique identifier for a request.
357 CORBA::ULong request_id_
;
359 /// The tagged profile that has the addressing information.
360 TAO_Tagged_Profile profile_
;
362 /// Identifies the requester.
363 CORBA::OctetSeq_var requesting_principal_
;
365 /// Used to pad CDR stream if we have used DSI.
366 ptrdiff_t dsi_nvlist_align_
;
368 TAO_Operation_Details
const * operation_details_
;
371 * An argument flag to indicate whether there is any data that is
372 * going to get marshaled along as a reply. The default will be true
373 * which indicates that we have some data that needs to be sent back
376 CORBA::Boolean argument_flag_
;
378 #if TAO_HAS_INTERCEPTORS == 1
379 /// The number of interceptors pushed on to the current interceptor
381 size_t interceptor_count_
;
383 /// The "Request Scope Current" (RSC) object, as required by
384 /// Portable Interceptors.
385 TAO::PICurrent_Impl
*rs_pi_current_
;
387 /// Pointer to the caught exception.
388 CORBA::Exception
* caught_exception_
;
390 /// Reply status for the current request.
391 PortableInterceptor::ReplyStatus pi_reply_status_
;
392 #endif /* TAO_HAS_INTERCEPTORS == 1 */
394 ///// Transport class.
395 /// An RAII (resource acquisition is initialization) class instance
396 /// for interfacing with TSS storage for the "current" transport.
397 TAO::Transport_Selection_Guard transport_
;
399 #if TAO_HAS_ZIOP == 1
400 CORBA::Policy_var clientCompressionEnablingPolicy_
;
401 CORBA::Policy_var clientCompressorIdLevelListPolicy_
;
402 #endif /* TAO_HAS_ZIOP == 1 */
405 TAO_END_VERSIONED_NAMESPACE_DECL
407 #if defined (__ACE_INLINE__)
408 # include "tao/TAO_Server_Request.inl"
409 #endif /* __ACE_INLINE__ */
411 #include /**/ "ace/post.h"
413 #endif /* TAO_SERVER_REQUEST_H */