#include <RequestProcessingStrategyServantActivator.h>
Inheritance diagram for TAO::Portable_Server::RequestProcessingStrategyServantActivator:
Definition at line 35 of file RequestProcessingStrategyServantActivator.h.
TAO::Portable_Server::RequestProcessingStrategyServantActivator::RequestProcessingStrategyServantActivator | ( | void | ) |
Definition at line 25 of file RequestProcessingStrategyServantActivator.cpp.
00025 : 00026 etherealize_objects_ (true) 00027 { 00028 }
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::cleanup_servant | ( | PortableServer::Servant | servant, | |
const PortableServer::ObjectId & | user_id | |||
) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 241 of file RequestProcessingStrategyServantActivator.cpp.
References TAO_ServantBase::_remove_ref(), etherealize_servant(), and CORBA::is_nil().
00245 { 00246 // If a servant manager is associated with the POA, 00247 // ServantLocator::etherealize will be invoked with the oid and the 00248 // servant. (The deactivate_object operation does not wait for the 00249 // etherealize operation to complete before deactivate_object 00250 // returns.) 00251 // 00252 // Note: If the servant associated with the oid is serving multiple 00253 // Object Ids, ServantLocator::etherealize may be invoked multiple 00254 // times with the same servant when the other objects are 00255 // deactivated. It is the responsibility of the object 00256 // implementation to refrain from destroying the servant while it is 00257 // active with any Id. 00258 00259 // If the POA has no ServantActivator associated with it, the POA 00260 // implementation calls _remove_ref when all operation invocations 00261 // have completed. If there is a ServantActivator, the Servant is 00262 // consumed by the call to ServantActivator::etherealize instead. 00263 00264 // @bala, is this order correct, see 11.3.9.17 of the spec, it 00265 // says first remove from the map, then etherealize. not the 00266 // other way around 00267 // @@ Johnny, you are right! This will not show up until a 00268 // thread is trying to activate the object in another thread 00269 // using activate_object_with_id (). A test case is a must for 00270 // atleast this issue. 00271 if (servant) 00272 { 00273 if (this->etherealize_objects_ && 00274 !CORBA::is_nil (this->servant_activator_.in ())) 00275 { 00276 this->etherealize_servant (user_id, 00277 servant, 00278 this->poa_->cleanup_in_progress ()); 00279 } 00280 else 00281 { 00282 // ATTENTION: Trick locking here, see class header for details 00283 Non_Servant_Upcall non_servant_upcall (*this->poa_); 00284 ACE_UNUSED_ARG (non_servant_upcall); 00285 00286 servant->_remove_ref (); 00287 } 00288 } 00289 00290 // This operation causes the association of the Object Id specified 00291 // by the oid parameter and its servant to be removed from the 00292 // Active Object Map. 00293 if (this->poa_->unbind_using_user_id (user_id) != 0) 00294 throw ::CORBA::OBJ_ADAPTER (); 00295 }
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::etherealize_objects | ( | CORBA::Boolean | etherealize_objects | ) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 298 of file RequestProcessingStrategyServantActivator.cpp.
References etherealize_objects_.
00300 { 00301 this->etherealize_objects_ = etherealize_objects; 00302 }
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::etherealize_servant | ( | const PortableServer::ObjectId & | object_id, | |
PortableServer::Servant | servant, | |||
CORBA::Boolean | cleanup_in_progress | |||
) | [private] |
Definition at line 191 of file RequestProcessingStrategyServantActivator.cpp.
References TAO::Portable_Server::RequestProcessingStrategy::poa_, servant_activator_, and TAO_Root_POA::servant_has_remaining_activations().
Referenced by cleanup_servant(), and locate_servant().
00196 { 00197 CORBA::Boolean remaining_activations = 00198 this->poa_->servant_has_remaining_activations (servant); 00199 00200 // ATTENTION: Trick locking here, see class header for details 00201 Non_Servant_Upcall non_servant_upcall (*this->poa_); 00202 ACE_UNUSED_ARG (non_servant_upcall); 00203 00204 // @todo This is not according to the spec. According to 11.3.6.2 at the 00205 // end when etherealize returns a system exception the POA ignores the 00206 // exception 00207 this->servant_activator_->etherealize (object_id, 00208 this->poa_, 00209 servant, 00210 cleanup_in_progress, 00211 remaining_activations); 00212 }
PortableServer::ServantManager_ptr TAO::Portable_Server::RequestProcessingStrategyServantActivator::get_servant_manager | ( | void | ) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 44 of file RequestProcessingStrategyServantActivator.cpp.
00045 { 00046 return PortableServer::ServantManager::_duplicate (this->servant_activator_.in ()); 00047 }
PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyServantActivator::incarnate_servant | ( | const PortableServer::ObjectId & | object_id | ) | [private] |
Definition at line 215 of file RequestProcessingStrategyServantActivator.cpp.
References CORBA::COMPLETED_NO, CORBA::OMGVMCID, and servant_activator_.
Referenced by locate_servant().
00217 { 00218 PortableServer::Servant servant = 0; 00219 00220 // ATTENTION: Trick locking here, see class header for details 00221 Non_Servant_Upcall non_servant_upcall (*this->poa_); 00222 ACE_UNUSED_ARG (non_servant_upcall); 00223 00224 // @@ 00225 // Invocations of incarnate on the servant manager are serialized. 00226 // Invocations of etherealize on the servant manager are serialized. 00227 // Invocations of incarnate and etherealize on the servant manager are mutually exclusive. 00228 servant = this->servant_activator_->incarnate (object_id, this->poa_); 00229 00230 if (servant == 0) 00231 { 00232 throw ::CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 7, CORBA::COMPLETED_NO); 00233 } 00234 else 00235 { 00236 return servant; 00237 } 00238 }
PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyServantActivator::locate_servant | ( | const char * | operation, | |
const PortableServer::ObjectId & | system_id, | |||
TAO::Portable_Server::Servant_Upcall & | servant_upcall, | |||
TAO::Portable_Server::POA_Current_Impl & | poa_current_impl, | |||
bool & | wait_occurred_restart_call | |||
) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 90 of file RequestProcessingStrategyServantActivator.cpp.
References etherealize_servant(), TAO_Root_POA::find_servant(), incarnate_servant(), TAO::Portable_Server::Servant_Upcall::increment_servant_refcount(), TAO_Root_POA::is_servant_activation_allowed(), TAO::Portable_Server::POA_Current_Impl::object_id(), TAO::Portable_Server::RequestProcessingStrategy::poa_, and TAO::Portable_Server::RequestProcessingStrategyServantManager::validate_servant_manager().
00097 { 00098 PortableServer::Servant servant = 0; 00099 00100 servant = this->poa_->find_servant (system_id, 00101 servant_upcall, 00102 poa_current_impl); 00103 00104 if (servant != 0) 00105 { 00106 return servant; 00107 } 00108 00109 // If the POA has the USE_SERVANT_MANAGER policy, a servant manager 00110 // has been associated with the POA so the POA will invoke incarnate 00111 // or preinvoke on it to find a servant that may handle the 00112 // request. (The choice of method depends on the NON_RETAIN or 00113 // RETAIN policy of the POA.) If no servant manager has been 00114 // associated with the POA, the POA raises the OBJ_ADAPTER system 00115 // exception. 00116 // 00117 // If a servant manager is located and invoked, but the servant 00118 // manager is not directly capable of incarnating the object, it 00119 // (the servant manager) may deal with the circumstance in a variety 00120 // of ways, all of which are the application's responsibility. Any 00121 // system exception raised by the servant manager will be returned 00122 // to the client in the reply. In addition to standard CORBA 00123 // exceptions, a servant manager is capable of raising a 00124 // ForwardRequest exception. This exception includes an object 00125 // reference. 00126 // 00127 00128 this->validate_servant_manager (this->servant_activator_.in ()); 00129 00130 servant = this->incarnate_servant (poa_current_impl.object_id ()); 00131 00132 // If the incarnate operation returns a servant that is 00133 // already active for a different Object Id and if the POA 00134 // also has the UNIQUE_ID policy, the incarnate has violated 00135 // the POA policy and is considered to be in error. The POA 00136 // will raise an OBJ_ADAPTER system exception for the 00137 // request. 00138 bool may_activate = 00139 this->poa_->is_servant_activation_allowed (servant, 00140 wait_occurred_restart_call); 00141 00142 if (!may_activate) 00143 { 00144 // If we are not allowed to activate the servant, throw an exception 00145 // etherealize is not called because the servant is never added to 00146 // the active object map 00147 throw ::CORBA::OBJ_ADAPTER (); 00148 } 00149 00150 // The POA enters the returned Servant value into the Active 00151 // Object Map so that subsequent requests with the same 00152 // ObjectId value will be delivered directly to that servant 00153 // without invoking the servant manager. Only run if there 00154 // are no errors or if a restart is not required. 00155 if (!wait_occurred_restart_call) 00156 { 00157 int const result = 00158 this->poa_-> 00159 rebind_using_user_id_and_system_id (servant, 00160 poa_current_impl.object_id (), 00161 system_id, 00162 servant_upcall); 00163 if (result != 0) 00164 { 00165 // Throw an exception, etherealize is not called because servant 00166 // is not added to the active object map 00167 throw ::CORBA::OBJ_ADAPTER (); 00168 } 00169 00170 // Increment the reference count on the servant upcall. 00171 servant_upcall.increment_servant_refcount (); 00172 } 00173 else 00174 { 00175 CORBA::Boolean cleanup_in_progress = 0; 00176 this->etherealize_servant (poa_current_impl.object_id (), 00177 servant, 00178 cleanup_in_progress); 00179 00180 // We ended up waiting on a condition variable, the 00181 // POA state may have changed while we are waiting. 00182 // Therefore, we need to restart this call. 00183 return 0; 00184 } 00185 00186 // Success 00187 return servant; 00188 }
TAO_SERVANT_LOCATION TAO::Portable_Server::RequestProcessingStrategyServantActivator::locate_servant | ( | const PortableServer::ObjectId & | system_id, | |
PortableServer::Servant & | servant | |||
) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 70 of file RequestProcessingStrategyServantActivator.cpp.
References CORBA::is_nil(), TAO::Portable_Server::RequestProcessingStrategy::poa_, TAO_Root_POA::servant_present(), TAO_SERVANT_MANAGER, and TAO_SERVANT_NOT_FOUND.
00073 { 00074 TAO_SERVANT_LOCATION location = TAO_SERVANT_NOT_FOUND; 00075 00076 location = this->poa_->servant_present (system_id, servant); 00077 00078 if (location == TAO_SERVANT_NOT_FOUND) 00079 { 00080 if (!CORBA::is_nil (this->servant_activator_.in ())) 00081 { 00082 location = TAO_SERVANT_MANAGER; 00083 } 00084 } 00085 00086 return location; 00087 }
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::post_invoke_servant_cleanup | ( | const PortableServer::ObjectId & | system_id, | |
const TAO::Portable_Server::Servant_Upcall & | servant_upcall | |||
) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 305 of file RequestProcessingStrategyServantActivator.cpp.
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::set_servant_manager | ( | PortableServer::ServantManager_ptr | imgr | ) | [virtual] |
Implements TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 50 of file RequestProcessingStrategyServantActivator.cpp.
References CORBA::COMPLETED_NO, CORBA::is_nil(), CORBA::OMGVMCID, servant_activator_, and TAO::Portable_Server::RequestProcessingStrategyServantManager::validate_servant_manager().
00052 { 00053 // This operation sets the default servant manager associated with the 00054 // POA. This operation may only be invoked once after a POA has been 00055 // created. Attempting to set the servant manager after one has already 00056 // been set will result in the BAD_INV_ORDER system exception with 00057 // standard minor code 6 being raised (see 11.3.9.12 of the corba spec) 00058 if (!CORBA::is_nil (this->servant_activator_.in ())) 00059 { 00060 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 6, CORBA::COMPLETED_NO); 00061 } 00062 00063 this->servant_activator_ = 00064 PortableServer::ServantActivator::_narrow (imgr); 00065 00066 this->validate_servant_manager (this->servant_activator_.in ()); 00067 }
void TAO::Portable_Server::RequestProcessingStrategyServantActivator::strategy_cleanup | ( | void | ) | [virtual] |
Reimplemented from TAO::Portable_Server::RequestProcessingStrategy.
Definition at line 31 of file RequestProcessingStrategyServantActivator.cpp.
References servant_activator_, and TAO::Portable_Server::RequestProcessingStrategy::strategy_cleanup().
00032 { 00033 { 00034 Non_Servant_Upcall non_servant_upcall (*this->poa_); 00035 ACE_UNUSED_ARG (non_servant_upcall); 00036 00037 this->servant_activator_ = PortableServer::ServantActivator::_nil (); 00038 } 00039 00040 RequestProcessingStrategy::strategy_cleanup (); 00041 }
CORBA::Boolean TAO::Portable_Server::RequestProcessingStrategyServantActivator::etherealize_objects_ [private] |
Definition at line 78 of file RequestProcessingStrategyServantActivator.h.
Referenced by etherealize_objects().
PortableServer::ServantActivator_var TAO::Portable_Server::RequestProcessingStrategyServantActivator::servant_activator_ [private] |
Definition at line 77 of file RequestProcessingStrategyServantActivator.h.
Referenced by etherealize_servant(), incarnate_servant(), set_servant_manager(), and strategy_cleanup().