00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Invocation_Base.h 00006 * 00007 * $Id: Invocation_Base.h 85400 2009-05-19 12:13:48Z sma $ 00008 * 00009 * 00010 * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef TAO_INVOCATION_BASE_H 00015 #define TAO_INVOCATION_BASE_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "tao/Object.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "tao/Invocation_Utils.h" 00026 #include "tao/GIOPC.h" 00027 00028 #if TAO_HAS_INTERCEPTORS == 1 00029 #include "tao/Exception.h" 00030 #include "tao/PI_ForwardC.h" 00031 #include "tao/ClientRequestInterceptor_Adapter.h" 00032 #include "tao/ServerRequestInterceptor_Adapter.h" 00033 #endif /* TAO_HAS_INTERCEPTORS == 1 */ 00034 00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00036 00037 class TAO_Service_Context; 00038 class TAO_Operation_Details; 00039 class TAO_Stub; 00040 00041 namespace TAO 00042 { 00043 class Invocation_Adapter; 00044 00045 /** 00046 * @class Invocation_Base 00047 * 00048 * @brief The base class for the invocation object 00049 * 00050 * This class is the base of the invocation object hiererachy. This 00051 * hierarchy is classified based on the type of invocation and the 00052 * mode of invocation. One of the objects from the hierarchy is 00053 * created on the stack for every invocation. 00054 * 00055 * In addition this class encapsulates the essential details that 00056 * are required for PortableInterceptors to function 00057 * correctly. Further this class also provides some helper and 00058 * accessor methods that are used by clients. 00059 */ 00060 class TAO_Export Invocation_Base 00061 { 00062 public: 00063 virtual ~Invocation_Base (void); 00064 00065 /// Accessor and mutator methods 00066 //@{ 00067 TAO_Stub *stub (void) const; 00068 00069 /// Accessor and mutator methods for forwarded object 00070 /// locations. 00071 /** 00072 * These access methods have to be public so that the 00073 * PortableInterceptor can use them 00074 */ 00075 CORBA::Object_ptr forwarded_reference (void); 00076 void forwarded_reference (CORBA::Object_ptr o); 00077 00078 /// Accessors for the service context list. 00079 /** 00080 * The service context lists are actually cached 00081 * elsewhere. Providing this accessor helps the PI to access this 00082 * list in both remote and collocated mode. 00083 */ 00084 TAO_Service_Context &request_service_context (void); 00085 TAO_Service_Context &reply_service_context (void); 00086 00087 /// Return the forwarded object location by loosing ownership. 00088 CORBA::Object_ptr steal_forwarded_reference (void); 00089 00090 /// Return the effective target of the invocation. 00091 /** 00092 * Please see the PortableInterceptor specification in the CORBA 00093 * spec to understand what effective target means. 00094 */ 00095 CORBA::Object_ptr effective_target (void) const; 00096 00097 /// Return the target object 00098 CORBA::Object_ptr target (void) const; 00099 00100 /// Does this invocation return a response? 00101 CORBA::Boolean response_expected (void) const; 00102 00103 /// Accessor of reply_status of the invocation. 00104 GIOP::ReplyStatusType reply_status (void) const; 00105 00106 /// Mutator of reply_status of the invocation. 00107 void reply_status (GIOP::ReplyStatusType s); 00108 00109 /// The operaton details of the invocation 00110 TAO_Operation_Details &operation_details (void); 00111 //@} 00112 00113 protected: 00114 /** 00115 * @param otarget The original target on which this invocation 00116 * was started. 00117 * 00118 * @param target the target on which this invocation is flowing 00119 * ie. the effective target 00120 * 00121 * @param op operation details of the invocation on @a target 00122 * 00123 * @param response_expected flag to indicate whether the 00124 * operation encapsulated by @a op returns a response or not. 00125 */ 00126 Invocation_Base (CORBA::Object_ptr otarget, 00127 CORBA::Object_ptr target, 00128 TAO_Stub *stub, 00129 TAO_Operation_Details &op, 00130 bool response_expected, 00131 bool request_is_remote); 00132 00133 protected: 00134 /// The operation details on which we are operating on. 00135 TAO_Operation_Details &details_; 00136 00137 /// Forwarded object reference. 00138 CORBA::Object_var forwarded_to_; 00139 00140 /// Is response expected? 00141 bool response_expected_; 00142 00143 /// A GIOP reply status of the invocation. 00144 GIOP::ReplyStatusType reply_status_; 00145 00146 private: 00147 Invocation_Base (const Invocation_Base&); 00148 Invocation_Base & operator= (const Invocation_Base &); 00149 00150 private: 00151 //@{ 00152 /** 00153 * The following object reference pointers are *not* 00154 * duplicated. They are cached for portable interceptors, and they 00155 * just live for the lifetime of the request. Hence there is no 00156 * point in duplicating the pointers. 00157 */ 00158 /// The original target on which the invocation was started. 00159 CORBA::Object_ptr otarget_; 00160 00161 /// The effective target on which the invocation is on. 00162 CORBA::Object_ptr target_; 00163 //@} 00164 00165 TAO_Stub *stub_; 00166 00167 /// Operations invoked by the 00168 /// PortableInterceptor::ClientRequestInfo object to get details 00169 /// about the operation and related stuff. 00170 //@{ 00171 #if TAO_HAS_INTERCEPTORS == 1 00172 public: 00173 /// Return a reference to the number of interceptors pushed on to 00174 /// the current interceptor flow stack. 00175 /** 00176 * @note It is a reference since the Portable Interceptor flow stack 00177 * code must be able to modify this value and use that value 00178 * at a later time without being forced to use TSS. 00179 */ 00180 size_t &stack_size (void); 00181 00182 CORBA::Exception *caught_exception (void); 00183 00184 /// Change the exception status. 00185 void exception (CORBA::Exception *exception); 00186 00187 /// Invocation status. 00188 TAO::Invocation_Status invoke_status (void) const; 00189 /// Mutator to set the invocation status. 00190 void invoke_status (Invocation_Status s); 00191 00192 PortableInterceptor::ReplyStatus pi_reply_status (void) const; 00193 00194 /// Accessor used to determine if the current invocation is part 00195 /// of a remote request, and if not, it will be considered to be 00196 /// part of a collocated request. 00197 bool is_remote_request() const; 00198 00199 protected: 00200 /// Helper method to invoke send_request interception call to all 00201 /// the registered interceptors. 00202 Invocation_Status send_request_interception (void); 00203 00204 /// Helper method to invoke receive_reply interception call to all 00205 /// the registered interceptors. 00206 Invocation_Status receive_reply_interception (void); 00207 00208 /// Helper method to invoke receive_other interception call to all 00209 /// the registered interceptors. 00210 Invocation_Status receive_other_interception (void); 00211 00212 /// Helper methods to handle interception calls when exceptions 00213 /// are thrown by the PortableInterceptor. 00214 PortableInterceptor::ReplyStatus 00215 handle_any_exception (CORBA::Exception * e); 00216 00217 PortableInterceptor::ReplyStatus handle_all_exception (void); 00218 00219 protected: 00220 /// The client requestor adapter 00221 ClientRequestInterceptor_Adapter *cri_adapter_; 00222 ServerRequestInterceptor_Adapter *sri_adapter_; 00223 00224 size_t stack_size_; 00225 00226 TAO::Invocation_Status invoke_status_; 00227 00228 private: 00229 /// Pointer to the caught exception. 00230 CORBA::Exception *caught_exception_; 00231 00232 /// Flag used to distinguish a remote invocation versus a collocated 00233 /// (thru-poa) invocation. 00234 bool const is_remote_request_; 00235 #endif /*TAO_HAS_INTERCEPTORS*/ 00236 //@} 00237 }; 00238 } 00239 00240 TAO_END_VERSIONED_NAMESPACE_DECL 00241 00242 #if defined (__ACE_INLINE__) 00243 # include "tao/Invocation_Base.inl" 00244 #endif /* __ACE_INLINE__ */ 00245 00246 #include /**/ "ace/post.h" 00247 00248 #endif /*TAO_INVOCATION_BASE_H*/