#include <EC_ObserverStrategy.h>
Inheritance diagram for TAO_EC_Reactive_ObserverStrategy:
Public Member Functions | |
TAO_EC_Reactive_ObserverStrategy (TAO_EC_Event_Channel_Base *ec, ACE_Lock *lock) | |
Constructor. | |
virtual | ~TAO_EC_Reactive_ObserverStrategy (void) |
Destructor. | |
Protected Member Functions | |
virtual void | consumer_qos_update (TAO_EC_ProxyPushSupplier *supplier) |
Recompute EC consumer subscriptions and send them out to all observers. | |
virtual void | supplier_qos_update (TAO_EC_ProxyPushConsumer *consumer) |
Recompute EC supplier publications and send them out to all observers. | |
int | create_observer_map (Observer_Map &map) |
void | observer_not_exists (Observer_Entry &observer) |
The observer doesn't exist anymore. |
This class simply keeps the information about the current list of observers, whenever the list of consumers and/or suppliers changes in queries the EC, computes the global subscription and/or publication list and sends the update message to all the observers. When an observer isn't reachable it is removed from the observer list.
It assumes ownership of the <lock>, but not of the Event_Channel.
Definition at line 239 of file EC_ObserverStrategy.h.
ACE_INLINE TAO_EC_Reactive_ObserverStrategy::TAO_EC_Reactive_ObserverStrategy | ( | TAO_EC_Event_Channel_Base * | ec, | |
ACE_Lock * | lock | |||
) |
Constructor.
Definition at line 57 of file EC_ObserverStrategy.inl.
00059 : TAO_EC_Basic_ObserverStrategy (ec, lock) 00060 { 00061 }
TAO_EC_Reactive_ObserverStrategy::~TAO_EC_Reactive_ObserverStrategy | ( | void | ) | [virtual] |
void TAO_EC_Reactive_ObserverStrategy::consumer_qos_update | ( | TAO_EC_ProxyPushSupplier * | supplier | ) | [protected, virtual] |
Recompute EC consumer subscriptions and send them out to all observers.
Reimplemented from TAO_EC_Basic_ObserverStrategy.
Definition at line 314 of file EC_ObserverStrategy.cpp.
References create_observer_map(), TAO_EC_Basic_ObserverStrategy::fill_qos(), RtecEventChannelAdmin::ConsumerQOS::is_gateway, observer_not_exists(), and TAO_EC_ProxyPushSupplier::subscriptions().
00316 { 00317 if (supplier->subscriptions ().is_gateway) 00318 return; 00319 00320 RtecEventChannelAdmin::ConsumerQOS c_qos; 00321 this->fill_qos (c_qos); 00322 00323 Observer_Map copy; 00324 this->create_observer_map (copy); 00325 00326 Observer_Map_Iterator end = copy.end (); 00327 for (Observer_Map_Iterator i = copy.begin (); 00328 i != end; 00329 ++i) 00330 { 00331 Observer_Entry& entry = (*i).int_id_; 00332 try 00333 { 00334 entry.observer->update_consumer (c_qos); 00335 } 00336 catch (const CORBA::OBJECT_NOT_EXIST&) 00337 { 00338 // Exception occured while updating observer, so remove it from the 00339 // observer list 00340 this->observer_not_exists (entry); 00341 } 00342 catch (const CORBA::TRANSIENT&) 00343 { 00344 // Exception occured while updating observer, so remove it from the 00345 // observer list 00346 this->observer_not_exists (entry); 00347 } 00348 catch (const CORBA::Exception&) 00349 { 00350 // Ignore all exceptions 00351 } 00352 } 00353 }
int TAO_EC_Reactive_ObserverStrategy::create_observer_map | ( | Observer_Map & | map | ) | [protected] |
Copies all current observers into a map and passes it back to the caller through map.
Definition at line 356 of file EC_ObserverStrategy.cpp.
References ACE_GUARD_THROW_EX, and TAO_EC_Basic_ObserverStrategy::observers_.
Referenced by consumer_qos_update(), and supplier_qos_update().
00357 { 00358 ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_, 00359 RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR()); 00360 00361 Observer_Map_Iterator end = this->observers_.end (); 00362 for (Observer_Map_Iterator i = this->observers_.begin (); 00363 i != end; 00364 ++i) 00365 { 00366 Observer_Entry& entry = (*i).int_id_; 00367 Observer_Entry copy (entry.handle, 00368 RtecEventChannelAdmin::Observer::_duplicate (entry.observer.in ())); 00369 if (map.bind (copy.handle, copy) == -1) 00370 { 00371 map.unbind_all(); 00372 return 0; 00373 } 00374 } 00375 00376 return map.current_size(); 00377 }
void TAO_EC_Reactive_ObserverStrategy::observer_not_exists | ( | Observer_Entry & | observer | ) | [protected] |
The observer doesn't exist anymore.
Definition at line 380 of file EC_ObserverStrategy.cpp.
References TAO_EC_Basic_ObserverStrategy::remove_observer().
Referenced by consumer_qos_update(), and supplier_qos_update().
00381 { 00382 try 00383 { 00384 this->remove_observer(observer.handle); 00385 } 00386 catch (const CORBA::Exception&) 00387 { 00388 // Ignore exceptions 00389 } 00390 }
void TAO_EC_Reactive_ObserverStrategy::supplier_qos_update | ( | TAO_EC_ProxyPushConsumer * | consumer | ) | [protected, virtual] |
Recompute EC supplier publications and send them out to all observers.
Reimplemented from TAO_EC_Basic_ObserverStrategy.
Definition at line 272 of file EC_ObserverStrategy.cpp.
References create_observer_map(), TAO_EC_Basic_ObserverStrategy::fill_qos(), RtecEventChannelAdmin::SupplierQOS::is_gateway, observer_not_exists(), and TAO_EC_ProxyPushConsumer::publications().
00274 { 00275 if (consumer->publications ().is_gateway) 00276 return; 00277 00278 RtecEventChannelAdmin::SupplierQOS s_qos; 00279 this->fill_qos (s_qos); 00280 00281 Observer_Map copy; 00282 this->create_observer_map (copy); 00283 00284 Observer_Map_Iterator end = copy.end (); 00285 for (Observer_Map_Iterator i = copy.begin (); 00286 i != end; 00287 ++i) 00288 { 00289 Observer_Entry& entry = (*i).int_id_; 00290 try 00291 { 00292 entry.observer->update_supplier (s_qos); 00293 } 00294 catch (const CORBA::OBJECT_NOT_EXIST&) 00295 { 00296 // Exception occured while updating observer, so remove it from the 00297 // observer list 00298 this->observer_not_exists (entry); 00299 } 00300 catch (const CORBA::TRANSIENT&) 00301 { 00302 // Exception occured while updating observer, so remove it from the 00303 // observer list 00304 this->observer_not_exists (entry); 00305 } 00306 catch (const CORBA::Exception&) 00307 { 00308 // Ignore all exceptions 00309 } 00310 } 00311 }