#include <CEC_ProxyPushConsumer.h>
Collaboration diagram for TAO_CEC_ProxyPushConsumer:
Public Types | |
typedef CosEventChannelAdmin::ProxyPushConsumer_ptr | _ptr_type |
typedef CosEventChannelAdmin::ProxyPushConsumer_var | _var_type |
Public Member Functions | |
TAO_CEC_ProxyPushConsumer (TAO_CEC_EventChannel *event_channel, const ACE_Time_Value &timeout) | |
constructor... | |
virtual | ~TAO_CEC_ProxyPushConsumer (void) |
destructor... | |
virtual void | activate (CosEventChannelAdmin::ProxyPushConsumer_ptr &activated_proxy) |
Activate in the POA. | |
virtual void | deactivate (void) |
Deactivate from the POA. | |
CORBA::Boolean | is_connected (void) const |
Return false if no supplier is connected... | |
CosEventComm::PushSupplier_ptr | supplier (void) const |
CORBA::Boolean | supplier_non_existent (CORBA::Boolean_out disconnected) |
virtual void | shutdown (void) |
The event channel is shutting down. | |
CORBA::ULong | _incr_refcnt (void) |
Increment and decrement the reference count. | |
CORBA::ULong | _decr_refcnt (void) |
virtual void | connect_push_supplier (CosEventComm::PushSupplier_ptr push_supplier) |
virtual void | push (const CORBA::Any &event) |
virtual void | disconnect_push_consumer (void) |
virtual PortableServer::POA_ptr | _default_POA (void) |
virtual void | _add_ref (void) |
virtual void | _remove_ref (void) |
Protected Member Functions | |
void | supplier (CosEventComm::PushSupplier_ptr supplier) |
void | supplier_i (CosEventComm::PushSupplier_ptr supplier) |
CORBA::Boolean | is_connected_i (void) const |
The private version (without locking) of is_connected(). | |
void | cleanup_i (void) |
Release the supplier. | |
CosEventComm::PushSupplier_ptr | apply_policy (CosEventComm::PushSupplier_ptr s) |
Private Attributes | |
TAO_CEC_EventChannel * | event_channel_ |
The supplier admin, used for activation and memory managment. | |
ACE_Time_Value | timeout_ |
ACE_Lock * | lock_ |
The locking strategy. | |
CORBA::ULong | refcount_ |
The reference count. | |
CosEventComm::PushSupplier_var | supplier_ |
CosEventComm::PushSupplier_var | nopolicy_supplier_ |
The supplier without any policies applied. | |
bool | connected_ |
PortableServer::POA_var | default_POA_ |
Store the default POA. | |
Friends | |
class | TAO_CEC_ProxyPushConsumer_Guard |
Implement the CosEventChannelAdmin::ProxyPushConsumer interface, remember that this class is used to communicate with a PushSupplier, so, in effect, this is the ambassador for a supplier inside the event channel. = MEMORY MANAGMENT The object commits suicide when disconnect_push_consumer() is called.
Definition at line 47 of file CEC_ProxyPushConsumer.h.
typedef CosEventChannelAdmin::ProxyPushConsumer_ptr TAO_CEC_ProxyPushConsumer::_ptr_type |
Definition at line 51 of file CEC_ProxyPushConsumer.h.
typedef CosEventChannelAdmin::ProxyPushConsumer_var TAO_CEC_ProxyPushConsumer::_var_type |
Definition at line 52 of file CEC_ProxyPushConsumer.h.
TAO_CEC_ProxyPushConsumer::TAO_CEC_ProxyPushConsumer | ( | TAO_CEC_EventChannel * | event_channel, | |
const ACE_Time_Value & | timeout | |||
) |
constructor...
Definition at line 23 of file CEC_ProxyPushConsumer.cpp.
00025 : event_channel_ (ec), 00026 timeout_(timeout), 00027 refcount_ (1), 00028 connected_ (false) 00029 { 00030 this->lock_ = 00031 this->event_channel_->create_consumer_lock (); 00032 00033 this->default_POA_ = 00034 this->event_channel_->consumer_poa (); 00035 00036 this->event_channel_->get_servant_retry_map ().bind (this, 0); 00037 }
TAO_CEC_ProxyPushConsumer::~TAO_CEC_ProxyPushConsumer | ( | void | ) | [virtual] |
destructor...
Definition at line 39 of file CEC_ProxyPushConsumer.cpp.
References TAO_CEC_EventChannel::destroy_consumer_lock(), event_channel_, and TAO_CEC_EventChannel::get_servant_retry_map().
00040 { 00041 this->event_channel_->get_servant_retry_map ().unbind (this); 00042 this->event_channel_->destroy_consumer_lock (this->lock_); 00043 }
void TAO_CEC_ProxyPushConsumer::_add_ref | ( | void | ) | [virtual] |
Definition at line 303 of file CEC_ProxyPushConsumer.cpp.
References _incr_refcnt().
00304 { 00305 this->_incr_refcnt (); 00306 }
CORBA::ULong TAO_CEC_ProxyPushConsumer::_decr_refcnt | ( | void | ) |
Definition at line 158 of file CEC_ProxyPushConsumer.cpp.
References ACE_GUARD_RETURN, TAO_CEC_EventChannel::destroy_proxy(), event_channel_, and refcount_.
Referenced by _remove_ref().
00159 { 00160 { 00161 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00162 --this->refcount_; 00163 if (this->refcount_ != 0) 00164 return this->refcount_; 00165 } 00166 00167 // Notify the event channel 00168 this->event_channel_->destroy_proxy (this); 00169 return 0; 00170 }
PortableServer::POA_ptr TAO_CEC_ProxyPushConsumer::_default_POA | ( | void | ) | [virtual] |
CORBA::ULong TAO_CEC_ProxyPushConsumer::_incr_refcnt | ( | void | ) |
Increment and decrement the reference count.
Definition at line 151 of file CEC_ProxyPushConsumer.cpp.
References ACE_GUARD_RETURN, and refcount_.
Referenced by _add_ref().
00152 { 00153 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00154 return this->refcount_++; 00155 }
void TAO_CEC_ProxyPushConsumer::_remove_ref | ( | void | ) | [virtual] |
Definition at line 309 of file CEC_ProxyPushConsumer.cpp.
References _decr_refcnt().
00310 { 00311 this->_decr_refcnt (); 00312 }
void TAO_CEC_ProxyPushConsumer::activate | ( | CosEventChannelAdmin::ProxyPushConsumer_ptr & | activated_proxy | ) | [virtual] |
Activate in the POA.
Definition at line 46 of file CEC_ProxyPushConsumer.cpp.
00048 { 00049 CosEventChannelAdmin::ProxyPushConsumer_var result; 00050 try 00051 { 00052 result = this->_this (); 00053 } 00054 catch (const CORBA::Exception&) 00055 { 00056 result = CosEventChannelAdmin::ProxyPushConsumer::_nil (); 00057 } 00058 activated_proxy = result._retn (); 00059 }
CosEventComm::PushSupplier_ptr TAO_CEC_ProxyPushConsumer::apply_policy | ( | CosEventComm::PushSupplier_ptr | s | ) | [protected] |
Assigns the parameter to both supplier_ and nopolicy_supplier_, and applies policies (when appropriate) to supplier_.
Definition at line 217 of file CEC_ProxyPushConsumer.cpp.
References event_channel_, TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), nopolicy_supplier_, and ACE_Time_Value::zero.
Referenced by connect_push_supplier().
00218 { 00219 if (CORBA::is_nil (pre)) return pre; 00220 this->nopolicy_supplier_ = CosEventComm::PushSupplier::_duplicate (pre); 00221 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00222 CosEventComm::PushSupplier_var post = 00223 CosEventComm::PushSupplier::_duplicate (pre); 00224 if (this->timeout_ > ACE_Time_Value::zero) 00225 { 00226 CORBA::PolicyList policy_list; 00227 policy_list.length (1); 00228 policy_list[0] = this->event_channel_-> 00229 create_roundtrip_timeout_policy (this->timeout_); 00230 00231 CORBA::Object_var post_obj = pre->_set_policy_overrides 00232 (policy_list, CORBA::ADD_OVERRIDE); 00233 post = CosEventComm::PushSupplier::_narrow(post_obj.in ()); 00234 00235 policy_list[0]->destroy (); 00236 policy_list.length (0); 00237 } 00238 return post._retn (); 00239 #else 00240 return CosEventComm::PushSupplier::_duplicate (pre); 00241 #endif /* TAO_HAS_CORBA_MESSAGING */ 00242 }
void TAO_CEC_ProxyPushConsumer::cleanup_i | ( | void | ) | [protected] |
Release the supplier.
Definition at line 143 of file CEC_ProxyPushConsumer.cpp.
References connected_, and supplier_.
Referenced by connect_push_supplier(), and disconnect_push_consumer().
00144 { 00145 this->supplier_ = 00146 CosEventComm::PushSupplier::_nil (); 00147 this->connected_ = false; 00148 }
void TAO_CEC_ProxyPushConsumer::connect_push_supplier | ( | CosEventComm::PushSupplier_ptr | push_supplier | ) | [virtual] |
Definition at line 173 of file CEC_ProxyPushConsumer.cpp.
References ACE_GUARD_THROW_EX, apply_policy(), cleanup_i(), TAO_CEC_EventChannel::connected(), connected_, TAO_CEC_EventChannel::disconnected(), event_channel_, supplier_, and TAO_CEC_Unlock.
00175 { 00176 { 00177 ACE_GUARD_THROW_EX ( 00178 ACE_Lock, ace_mon, *this->lock_, 00179 CORBA::INTERNAL ()); 00180 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00181 00182 if (this->is_connected_i ()) 00183 { 00184 if (this->event_channel_->supplier_reconnect () == 0) 00185 throw CosEventChannelAdmin::AlreadyConnected (); 00186 00187 // Re-connections are allowed, go ahead and disconnect the 00188 // consumer... 00189 this->cleanup_i (); 00190 00191 // @@ Please read the comments in CEC_ProxyPushSupplier about 00192 // possible race conditions in this area... 00193 TAO_CEC_Unlock reverse_lock (*this->lock_); 00194 00195 { 00196 ACE_GUARD_THROW_EX ( 00197 TAO_CEC_Unlock, ace_mon, reverse_lock, 00198 CORBA::INTERNAL ()); 00199 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00200 00201 this->event_channel_->disconnected (this); 00202 } 00203 00204 // What if a second thread connected us after this? 00205 if (this->is_connected_i ()) 00206 return; 00207 } 00208 this->supplier_ = apply_policy (push_supplier); 00209 this->connected_ = true; 00210 } 00211 00212 // Notify the event channel... 00213 this->event_channel_->connected (this); 00214 }
void TAO_CEC_ProxyPushConsumer::deactivate | ( | void | ) | [virtual] |
Deactivate from the POA.
Definition at line 62 of file CEC_ProxyPushConsumer.cpp.
References _default_POA().
Referenced by shutdown().
00063 { 00064 try 00065 { 00066 PortableServer::POA_var poa = 00067 this->_default_POA (); 00068 PortableServer::ObjectId_var id = 00069 poa->servant_to_id (this); 00070 poa->deactivate_object (id.in ()); 00071 } 00072 catch (const CORBA::Exception&) 00073 { 00074 // Exceptions here should not be propagated. They usually 00075 // indicate that an object is beign disconnected twice, or some 00076 // race condition, but not a fault that the user needs to know 00077 // about. 00078 } 00079 }
void TAO_CEC_ProxyPushConsumer::disconnect_push_consumer | ( | void | ) | [virtual] |
Definition at line 258 of file CEC_ProxyPushConsumer.cpp.
References ACE_GUARD_THROW_EX, cleanup_i(), TAO_CEC_EventChannel::disconnected(), event_channel_, CORBA::is_nil(), supplier(), and supplier_.
Referenced by TAO_CEC_Reactive_SupplierControl::supplier_not_exist().
00259 { 00260 CosEventComm::PushSupplier_var supplier; 00261 00262 { 00263 ACE_GUARD_THROW_EX ( 00264 ACE_Lock, ace_mon, *this->lock_, 00265 CORBA::INTERNAL ()); 00266 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00267 00268 if (!this->is_connected_i ()) 00269 throw CORBA::BAD_INV_ORDER (); // @@ add user exception? 00270 00271 supplier = this->supplier_._retn (); 00272 00273 this->cleanup_i (); 00274 } 00275 00276 // Notify the event channel... 00277 this->event_channel_->disconnected (this); 00278 00279 if (CORBA::is_nil (supplier.in ())) 00280 return; 00281 00282 if (this->event_channel_->disconnect_callbacks ()) 00283 { 00284 try 00285 { 00286 supplier->disconnect_push_supplier (); 00287 } 00288 catch (const CORBA::Exception&) 00289 { 00290 // Ignore exceptions, we must isolate other clients from 00291 // failures on this one. 00292 } 00293 } 00294 }
ACE_INLINE CORBA::Boolean TAO_CEC_ProxyPushConsumer::is_connected | ( | void | ) | const |
Return false if no supplier is connected...
Definition at line 14 of file CEC_ProxyPushConsumer.inl.
References ACE_GUARD_RETURN, and is_connected_i().
00015 { 00016 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00017 00018 return this->is_connected_i (); 00019 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::Boolean TAO_CEC_ProxyPushConsumer::is_connected_i | ( | void | ) | const [protected] |
The private version (without locking) of is_connected().
Definition at line 8 of file CEC_ProxyPushConsumer.inl.
References connected_.
Referenced by is_connected(), and TAO_CEC_ProxyPushConsumer_Guard::TAO_CEC_ProxyPushConsumer_Guard().
00009 { 00010 return this->connected_; 00011 }
void TAO_CEC_ProxyPushConsumer::push | ( | const CORBA::Any & | event | ) | [virtual] |
Definition at line 245 of file CEC_ProxyPushConsumer.cpp.
References TAO_CEC_EventChannel::consumer_admin(), event_channel_, TAO_CEC_ProxyPushConsumer_Guard::locked(), and TAO_CEC_ConsumerAdmin::push().
00246 { 00247 TAO_CEC_ProxyPushConsumer_Guard ace_mon (this->lock_, 00248 this->refcount_, 00249 this->event_channel_, 00250 this); 00251 if (!ace_mon.locked ()) 00252 return; 00253 00254 this->event_channel_->consumer_admin ()->push (event); 00255 }
void TAO_CEC_ProxyPushConsumer::shutdown | ( | void | ) | [virtual] |
The event channel is shutting down.
Definition at line 112 of file CEC_ProxyPushConsumer.cpp.
References ACE_GUARD_THROW_EX, connected_, deactivate(), CORBA::is_nil(), supplier(), and supplier_.
00113 { 00114 CosEventComm::PushSupplier_var supplier; 00115 00116 { 00117 ACE_GUARD_THROW_EX ( 00118 ACE_Lock, ace_mon, *this->lock_, 00119 CORBA::INTERNAL ()); 00120 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00121 00122 supplier = this->supplier_._retn (); 00123 this->connected_ = false; 00124 } 00125 00126 this->deactivate (); 00127 00128 if (CORBA::is_nil (supplier.in ())) 00129 return; 00130 00131 try 00132 { 00133 supplier->disconnect_push_supplier (); 00134 } 00135 catch (const CORBA::Exception&) 00136 { 00137 // Ignore exceptions, we must isolate other clients from 00138 // failures on this one. 00139 } 00140 }
ACE_INLINE void TAO_CEC_ProxyPushConsumer::supplier | ( | CosEventComm::PushSupplier_ptr | supplier | ) | [protected] |
Set the supplier, used by some implementations to change the policies used when invoking operations on the supplier.
Definition at line 35 of file CEC_ProxyPushConsumer.inl.
References ACE_GUARD, and supplier_i().
00036 { 00037 ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); 00038 00039 this->supplier_i (supplier); 00040 }
ACE_INLINE CosEventComm::PushSupplier_ptr TAO_CEC_ProxyPushConsumer::supplier | ( | void | ) | const |
Return the consumer object reference. It returns nil() if it has not connected yet.
Definition at line 22 of file CEC_ProxyPushConsumer.inl.
References ACE_GUARD_RETURN.
Referenced by disconnect_push_consumer(), shutdown(), and supplier_non_existent().
00023 { 00024 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00025 return CosEventComm::PushSupplier::_duplicate (this->supplier_.in ()); 00026 }
ACE_INLINE void TAO_CEC_ProxyPushConsumer::supplier_i | ( | CosEventComm::PushSupplier_ptr | supplier | ) | [protected] |
Definition at line 29 of file CEC_ProxyPushConsumer.inl.
References supplier_.
Referenced by supplier().
CORBA::Boolean TAO_CEC_ProxyPushConsumer::supplier_non_existent | ( | CORBA::Boolean_out | disconnected | ) |
Invoke the _non_existent() pseudo-operation on the supplier. If it is disconnected then it returns true and sets the <disconnected> flag.
Definition at line 82 of file CEC_ProxyPushConsumer.cpp.
References CORBA::Object::_duplicate(), ACE_GUARD_THROW_EX, CORBA::is_nil(), and supplier().
Referenced by TAO_CEC_Ping_Push_Supplier::work().
00084 { 00085 CORBA::Object_var supplier; 00086 { 00087 ACE_GUARD_THROW_EX ( 00088 ACE_Lock, ace_mon, *this->lock_, 00089 CORBA::INTERNAL ()); 00090 00091 disconnected = false; 00092 if (!this->is_connected_i ()) 00093 { 00094 disconnected = true; 00095 return false; 00096 } 00097 if (CORBA::is_nil (this->nopolicy_supplier_.in ())) 00098 { 00099 return false; 00100 } 00101 supplier = CORBA::Object::_duplicate (this->nopolicy_supplier_.in ()); 00102 } 00103 00104 #if (TAO_HAS_MINIMUM_CORBA == 0) 00105 return supplier->_non_existent (); 00106 #else 00107 return false; 00108 #endif /* TAO_HAS_MINIMUM_CORBA */ 00109 }
friend class TAO_CEC_ProxyPushConsumer_Guard [friend] |
Definition at line 106 of file CEC_ProxyPushConsumer.h.
bool TAO_CEC_ProxyPushConsumer::connected_ [private] |
If the flag is true then we are connected, notice that the supplier can be nil.
Definition at line 141 of file CEC_ProxyPushConsumer.h.
Referenced by cleanup_i(), connect_push_supplier(), is_connected_i(), and shutdown().
The supplier admin, used for activation and memory managment.
Definition at line 122 of file CEC_ProxyPushConsumer.h.
Referenced by _decr_refcnt(), apply_policy(), connect_push_supplier(), disconnect_push_consumer(), push(), and ~TAO_CEC_ProxyPushConsumer().
ACE_Lock* TAO_CEC_ProxyPushConsumer::lock_ [private] |
CosEventComm::PushSupplier_var TAO_CEC_ProxyPushConsumer::nopolicy_supplier_ [private] |
The supplier without any policies applied.
Definition at line 137 of file CEC_ProxyPushConsumer.h.
Referenced by apply_policy().
The reference count.
Definition at line 130 of file CEC_ProxyPushConsumer.h.
Referenced by _decr_refcnt(), and _incr_refcnt().
CosEventComm::PushSupplier_var TAO_CEC_ProxyPushConsumer::supplier_ [private] |
The supplier -- use apply_policy() instead of assigning directly to supplier_. This will keep supplier_ and nopolicy_supplier_ in sync.
Definition at line 134 of file CEC_ProxyPushConsumer.h.
Referenced by cleanup_i(), connect_push_supplier(), disconnect_push_consumer(), shutdown(), and supplier_i().
Definition at line 124 of file CEC_ProxyPushConsumer.h.