00001 // -*- C++ -*- 00002 // 00003 //============================================================================= 00004 /** 00005 * @file Synch_Invocation.h 00006 * 00007 * Synch_Invocation.h,v 1.12 2005/11/24 11:05:46 ossama Exp 00008 * 00009 * 00010 * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> 00011 */ 00012 //============================================================================= 00013 #ifndef TAO_SYNCH_INVOCATION_H 00014 #define TAO_SYNCH_INVOCATION_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "tao/Remote_Invocation.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "tao/SystemException.h" 00024 00025 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00026 class ACE_Time_Value; 00027 ACE_END_VERSIONED_NAMESPACE_DECL 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 class TAO_Operation_Details; 00032 class TAO_Synch_Reply_Dispatcher; 00033 class TAO_InputCDR; 00034 class TAO_Bind_Dispatcher_Guard; 00035 00036 namespace TAO 00037 { 00038 class Profile_Transport_Resolver; 00039 00040 /** 00041 * @class Synch_Twoway_Invocation 00042 * 00043 * @brief All the action for a synchronous twoway invocation happen 00044 * here. 00045 * 00046 * An object of this type is created by TAO::Invocation_Adapter 00047 * and invokes a method on this class. The method takes care of 00048 * creating and sending a request, waiting for a reply and 00049 * demarshalling the reply for the client. 00050 * 00051 */ 00052 class TAO_Export Synch_Twoway_Invocation : public Remote_Invocation 00053 { 00054 public: 00055 /// Constructor used by TAO::Invocation_Adapter 00056 /** 00057 * @param otarget The original target on which this invocation 00058 * was started. This is there to be passed up to its parent 00059 * class. 00060 * 00061 * @param resolver The profile and transport holder. 00062 * 00063 * @param detail Operation details of the invocation on the target 00064 * 00065 * @param response_expected Flag to indicate whether the 00066 * operation encapsulated by @a op returns a response or not. 00067 */ 00068 Synch_Twoway_Invocation (CORBA::Object_ptr otarget, 00069 Profile_Transport_Resolver &resolver, 00070 TAO_Operation_Details &detail, 00071 bool response_expected = true); 00072 00073 /// Method used by the adapter to kickstart an invocation to the 00074 /// remote object. 00075 /** 00076 * There is a exception declaration in this method which ensures 00077 * that the exceptions propogated by the remote objects are 00078 * converted a CORBA exceptions for the clients. This method does 00079 * a bunch of things necessary to create and send the 00080 * invocation. This method is also nerve centre for the 00081 * interceptor invocation points. 00082 */ 00083 Invocation_Status remote_twoway (ACE_Time_Value *max_wait_time 00084 ACE_ENV_ARG_DECL) 00085 ACE_THROW_SPEC ((CORBA::Exception)); 00086 00087 protected: 00088 00089 /** 00090 * This method is selectively made virtual, so that inherited 00091 * classes can overload the user exception handling type. For 00092 * example the DII needs a totally different method of 00093 * user exception exception handling 00094 */ 00095 virtual Invocation_Status handle_user_exception (TAO_InputCDR &cdr 00096 ACE_ENV_ARG_DECL) 00097 ACE_THROW_SPEC ((CORBA::Exception)); 00098 00099 /// Helper method used to handle location forwarded replies. 00100 Invocation_Status location_forward (TAO_InputCDR &cdr 00101 ACE_ENV_ARG_DECL) 00102 ACE_THROW_SPEC ((CORBA::SystemException)); 00103 00104 /// Helper method used to handle system exceptions from the remote 00105 /// objects. 00106 Invocation_Status handle_system_exception (TAO_InputCDR &cdr 00107 ACE_ENV_ARG_DECL) 00108 ACE_THROW_SPEC ((CORBA::SystemException)); 00109 00110 /// As the name suggests waits for a reply from the remote ORB. 00111 /** 00112 * This method returns an exception when there is an error. 00113 */ 00114 Invocation_Status wait_for_reply (ACE_Time_Value *max_wait_time, 00115 TAO_Synch_Reply_Dispatcher &rd, 00116 TAO_Bind_Dispatcher_Guard &bd 00117 ACE_ENV_ARG_DECL) 00118 ACE_THROW_SPEC ((CORBA::SystemException)); 00119 00120 private: 00121 00122 /// Helper method that checks the reply status of the 00123 /// replies and takes appropriate action. 00124 /** 00125 * This method returns an exception when there is an error. 00126 */ 00127 Invocation_Status check_reply_status ( 00128 TAO_Synch_Reply_Dispatcher &rd 00129 ACE_ENV_ARG_DECL); 00130 00131 }; 00132 00133 /** 00134 * @class Synch_Oneway_Invocation 00135 * 00136 * @brief All the action for a synchronous oneway invocation happen 00137 * here. 00138 * 00139 * This class inherits from twoway invocation for the following 00140 * reasons 00141 * 00142 * - We deal with oneway invocation in more or less the same way as 00143 * two but for waiting for the reply 00144 * 00145 * - For some SYNC_SCOPE policies namely SYNC_WITH_TARGET and 00146 * SYNC_WITH_SERVER the invocation classes have to treat the 00147 * invocation as a twoway invocation (more or less) 00148 * 00149 */ 00150 class TAO_Export Synch_Oneway_Invocation 00151 : public Synch_Twoway_Invocation 00152 { 00153 public: 00154 /// Constructor used by TAO::Invocation_Adapter 00155 /** 00156 * @param otarget The original target on which this invocation 00157 * was started. This is there to be passed up to its parent 00158 * class. 00159 * 00160 * @param resolver The profile and transport holder. 00161 * 00162 * @param detail Operation details of the invocation on the target 00163 */ 00164 Synch_Oneway_Invocation (CORBA::Object_ptr otarget, 00165 Profile_Transport_Resolver &resolver, 00166 TAO_Operation_Details &detail); 00167 00168 /// Method used by the adapter to kickstart an oneway invocation 00169 /// to the remote object. 00170 Invocation_Status remote_oneway (ACE_Time_Value *max_wait_time 00171 ACE_ENV_ARG_DECL) 00172 ACE_THROW_SPEC ((CORBA::Exception)); 00173 }; 00174 00175 /** 00176 * @class Reply_Guard 00177 * 00178 * @brief A guard class used for storing and forwarding the reply 00179 * status to the portable interceptors. 00180 */ 00181 class TAO_Export Reply_Guard 00182 { 00183 public: 00184 00185 Reply_Guard (Invocation_Base *s, 00186 Invocation_Status is); 00187 00188 /// The destructor calls Invocation_Base::reply_received with the 00189 /// right reply status, which is useful for PI's. 00190 ~Reply_Guard (void); 00191 00192 /// Mutator to set the invocation status. 00193 void set_status (Invocation_Status s); 00194 00195 private: 00196 00197 Reply_Guard (Reply_Guard const &); 00198 Reply_Guard & operator= (Reply_Guard const &); 00199 00200 private: 00201 00202 Invocation_Base * const invocation_; 00203 Invocation_Status status_; 00204 }; 00205 00206 } 00207 00208 TAO_END_VERSIONED_NAMESPACE_DECL 00209 00210 #if defined (__ACE_INLINE__) 00211 # include "tao/Synch_Invocation.inl" 00212 #endif /* __ACE_INLINE__ */ 00213 00214 #include /**/ "ace/post.h" 00215 #endif /*TAO_SYNCH_INVOCATION_H*/