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

Generated on Tue Feb 2 17:37:53 2010 for TAO by  doxygen 1.4.7