00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Profile_Transport_Resolver.h 00006 * 00007 * Profile_Transport_Resolver.h,v 1.14 2006/04/26 17:12:47 mesnier_p Exp 00008 * 00009 * 00010 * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef TAO_PROFILE_TRANSPORT_RESOLVER_H 00015 #define TAO_PROFILE_TRANSPORT_RESOLVER_H 00016 00017 #include /**/ "ace/pre.h" 00018 #include "ace/Global_Macros.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ace/CORBA_macros.h" 00025 00026 #include "tao/SystemException.h" 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 class ACE_Time_Value; 00030 ACE_END_VERSIONED_NAMESPACE_DECL 00031 00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00033 00034 class TAO_Stub; 00035 class TAO_Profile; 00036 class TAO_Transport; 00037 class TAO_Endpoint; 00038 class TAO_Transport_Descriptor_Interface; 00039 00040 namespace CORBA 00041 { 00042 class Environment; 00043 class Object; 00044 class PolicyList; 00045 00046 class Object; 00047 typedef Object *Object_ptr; 00048 } 00049 00050 namespace TAO 00051 { 00052 class Synch_Twoway_Invocation; 00053 00054 /** 00055 * @class Profile_Transport_Resolver 00056 * 00057 * @brief Chooses the profile and a transport for a target object on 00058 * which an invocation can be made. 00059 * 00060 * A target object is represented by multiple profiles, which 00061 * theoretically provides multiple paths to the same target 00062 * object. This class helps in choosing the right profile, and pick 00063 * a transport from cache (or create a new transport if needed) that 00064 * represents the profile. 00065 */ 00066 class TAO_Export Profile_Transport_Resolver 00067 { 00068 public: 00069 /// Constructor 00070 /** 00071 * With @a block we tell whether this resolved should always deliver 00072 * a connection by blocking or unblock before the connection is 00073 * completely established. Please note that this has *nothing* to 00074 * do with the synchronous or asynch connect strategy used for 00075 * making connections. This is a local flag used by the clients of 00076 * this to dictate some local behavior. 00077 */ 00078 Profile_Transport_Resolver (CORBA::Object *p, 00079 TAO_Stub *stub, 00080 bool block = true); 00081 00082 ~Profile_Transport_Resolver (void); 00083 00084 /// Method where the bunch of the action takes place. 00085 /** 00086 * This is the entry point from the TAO::Invocation_Adapter 00087 * class. This method accesses the endpoint selector factory from 00088 * the ORB_Core to decide on the strategy to be used for selecting 00089 * the profile. 00090 */ 00091 void resolve (ACE_Time_Value *val 00092 ACE_ENV_ARG_DECL) 00093 ACE_THROW_SPEC ((CORBA::SystemException)); 00094 00095 //@{ 00096 /** 00097 * @name Accessors and mutators for this class. The following methods 00098 * are used by the clients of this class to access strategies and 00099 * other internal workings. 00100 */ 00101 00102 /// Mutator for profile. 00103 void profile (TAO_Profile *pfile); 00104 00105 /// Accessor for profile. 00106 TAO_Profile *profile (void) const; 00107 00108 /// Accessor for TAO_Stub 00109 TAO_Stub *stub (void) const; 00110 00111 /// Accessor for the target in use 00112 CORBA::Object *object (void) const; 00113 00114 /// Accessor for the transport reserved for this invocation. 00115 TAO_Transport *transport (void) const; 00116 00117 /// See if the transport cache has an available transport and 00118 /// use that one rather than trying to connect via the connector. 00119 /// Separating this functionality enables the look up of many 00120 /// endpoints before trying the more time-consuming trip through 00121 /// the actual connector. 00122 int find_transport (TAO_Transport_Descriptor_Interface *); 00123 00124 /// Accessor to indicate whether we should block while 00125 /// establishing a connection. 00126 bool blocked_connect (void) const; 00127 //@} 00128 00129 /// Signal to let the resolver know that the transport has been 00130 /// released back to the cache. 00131 void transport_released (void) const; 00132 00133 /// This is a callback method used by the endpoint selectors to 00134 /// delegate the responsibility of reserving a transport from the 00135 /// connection cache for this invocation. When the descriptor 00136 /// contains more than one endpoint (as part of a linked list) and 00137 /// the parallel flag is true then the connector will look for a 00138 /// connection on any of the endpoints if it supports that 00139 /// behavior, otherwise an ENOTSUP errno will be set and the 00140 /// method will return false. 00141 bool try_connect (TAO_Transport_Descriptor_Interface *desc, 00142 ACE_Time_Value *val 00143 ACE_ENV_ARG_DECL); 00144 00145 bool try_parallel_connect (TAO_Transport_Descriptor_Interface *desc, 00146 ACE_Time_Value *val 00147 ACE_ENV_ARG_DECL); 00148 00149 /// This method wraps a call to the orb core to see if parallel 00150 /// connection attempts are even desired. This is controlled by 00151 /// the -ORBUseParallelConnects 1|0 commandline option. 00152 bool use_parallel_connect (void) const; 00153 00154 /// Initialize the inconsistent policy list that this object has 00155 /// cached. 00156 void init_inconsistent_policies (ACE_ENV_SINGLE_ARG_DECL) 00157 ACE_THROW_SPEC ((CORBA::SystemException)); 00158 00159 CORBA::PolicyList *inconsistent_policies (void) const; 00160 00161 CORBA::PolicyList *steal_inconsistent_policies (void); 00162 private: 00163 00164 /// Helper method to access get the connection timeout from the 00165 /// ORB. 00166 bool get_connection_timeout (ACE_Time_Value &max_wait_time); 00167 00168 private: 00169 bool try_connect_i (TAO_Transport_Descriptor_Interface *desc, 00170 ACE_Time_Value *val, 00171 bool parallel 00172 ACE_ENV_ARG_DECL); 00173 00174 /// Target object 00175 mutable CORBA::Object *obj_; 00176 00177 /// Stub object for the target object. 00178 TAO_Stub *stub_; 00179 00180 /// The transport selected for this invocation. 00181 TAO_Transport *transport_; 00182 00183 /// The profile that has been selected for this invocation. 00184 TAO_Profile *profile_; 00185 00186 /// List of inconsistent policies 00187 /** 00188 * If current effective policies cause the invocation to raise 00189 * CORBA::INV_POLICY exception, the conflicting/problematic policies 00190 * are stored in this list. This is used by \param 00191 * Object::_validate_connection method to inform clients about 00192 * causes of invocation failure. 00193 * @par 00194 * Conflicting policies are only stored in this list if \param 00195 * init_inconsistent_policies method has been called prior to the 00196 * beginning of invocation. This saves extra work of conflicting 00197 * policies 'logging' when it's not needed. 00198 * 00199 * @note We don't use _var with a reason. Using _var would 00200 * involve including the header file for at least 00201 * Policy_ForwardC.h, and that is what we precisely want to 00202 * avoid. 00203 */ 00204 CORBA::PolicyList *inconsistent_policies_; 00205 00206 /// Has the transport been idle? 00207 mutable bool is_released_; 00208 00209 /// Should we block while trying to make a connection 00210 bool const blocked_; 00211 }; 00212 } // TAO namespace end 00213 00214 TAO_END_VERSIONED_NAMESPACE_DECL 00215 00216 #if defined (__ACE_INLINE__) 00217 # include "tao/Profile_Transport_Resolver.inl" 00218 #endif /* __ACE_INLINE__ */ 00219 00220 #include /**/ "ace/post.h" 00221 00222 #endif /*TAO_PROFILE_TRANSPORT_RESOLVER_H*/