TAO_Server_Request.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005 *  @file    TAO_Server_Request.h
00006 *
00007 *  TAO_Server_Request.h,v 1.41 2006/07/01 15:46:08 mesnier_p Exp
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 
00033 #if TAO_HAS_INTERCEPTORS == 1
00034 
00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00036 
00037 namespace TAO
00038 {
00039   class PICurrent;
00040   class PICurrent_Impl;
00041 }
00042 TAO_END_VERSIONED_NAMESPACE_DECL
00043 
00044 #include "tao/PortableInterceptorC.h"
00045 
00046 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00047 
00048 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00049 
00050 class TAO_Pluggable_Messaging;
00051 class TAO_Transport;
00052 class TAO_AMH_Response_Handler;
00053 
00054 namespace CORBA
00055 {
00056   class ORB;
00057   typedef ORB *ORB_ptr;
00058 
00059   class Exception;
00060 }
00061 
00062 namespace TAO
00063 {
00064   namespace CSD
00065   {
00066     class FW_Server_Request_Wrapper;
00067   }
00068 }
00069 
00070 class TAO_Operation_Details;
00071 
00072 /**
00073  * @class TAO_ServerRequest
00074  *
00075  * @brief Class representing a ServerRequest object.
00076  *
00077  * Encapsulates CDR, transport and pluggable messaging
00078  * components on the server side.
00079 */
00080 class TAO_Export TAO_ServerRequest
00081 {
00082 public:
00083 
00084   /// Declare FW_Server_Request_Wrapper a friend
00085   /// This friendship makes the FW_Server_Request_Wrapper be able to
00086   /// clone the TAO_ServerRequest.
00087   friend class TAO::CSD::FW_Server_Request_Wrapper;
00088 
00089   /// Declare TAO_AMH_Response_Handler a friend
00090   /**
00091    * The TAO_AMH_Response_Handler class needs to copy part of the
00092    * state in a TAO_ServerRequest, however, we do not want to expose
00093    * that state as public members of this class, neither do we want to
00094    * add modifiers to the TAO_AMH_Response_Handler class that would
00095    * allow us (the TAO_ServerRequest class) to set the state.
00096    *
00097    * Lucky for us, C++ is a language for adult developers, and allow
00098    * us to use the evil "friend" declaration.
00099    *
00100    */
00101   friend class TAO_AMH_Response_Handler;
00102 
00103   // Constructors.
00104 
00105   TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
00106                      TAO_InputCDR &input,
00107                      TAO_OutputCDR &output,
00108                      TAO_Transport *transport,
00109                      TAO_ORB_Core *orb_core);
00110 
00111   TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base,
00112                      CORBA::ULong request_id,
00113                      CORBA::Boolean response_expected,
00114                      CORBA::Boolean deferred_flag,
00115                      TAO::ObjectKey &object_key,
00116                      const char *operation,
00117                      TAO_OutputCDR &output,
00118                      TAO_Transport *transport,
00119                      TAO_ORB_Core *orb_core,
00120                      int &parse_error);
00121 
00122   /// Constructor used by thru-POA collocated invocation path.
00123   TAO_ServerRequest (TAO_ORB_Core * orb_core,
00124                      TAO_Operation_Details const & details,
00125                      CORBA::Object_ptr target);
00126 
00127   /// Destructor.
00128   ~TAO_ServerRequest (void);
00129 
00130   /**
00131    * @name Request attributes.
00132    */
00133   //@{
00134   /// Return the operation name.
00135   const char *operation (void) const;
00136 
00137   /// Set the operation name.
00138   void operation (const char *operation,
00139                   size_t length,
00140                   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   /// Get the exception type.
00212   CORBA::ULong exception_type (void);
00213 
00214   /// Set the exception type.
00215   void exception_type (CORBA::ULong except_type);
00216 
00217   /// Set the requesting principal
00218   void requesting_principal (const CORBA::OctetSeq & principal);
00219 
00220   /// Return the reference to the tagged profile
00221   TAO_Tagged_Profile &profile (void);
00222 
00223   void tao_send_reply (void);
00224 
00225   void tao_send_reply_exception (CORBA::Exception&);
00226 
00227   /// Set the boolean member to 1.
00228   void is_dsi (void);
00229 
00230   /// Set the member.
00231   void dsi_nvlist_align (ptrdiff_t alignment);
00232 
00233   // Get the operation details for the current request.
00234   TAO_Operation_Details const * operation_details (void) const;
00235 
00236   /// Set the argument_flag
00237   void argument_flag (CORBA::Boolean flag);
00238 
00239   /// Get the argument_flag
00240   CORBA::Boolean argument_flag (void);
00241 
00242   /// Returns @c true if the current request is collocated.
00243   bool collocated (void) const;
00244 
00245 #if TAO_HAS_INTERCEPTORS == 1
00246   /// Send cached reply. Used in scenarios where the FTORB thinks that
00247   /// this request is a duplicate
00248   void send_cached_reply (CORBA::OctetSeq &ocs);
00249 
00250   /// Return the octet sequence pointer through which the FTORB would
00251   /// send the reply back.
00252   void result_seq (CORBA::OctetSeq &ocs);
00253 
00254   /// Check whether we got the result.
00255   int got_result (void);
00256 
00257   /// Return a reference to the number of interceptors pushed on to
00258   /// the current interceptor flow stack.
00259   /**
00260    * @note It is a reference since the Portable Interceptor flow stack
00261    *       code must be able to modify this value and use that value
00262    *       at a later time without being forced to use TSS.
00263    */
00264   size_t & interceptor_count (void);
00265 
00266   /// Return a reference to the "request scope" PICurrent object.
00267   TAO::PICurrent_Impl *rs_pi_current (void);
00268 
00269   CORBA::Exception *caught_exception (void);
00270 
00271   void caught_exception (CORBA::Exception *exception);
00272 
00273   /// Set the status of the received reply.
00274   void reply_status (PortableInterceptor::ReplyStatus s);
00275 
00276   /// Get the status of the received reply.
00277   PortableInterceptor::ReplyStatus reply_status (void);
00278 
00279 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00280 
00281 private:
00282   TAO_Pluggable_Messaging *mesg_base_;
00283 
00284   /// Operation name.
00285   ACE_CString operation_;
00286 
00287   CORBA::Object_var forward_location_;
00288 
00289   /// Incoming stream.
00290   TAO_InputCDR *incoming_;
00291 
00292   /// Outgoing stream.
00293   TAO_OutputCDR *outgoing_;
00294 
00295   /// Transport class.
00296   TAO_Transport *transport_;
00297 
00298   /// 0: oneway (SYNC_NONE or SYNC_WITH_TRANSPORT)
00299   /// 1: twoway, or oneway (SYNC_WITH_SERVER or SYNC_WITH_TARGET)
00300   CORBA::Boolean response_expected_;
00301 
00302   /**
00303    * 0: Reply would be sent by the object of this class which is the
00304    *    default.
00305    * 1: Reply would not be prepared by this class and it would be
00306    *    deferred for somebody.
00307    */
00308   CORBA::Boolean deferred_reply_;
00309 
00310   /// 1: oneway (SYNC_WITH_SERVER)
00311   /// 0: anything else
00312   CORBA::Boolean sync_with_server_;
00313 
00314   /// Did we get passed to a CORBA::ServerRequest?
00315   CORBA::Boolean is_dsi_;
00316 
00317   /// Exception type (will be NO_EXCEPTION in the majority of the cases).
00318   CORBA::ULong exception_type_;
00319 
00320   /// A pointer to the ORB Core for the context where the request was
00321   /// created.
00322   TAO_ORB_Core *orb_core_;
00323 
00324   /// Service Context info
00325   TAO_Service_Context request_service_context_;
00326   TAO_Service_Context reply_service_context_;
00327 
00328   /// Unique identifier for a request.
00329   CORBA::ULong request_id_;
00330 
00331   /// The tagged profile that has the addressing information.
00332   TAO_Tagged_Profile profile_;
00333 
00334   /// Identifies the requester.
00335   CORBA::OctetSeq_var requesting_principal_;
00336 
00337   /// Used to pad CDR stream if we have used DSI.
00338   ptrdiff_t dsi_nvlist_align_;
00339 
00340   TAO_Operation_Details const * operation_details_;
00341 
00342   /**
00343    * An argument flag to indicate whether there is any data that is
00344    * going to get marshaled along as a reply. The default will be 1
00345    * which indicates that we have some data that needs to be sent back
00346    * to the client.
00347    */
00348   CORBA::Boolean argument_flag_;
00349 
00350 #if TAO_HAS_INTERCEPTORS == 1
00351   /// The number of interceptors pushed on to the current interceptor
00352   /// flow stack.
00353   size_t interceptor_count_;
00354 
00355   /// The "Request Scope Current" (RSC) object, as required by
00356   /// Portable Interceptors.
00357   TAO::PICurrent_Impl *rs_pi_current_;
00358 
00359   /// Used by the FTORB
00360   CORBA::OctetSeq_var result_seq_;
00361 
00362   /// Pointer to the caught exception.
00363   CORBA::Exception * caught_exception_;
00364 
00365   /// Reply status for the current request.
00366   PortableInterceptor::ReplyStatus reply_status_;
00367 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00368 };
00369 
00370 TAO_END_VERSIONED_NAMESPACE_DECL
00371 
00372 #if defined (__ACE_INLINE__)
00373 # include "tao/TAO_Server_Request.i"
00374 #endif /* __ACE_INLINE__ */
00375 
00376 #include /**/ "ace/post.h"
00377 
00378 #endif /* TAO_SERVER_REQUEST_H */

Generated on Thu Nov 9 11:54:23 2006 for TAO by doxygen 1.3.6