TAO_Server_Request.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005 *  @file    TAO_Server_Request.h
00006 *
00007 *  $Id: TAO_Server_Request.h 79080 2007-07-30 12:30:55Z iliyan $
00008 *
00009 *  Header file for CORBA's Server Skeleton Interface's
00010 *  "Server Request" type.
00011 *
00012 *
00013 * @author Copyright 1994-1995 by Sun Microsystems Inc.
00014 * @author Chris Cleeland
00015 * @author Aniruddha Gokhale
00016 */
00017 //=============================================================================
00018 
00019 #ifndef TAO_SERVER_REQUEST_H
00020 #define TAO_SERVER_REQUEST_H
00021 
00022 #include /**/ "ace/pre.h"
00023 #include "ace/SString.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 #include "tao/Tagged_Profile.h"
00030 #include "tao/Service_Context.h"
00031 #include "tao/Object.h"
00032 #include "tao/Transport_Selection_Guard.h"
00033 
00034 #if TAO_HAS_INTERCEPTORS == 1
00035 
00036 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00037 
00038 namespace TAO
00039 {
00040   class PICurrent;
00041   class PICurrent_Impl;
00042 }
00043 TAO_END_VERSIONED_NAMESPACE_DECL
00044 
00045 #include "tao/PortableInterceptorC.h"
00046 
00047 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00048 
00049 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00050 
00051 class TAO_Pluggable_Messaging;
00052 class TAO_Transport;
00053 class TAO_AMH_Response_Handler;
00054 
00055 namespace CORBA
00056 {
00057   class ORB;
00058   typedef ORB *ORB_ptr;
00059 
00060   class Exception;
00061 }
00062 
00063 namespace TAO
00064 {
00065   namespace CSD
00066   {
00067     class FW_Server_Request_Wrapper;
00068   }
00069 }
00070 
00071 class TAO_Operation_Details;
00072 
00073 /**
00074  * @class TAO_ServerRequest
00075  *
00076  * @brief Class representing a ServerRequest object.
00077  *
00078  * Encapsulates CDR, transport and pluggable messaging
00079  * components on the server side.
00080 */
00081 class TAO_Export TAO_ServerRequest
00082 {
00083 public:
00084 
00085   /// Declare FW_Server_Request_Wrapper a friend
00086   /// This friendship makes the FW_Server_Request_Wrapper be able to
00087   /// clone the TAO_ServerRequest.
00088   friend class TAO::CSD::FW_Server_Request_Wrapper;
00089 
00090   /// Declare TAO_AMH_Response_Handler a friend
00091   /**
00092    * The TAO_AMH_Response_Handler class needs to copy part of the
00093    * state in a TAO_ServerRequest, however, we do not want to expose
00094    * that state as public members of this class, neither do we want to
00095    * add modifiers to the TAO_AMH_Response_Handler class that would
00096    * allow us (the TAO_ServerRequest class) to set the state.
00097    *
00098    * Lucky for us, C++ is a language for adult developers, and allow
00099    * us to use the evil "friend" declaration.
00100    *
00101    */
00102   friend class TAO_AMH_Response_Handler;
00103 
00104   // Constructors.
00105 
00106   TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
00107                      TAO_InputCDR &input,
00108                      TAO_OutputCDR &output,
00109                      TAO_Transport *transport,
00110                      TAO_ORB_Core *orb_core);
00111 
00112   TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
00113                      CORBA::ULong request_id,
00114                      CORBA::Boolean response_expected,
00115                      CORBA::Boolean deferred_flag,
00116                      TAO::ObjectKey &object_key,
00117                      const char *operation,
00118                      TAO_OutputCDR &output,
00119                      TAO_Transport *transport,
00120                      TAO_ORB_Core *orb_core,
00121                      int &parse_error);
00122 
00123   /// Constructor used by thru-POA collocated invocation path.
00124   TAO_ServerRequest (TAO_ORB_Core * orb_core,
00125                      TAO_Operation_Details const & details,
00126                      CORBA::Object_ptr target);
00127 
00128   /// Destructor.
00129   ~TAO_ServerRequest (void);
00130 
00131   /**
00132    * @name Request attributes.
00133    */
00134   //@{
00135   /// Return the operation name.
00136   const char *operation (void) const;
00137 
00138   /// Set the operation name.
00139   void operation (const char *operation,
00140                   size_t length,
00141                   int release);
00142 
00143   /// Return the length of the operation.
00144   size_t operation_length (void) const;
00145   //@}
00146 
00147   /// Return the underlying ORB.
00148   CORBA::ORB_ptr orb (void);
00149 
00150   /// Return the ORB core pointer member.
00151   TAO_ORB_Core *orb_core (void) const;
00152 
00153   /// Start a Reply message.
00154   void init_reply (void);
00155 
00156   /// Retrieve the incoming stream.
00157   TAO_InputCDR * incoming (void) const;
00158 
00159   /// Retrieve the outgoing stream.
00160   TAO_OutputCDR * outgoing (void) const;
00161 
00162   /// Is the response expected?
00163   CORBA::Boolean response_expected (void) const;
00164 
00165   /// Should the reply be deferred?
00166   CORBA::Boolean deferred_reply (void) const;
00167 
00168   /// Set the response expected flag.
00169   void response_expected (CORBA::Boolean response);
00170 
00171   /// Should we return before dispatching the servant?
00172   CORBA::Boolean sync_with_server (void) const;
00173 
00174   /// Set the sync_with_server flag.
00175   void sync_with_server (CORBA::Boolean sync_flag);
00176 
00177   /// Used with reliable oneway requests.
00178   void send_no_exception_reply (void);
00179 
00180   TAO::ObjectKey &object_key (void);
00181 
00182   /// Return the request TAO_Service_Context
00183   TAO_Service_Context &request_service_context (void);
00184 
00185   /// Return the reply TAO_Service_Context
00186   TAO_Service_Context &reply_service_context (void);
00187 
00188   IOP::ServiceContextList &reply_service_info (void);
00189 
00190   IOP::ServiceContextList &request_service_info (void);
00191 
00192   /// Return the underlying transport
00193   TAO_Transport *transport ();
00194 
00195   /// To handle System Exceptions at the lowest level, a method
00196   /// returning the request_id_ is needed.
00197   //@{
00198   CORBA::ULong request_id (void);
00199   void request_id (CORBA::ULong req);
00200   //@}
00201 
00202   /**
00203    * Set the reference to the object the request should be forwarded
00204    * to.  This reference will only be used if set prior to calling
00205    * init_reply().
00206    */
00207   void forward_location (CORBA::Object_ptr forward_reference);
00208 
00209   /// Get the forward_location.
00210   CORBA::Object_ptr forward_location (void);
00211 
00212   /// Get the exception type.
00213   CORBA::ULong exception_type (void);
00214 
00215   /// Set the exception type.
00216   void exception_type (CORBA::ULong except_type);
00217 
00218   /// Set the requesting principal
00219   void requesting_principal (const CORBA::OctetSeq & principal);
00220 
00221   /// Return the reference to the tagged profile
00222   TAO_Tagged_Profile &profile (void);
00223 
00224   void tao_send_reply (void);
00225 
00226   void tao_send_reply_exception (const CORBA::Exception& ex);
00227 
00228   /// Set the boolean member to 1.
00229   void is_dsi (void);
00230 
00231   /// Set the member.
00232   void dsi_nvlist_align (ptrdiff_t alignment);
00233 
00234   // Get the operation details for the current request.
00235   TAO_Operation_Details const * operation_details (void) const;
00236 
00237   /// Set the argument_flag
00238   void argument_flag (CORBA::Boolean flag);
00239 
00240   /// Get the argument_flag
00241   CORBA::Boolean argument_flag (void);
00242 
00243   /// Returns @c true if the current request is collocated.
00244   bool collocated (void) const;
00245 
00246 #if TAO_HAS_INTERCEPTORS == 1
00247   /// Send cached reply. Used in scenarios where the FTORB thinks that
00248   /// this request is a duplicate
00249   void send_cached_reply (CORBA::OctetSeq &ocs);
00250 
00251   /// Return a reference to the number of interceptors pushed on to
00252   /// the current interceptor flow stack.
00253   /**
00254    * @note It is a reference since the Portable Interceptor flow stack
00255    *       code must be able to modify this value and use that value
00256    *       at a later time without being forced to use TSS.
00257    */
00258   size_t & interceptor_count (void);
00259 
00260   /// Return a reference to the "request scope" PICurrent object.
00261   TAO::PICurrent_Impl *rs_pi_current (void);
00262 
00263   CORBA::Exception *caught_exception (void);
00264 
00265   void caught_exception (CORBA::Exception *exception);
00266 
00267   /// Set the status of the received reply.
00268   void reply_status (PortableInterceptor::ReplyStatus s);
00269 
00270   /// Get the status of the received reply.
00271   PortableInterceptor::ReplyStatus reply_status (void);
00272 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00273 
00274 private:
00275   /// Default ctor only used to create a TAO_ServerRequest that is about
00276   /// to be the target of a clone operation.
00277   TAO_ServerRequest (void);
00278 
00279   TAO_Pluggable_Messaging *mesg_base_;
00280 
00281   /// Operation name.
00282   const char* operation_;
00283 
00284   /// Operation length.
00285   size_t operation_len_;
00286 
00287   /// Do we own the memory associated with operation_?
00288   bool release_operation_;
00289 
00290   CORBA::Object_var forward_location_;
00291 
00292   /// Incoming stream.
00293   TAO_InputCDR *incoming_;
00294   /// Outgoing stream.
00295   TAO_OutputCDR *outgoing_;
00296 
00297   /// false: oneway (SYNC_NONE or SYNC_WITH_TRANSPORT)
00298   /// true: twoway, or oneway (SYNC_WITH_SERVER or SYNC_WITH_TARGET)
00299   CORBA::Boolean response_expected_;
00300 
00301   /**
00302    * false: Reply would be sent by the object of this class which is the
00303    *    default.
00304    * true: Reply would not be prepared by this class and it would be
00305    *    deferred for somebody.
00306    */
00307   CORBA::Boolean deferred_reply_;
00308 
00309   /// true: oneway (SYNC_WITH_SERVER)
00310   /// false: anything else
00311   CORBA::Boolean sync_with_server_;
00312 
00313   /// Did we get passed to a CORBA::ServerRequest?
00314   CORBA::Boolean is_dsi_;
00315 
00316   /// Exception type (will be NO_EXCEPTION in the majority of the cases).
00317   CORBA::ULong exception_type_;
00318 
00319   /// A pointer to the ORB Core for the context where the request was
00320   /// created.
00321   TAO_ORB_Core *orb_core_;
00322 
00323   /// Service Context info
00324   TAO_Service_Context request_service_context_;
00325   TAO_Service_Context reply_service_context_;
00326 
00327   /// Unique identifier for a request.
00328   CORBA::ULong request_id_;
00329 
00330   /// The tagged profile that has the addressing information.
00331   TAO_Tagged_Profile profile_;
00332 
00333   /// Identifies the requester.
00334   CORBA::OctetSeq_var requesting_principal_;
00335 
00336   /// Used to pad CDR stream if we have used DSI.
00337   ptrdiff_t dsi_nvlist_align_;
00338 
00339   TAO_Operation_Details const * operation_details_;
00340 
00341   /**
00342    * An argument flag to indicate whether there is any data that is
00343    * going to get marshaled along as a reply. The default will be 1
00344    * which indicates that we have some data that needs to be sent back
00345    * to the client.
00346    */
00347   CORBA::Boolean argument_flag_;
00348 
00349 #if TAO_HAS_INTERCEPTORS == 1
00350   /// The number of interceptors pushed on to the current interceptor
00351   /// flow stack.
00352   size_t interceptor_count_;
00353 
00354   /// The "Request Scope Current" (RSC) object, as required by
00355   /// Portable Interceptors.
00356   TAO::PICurrent_Impl *rs_pi_current_;
00357 
00358   /// Pointer to the caught exception.
00359   CORBA::Exception * caught_exception_;
00360 
00361   /// Reply status for the current request.
00362   PortableInterceptor::ReplyStatus reply_status_;
00363 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00364 
00365   ///// Transport class.
00366   /// An RAII (resource acquisition is initialization) class instance
00367   /// for interfacing with TSS storage for the "current" transport.
00368   TAO::Transport_Selection_Guard transport_;
00369 };
00370 
00371 TAO_END_VERSIONED_NAMESPACE_DECL
00372 
00373 #if defined (__ACE_INLINE__)
00374 # include "tao/TAO_Server_Request.inl"
00375 #endif /* __ACE_INLINE__ */
00376 
00377 #include /**/ "ace/post.h"
00378 
00379 #endif /* TAO_SERVER_REQUEST_H */

Generated on Sun Jan 27 13:07:37 2008 for TAO by doxygen 1.3.6