#include <POAManager.h>
Inheritance diagram for TAO_POA_Manager:
Public Member Functions | |
void | activate () throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | hold_requests (CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | discard_requests (CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | deactivate (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
PortableServer::POAManager::State | get_state () throw (CORBA::SystemException) |
char * | get_id () throw (CORBA::SystemException) |
TAO_POA_Manager (TAO_Object_Adapter &object_adapter, const char *id, const::CORBA::PolicyList &policies, PortableServer::POAManagerFactory_ptr poa_manager_factory) | |
~TAO_POA_Manager (void) | |
void | check_state () |
Check the state of this POA manager. | |
PortableServer::POAManager::State | get_state_i () throw (CORBA::SystemException) |
virtual CORBA::ORB_ptr | _get_orb () |
CORBA::PolicyList & | get_policies () |
Protected Types | |
typedef ACE_Unbounded_Set< TAO_Root_POA * > | POA_COLLECTION |
Protected Member Functions | |
void | activate_i () throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | deactivate_i (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | adapter_manager_state_changed (PortableServer::POAManager::State state) throw (CORBA::SystemException) |
void | hold_requests_i (CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
void | discard_requests_i (CORBA::Boolean wait_for_completion) throw (CORBA::SystemException, PortableServer::POAManager::AdapterInactive) |
ACE_Lock & | lock (void) |
int | remove_poa (TAO_Root_POA *poa) |
int | register_poa (TAO_Root_POA *poa) |
Protected Attributes | |
PortableServer::POAManager::State | state_ |
ACE_Lock & | lock_ |
POA_COLLECTION | poa_collection_ |
TAO_Object_Adapter & | object_adapter_ |
CORBA::String_var | id_ |
TAO_POAManager_Factory & | poa_manager_factory_ |
CORBA::PolicyList | policies_ |
Private Member Functions | |
char * | generate_manager_id (void) const |
Friends | |
class | TAO_Root_POA |
class | TAO_Object_Adapter |
|
Definition at line 155 of file POAManager.h. |
|
Definition at line 21 of file POAManager.cpp. References TAO_Local_RefCounted_Object::_add_ref(), and PortableServer::POAManagerFactory_ptr.
00026 : state_ (PortableServer::POAManager::HOLDING), 00027 lock_ (object_adapter.lock ()), 00028 poa_collection_ (), 00029 object_adapter_ (object_adapter), 00030 id_ (id == 0 ? this->generate_manager_id () : CORBA::string_dup (id)), 00031 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00032 poa_manager_factory_ (* dynamic_cast <TAO_POAManager_Factory*> (poa_manager_factory)), 00033 #endif 00034 policies_ (policies) 00035 { 00036 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00037 poa_manager_factory_._add_ref (); 00038 #endif 00039 } |
|
Definition at line 41 of file POAManager.cpp. References TAO_Local_RefCounted_Object::_remove_ref().
00042 { 00043 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00044 poa_manager_factory_._remove_ref (); 00045 #endif 00046 } |
|
Reimplemented from CORBA::LocalObject. Definition at line 408 of file POAManager.cpp. References CORBA::ORB::_duplicate().
00409 { 00410 return CORBA::ORB::_duplicate (this->object_adapter_.orb_core ().orb ()); 00411 } |
|
Implements PortableServer::POAManager. Definition at line 17 of file POAManager.i. References ACE_ENV_SINGLE_ARG_PARAMETER, and TAO_OBJECT_ADAPTER_GUARD.
00020 { 00021 // Lock access to the POAManager for the duration of this transaction 00022 TAO_OBJECT_ADAPTER_GUARD; 00023 00024 this->activate_i (ACE_ENV_SINGLE_ARG_PARAMETER); 00025 } |
|
Definition at line 56 of file POAManager.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and ACE_THROW.
00059 { 00060 // This operation changes the state of the POA manager to active. If 00061 // issued while the POA manager is in the inactive state, the 00062 // AdapterInactive exception is raised. Entering the active state 00063 // enables the associated POAs to process requests. 00064 00065 if (this->state_ == PortableServer::POAManager::INACTIVE) 00066 { 00067 ACE_THROW (PortableServer::POAManager::AdapterInactive ()); 00068 } 00069 else 00070 { 00071 this->state_ = PortableServer::POAManager::ACTIVE; 00072 // Find the poas that applied the custom servant dispatching 00073 // strategy to launch the dispatching threads. 00074 00075 for (POA_COLLECTION::iterator iterator = this->poa_collection_.begin (); 00076 iterator != this->poa_collection_.end (); 00077 ++iterator) 00078 { 00079 (*iterator)->poa_activated_hook (); 00080 } 00081 } 00082 00083 this->adapter_manager_state_changed (this->state_ 00084 ACE_ENV_ARG_PARAMETER); 00085 ACE_CHECK; 00086 } |
|
Method needed for notifying the IORInterceptors that the state of POAManager changed. Definition at line 169 of file POAManager.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and TAO_IORInterceptor_Adapter::adapter_manager_state_changed().
00172 { 00173 PortableInterceptor::AdapterState adapter_state = 00174 static_cast<PortableInterceptor::AdapterState> (state); 00175 00176 TAO_IORInterceptor_Adapter *ior_adapter = 00177 this->object_adapter_.orb_core ().ior_interceptor_adapter (); 00178 00179 if (ior_adapter) 00180 { 00181 ior_adapter->adapter_manager_state_changed (this->id_.in (), 00182 adapter_state 00183 ACE_ENV_ARG_PARAMETER); 00184 ACE_CHECK; 00185 } 00186 } |
|
Check the state of this POA manager.
Definition at line 338 of file POAManager.cpp. References ACE_THROW, TAO_POA_DISCARDING, TAO_POA_HOLDING, and TAO_POA_INACTIVE. Referenced by TAO::Portable_Server::LifespanStrategyTransient::check_state(), and TAO::Portable_Server::LifespanStrategyPersistent::check_state().
00339 { 00340 if (state_ == PortableServer::POAManager::ACTIVE) 00341 { 00342 // When a POA manager is in the active state, the associated 00343 // POAs will receive and start processing requests (assuming 00344 // that appropriate thread resources are available). 00345 return; 00346 } 00347 00348 if (state_ == PortableServer::POAManager::DISCARDING) 00349 { 00350 // When a POA manager is in the discarding state, the associated 00351 // POAs will discard all incoming requests (whose processing has 00352 // not yet begun). When a request is discarded, the TRANSIENT 00353 // system exception, with standard minor code 1, must be 00354 // returned to the client-side to indicate that the request 00355 // should be re-issued. (Of course, an ORB may always reject a 00356 // request for other reasons and raise some other system 00357 // exception.) 00358 ACE_THROW ( 00359 CORBA::TRANSIENT ( 00360 CORBA::SystemException::_tao_minor_code ( 00361 TAO_POA_DISCARDING, 00362 1), 00363 CORBA::COMPLETED_NO)); 00364 } 00365 00366 if (state_ == PortableServer::POAManager::HOLDING) 00367 { 00368 // When a POA manager is in the holding state, the associated 00369 // POAs will queue incoming requests. The number of requests 00370 // that can be queued is an implementation limit. If this limit 00371 // is reached, the POAs may discard requests and return the 00372 // TRANSIENT system exception, with standard minor code 1, to 00373 // the client to indicate that the client should reissue the 00374 // request. (Of course, an ORB may always reject a request for 00375 // other reasons and raise some other system exception.) 00376 00377 // Since there is no queuing in TAO, we immediately raise a 00378 // TRANSIENT exception. 00379 ACE_THROW (CORBA::TRANSIENT ( 00380 CORBA::SystemException::_tao_minor_code ( 00381 TAO_POA_HOLDING, 00382 1), 00383 CORBA::COMPLETED_NO)); 00384 } 00385 00386 if (state_ == PortableServer::POAManager::INACTIVE) 00387 { 00388 // The inactive state is entered when the associated POAs are to 00389 // be shut down. Unlike the discarding state, the inactive state 00390 // is not a temporary state. When a POA manager is in the 00391 // inactive state, the associated POAs will reject new 00392 // requests. The rejection mechanism used is specific to the 00393 // vendor. The GIOP location forwarding mechanism and 00394 // CloseConnection message are examples of mechanisms that could 00395 // be used to indicate the rejection. If the client is 00396 // co-resident in the same process, the ORB could raise the 00397 // OBJ_ADAPTER system exception, with standard minor code 1, to 00398 // indicate that the object implementation is unavailable. 00399 ACE_THROW (CORBA::OBJ_ADAPTER ( 00400 CORBA::SystemException::_tao_minor_code ( 00401 TAO_POA_INACTIVE, 00402 1), 00403 CORBA::COMPLETED_NO)); 00404 } 00405 } |
|
Definition at line 54 of file POAManager.i. References ACE_ENV_ARG_PARAMETER, and TAO_OBJECT_ADAPTER_GUARD.
00059 { 00060 // Lock access to the POAManager for the duration of this transaction 00061 TAO_OBJECT_ADAPTER_GUARD; 00062 00063 this->deactivate_i (etherealize_objects, 00064 wait_for_completion 00065 ACE_ENV_ARG_PARAMETER); 00066 } |
|
Definition at line 89 of file POAManager.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, TAO_Root_POA::check_for_valid_wait_for_completions(), TAO_Root_POA::deactivate_all_objects_i(), and TAO_Root_POA::poa_deactivated_hook().
00094 { 00095 // Is the <wait_for_completion> semantics for this thread correct? 00096 TAO_Root_POA::check_for_valid_wait_for_completions (this->object_adapter_.orb_core (), 00097 wait_for_completion 00098 ACE_ENV_ARG_PARAMETER); 00099 ACE_CHECK; 00100 00101 // This operation changes the state of the POA manager to 00102 // inactive. If issued while the POA manager is in the inactive 00103 // state, the AdapterInactive exception is raised. Entering the 00104 // inactive state causes the associated POAs to reject requests that 00105 // have not begun to be executed as well as any new requests. 00106 00107 if (this->state_ == PortableServer::POAManager::INACTIVE) 00108 { 00109 ACE_THROW (PortableServer::POAManager::AdapterInactive ()); 00110 } 00111 else 00112 { 00113 this->state_ = PortableServer::POAManager::INACTIVE; 00114 } 00115 00116 // After changing the state, if the etherealize_objects parameter is: 00117 // 00118 // a) TRUE - the POA manager will cause all associated POAs that 00119 // have the RETAIN and USE_SERVANT_MANAGER policies to perform the 00120 // etherealize operation on the associated servant manager for all 00121 // active objects. 00122 // 00123 // b) FALSE - the etherealize operation is not called. The purpose 00124 // is to provide developers with a means to shut down POAs in a 00125 // crisis (for example, unrecoverable error) situation. 00126 00127 // If the wait_for_completion parameter is FALSE, this operation 00128 // will return immediately after changing the state. If the 00129 // parameter is TRUE and the current thread is not in an invocation 00130 // context dispatched by some POA belonging to the same ORB as this 00131 // POA, this operation does not return until there are no actively 00132 // executing requests in any of the POAs associated with this POA 00133 // manager (that is, all requests that were started prior to the 00134 // state change have completed) and, in the case of a TRUE 00135 // etherealize_objects, all invocations of etherealize have 00136 // completed for POAs having the RETAIN and USE_SERVANT_MANAGER 00137 // policies. If the parameter is TRUE and the current thread is in 00138 // an invocation context dispatched by some POA belonging to the 00139 // same ORB as this POA the BAD_INV_ORDER exception is raised and 00140 // the state is not changed. 00141 00142 for (POA_COLLECTION::iterator iterator = this->poa_collection_.begin (); 00143 iterator != this->poa_collection_.end (); 00144 ++iterator) 00145 { 00146 TAO_Root_POA *poa = *iterator; 00147 // Notify the poas that applied the custom servant dispatching 00148 // strategy to stop the dispatching threads. 00149 poa->poa_deactivated_hook (); 00150 00151 poa->deactivate_all_objects_i (etherealize_objects, 00152 wait_for_completion 00153 ACE_ENV_ARG_PARAMETER); 00154 ACE_CHECK; 00155 } 00156 00157 // If the ORB::shutdown operation is called, it makes a call on 00158 // deactivate with a TRUE etherealize_objects parameter for each POA 00159 // manager known in the process; the wait_for_completion parameter 00160 // to deactivate will be the same as the similarly named parameter 00161 // of ORB::shutdown. 00162 00163 this->adapter_manager_state_changed (this->state_ 00164 ACE_ENV_ARG_PARAMETER); 00165 ACE_CHECK; 00166 } |
|
Definition at line 42 of file POAManager.i. References ACE_ENV_ARG_PARAMETER, and TAO_OBJECT_ADAPTER_GUARD.
00046 { 00047 // Lock access to the POAManager for the duration of this transaction 00048 TAO_OBJECT_ADAPTER_GUARD; 00049 00050 this->discard_requests_i (wait_for_completion ACE_ENV_ARG_PARAMETER); 00051 } |
|
Definition at line 251 of file POAManager.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, TAO_Root_POA::check_for_valid_wait_for_completions(), and TAO_Root_POA::wait_for_completions().
00255 { 00256 // Is the <wait_for_completion> semantics for this thread correct? 00257 TAO_Root_POA::check_for_valid_wait_for_completions (this->object_adapter_.orb_core (), 00258 wait_for_completion 00259 ACE_ENV_ARG_PARAMETER); 00260 ACE_CHECK; 00261 00262 // This operation changes the state of the POA manager to 00263 // discarding. If issued while the POA manager is in the inactive 00264 // state, the AdapterInactive exception is raised. Entering the 00265 // discarding state causes the associated POAs to discard incoming 00266 // requests. In addition, any requests that have been queued but 00267 // have not started executing are discarded. When a request is 00268 // discarded, a TRANSIENT system exception is returned to the 00269 // client. 00270 00271 if (this->state_ == PortableServer::POAManager::INACTIVE) 00272 { 00273 ACE_THROW (PortableServer::POAManager::AdapterInactive ()); 00274 } 00275 else 00276 { 00277 this->state_ = PortableServer::POAManager::DISCARDING; 00278 } 00279 00280 // If the wait_for_completion parameter is FALSE, this operation 00281 // returns immediately after changing the state. If the 00282 // parameter is TRUE and the current thread is not in an 00283 // invocation context dispatched by some POA belonging to the 00284 // same ORB as this POA, this operation does not return until 00285 // either there are no actively executing requests in any of the 00286 // POAs associated with this POA manager (that is, all requests 00287 // that were started prior to the state change have completed) 00288 // or the state of the POA manager is changed to a state other 00289 // than discarding. If the parameter is TRUE and the current 00290 // thread is in an invocation context dispatched by some POA 00291 // belonging to the same ORB as this POA the BAD_INV_ORDER 00292 // exception is raised and the state is not changed. 00293 00294 if (wait_for_completion) 00295 { 00296 for (POA_COLLECTION::iterator iterator = this->poa_collection_.begin (); 00297 iterator != this->poa_collection_.end (); 00298 ++iterator) 00299 { 00300 TAO_Root_POA *poa = *iterator; 00301 poa->wait_for_completions (wait_for_completion 00302 ACE_ENV_ARG_PARAMETER); 00303 ACE_CHECK; 00304 } 00305 } 00306 00307 this->adapter_manager_state_changed (this->state_ 00308 ACE_ENV_ARG_PARAMETER); 00309 } |
|
Generate an id for this POAManager.
Definition at line 88 of file POAManager.i. References ACE_OS::sprintf().
00089 { 00090 // The AdapterManagerId must be unique across all Adapter Managers 00091 // (e.g. POAManagers) within a given process. To avoid locking 00092 // overhead, the address of the POAManager object is used as the 00093 // AdapterManagerId. This guarantees that the AdapterManagerId is 00094 // unique. 00095 // 00096 // For 64-bit platforms, only the lower 32 bits are used. Hopefully 00097 // that will be enough to ensure uniqueness. 00098 00099 // This is basically the same trick used in 00100 // TAO_GIOP_Invocation::generate_request_id(). However, no right 00101 // shifting of 64 bit addresses is performed since the 00102 // TAO_POA_Manager object is not large enough to allow that trick. 00103 00104 CORBA::Long id = 0; 00105 00106 // Note that we reinterpret_cast to an "unsigned long" instead of 00107 // CORBA::ULong since we need to first cast to an integer large 00108 // enough to hold an address to avoid compile-time warnings on some 00109 // 64-bit platforms. 00110 00111 if (sizeof (this) == 4) // 32 bit address 00112 id = reinterpret_cast <ptrdiff_t> (this); 00113 00114 else if (sizeof (this) == 8) // 64 bit address -- use lower 32 bits 00115 id = reinterpret_cast <ptrdiff_t> (this) & 0xFFFFFFFFu; 00116 00117 // @@ If we ever hit a platform where neither of the above cases are 00118 // satisfied, we're up the creek! 00119 00120 // else 00121 // // Fallback on an atomically incremented variable specific to the 00122 // // ORB, or perhaps specific to the process. 00123 // id = ...GENERATE_ID_ATOMICALLY...; // Fallback 00124 00125 char* buf = new char [25]; 00126 ACE_OS::sprintf (buf, "POAManager%d", id); 00127 return buf; 00128 } |
|
Implements PortableServer::POAManager. Definition at line 49 of file POAManager.cpp. References CORBA::string_dup().
00051 { 00052 return CORBA::string_dup (this->id_.in ()); 00053 } |
|
Definition at line 131 of file POAManager.i.
00132 { 00133 return this->policies_; 00134 } |
|
Implements PortableServer::POAManager. Definition at line 78 of file POAManager.i. References TAO_OBJECT_ADAPTER_GUARD_RETURN.
00080 { 00081 // Lock access to the POAManager for the duration of this transaction 00082 TAO_OBJECT_ADAPTER_GUARD_RETURN (this->state_); 00083 00084 return this->get_state_i (); 00085 } |
|
Definition at line 71 of file POAManager.i. Referenced by TAO::Portable_Server::LifespanStrategyTransient::check_state().
00073 { 00074 return this->state_; 00075 } |
|
Definition at line 30 of file POAManager.i. References ACE_ENV_ARG_PARAMETER, and TAO_OBJECT_ADAPTER_GUARD.
00034 { 00035 // Lock access to the POAManager for the duration of this transaction 00036 TAO_OBJECT_ADAPTER_GUARD; 00037 00038 this->hold_requests_i (wait_for_completion ACE_ENV_ARG_PARAMETER); 00039 } |
|
Definition at line 191 of file POAManager.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, TAO_Root_POA::check_for_valid_wait_for_completions(), and TAO_Root_POA::wait_for_completions().
00195 { 00196 // Is the <wait_for_completion> semantics for this thread correct? 00197 TAO_Root_POA::check_for_valid_wait_for_completions (this->object_adapter_.orb_core (), 00198 wait_for_completion 00199 ACE_ENV_ARG_PARAMETER); 00200 ACE_CHECK; 00201 00202 // This operation changes the state of the POA manager to 00203 // holding. If issued while the POA manager is in the inactive 00204 // state, the AdapterInactive exception is raised. Entering the 00205 // holding state causes the associated POAs to queue incoming 00206 // requests. Any requests that have been queued but have not 00207 // started executing will continue to be queued while in the holding 00208 // state. 00209 00210 if (this->state_ == PortableServer::POAManager::INACTIVE) 00211 { 00212 ACE_THROW (PortableServer::POAManager::AdapterInactive ()); 00213 } 00214 else 00215 { 00216 this->state_ = PortableServer::POAManager::HOLDING; 00217 } 00218 00219 // If the wait_for_completion parameter is FALSE, this operation 00220 // returns immediately after changing the state. If the parameter is 00221 // TRUE and the current thread is not in an invocation context 00222 // dispatched by some POA belonging to the same ORB as this POA, 00223 // this operation does not return until either there are no actively 00224 // executing requests in any of the POAs associated with this POA 00225 // manager (that is, all requests that were started prior to the 00226 // state change have completed) or the state of the POA manager is 00227 // changed to a state other than holding. If the parameter is TRUE 00228 // and the current thread is in an invocation context dispatched by 00229 // some POA belonging to the same ORB as this POA the BAD_INV_ORDER 00230 // exception is raised and the state is not changed. 00231 00232 if (wait_for_completion) 00233 { 00234 for (POA_COLLECTION::iterator iterator = this->poa_collection_.begin (); 00235 iterator != this->poa_collection_.end (); 00236 ++iterator) 00237 { 00238 TAO_Root_POA *poa = *iterator; 00239 poa->wait_for_completions (wait_for_completion 00240 ACE_ENV_ARG_PARAMETER); 00241 ACE_CHECK; 00242 } 00243 } 00244 00245 this->adapter_manager_state_changed (this->state_ 00246 ACE_ENV_ARG_PARAMETER); 00247 ACE_CHECK; 00248 } |
|
Definition at line 11 of file POAManager.i.
00012 { 00013 return this->lock_; 00014 } |
|
Definition at line 332 of file POAManager.cpp. References ACE_Unbounded_Set< T >::insert(), and poa_collection_. Referenced by TAO_Root_POA::TAO_Root_POA().
00333 { 00334 return this->poa_collection_.insert (poa); 00335 } |
|
Definition at line 314 of file POAManager.cpp. References ACE_Unbounded_Set< T >::is_empty(), poa_collection_, ACE_Unbounded_Set< T >::remove(), and TAO_POAManager_Factory::remove_poamanager(). Referenced by TAO_Root_POA::complete_destruction_i(), and TAO_Root_POA::TAO_Root_POA().
00315 { 00316 int const result = this->poa_collection_.remove (poa); 00317 00318 if (result == 0) 00319 { 00320 if (this->poa_collection_.is_empty ()) 00321 { 00322 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00323 this->poa_manager_factory_.remove_poamanager (this); 00324 #endif 00325 } 00326 } 00327 00328 return result; 00329 } |
|
Definition at line 58 of file POAManager.h. |
|
Definition at line 57 of file POAManager.h. |
|
Definition at line 161 of file POAManager.h. |
|
Definition at line 153 of file POAManager.h. |
|
Definition at line 159 of file POAManager.h. |
|
Definition at line 157 of file POAManager.h. Referenced by register_poa(), and remove_poa(). |
|
Definition at line 164 of file POAManager.h. |
|
Definition at line 167 of file POAManager.h. |
|
Definition at line 151 of file POAManager.h. |