#include <CEC_ProxyPullConsumer.h>
Collaboration diagram for TAO_CEC_ProxyPullConsumer:
Public Types | |
typedef CosEventChannelAdmin::ProxyPullConsumer_ptr | _ptr_type |
typedef CosEventChannelAdmin::ProxyPullConsumer_var | _var_type |
Public Member Functions | |
TAO_CEC_ProxyPullConsumer (TAO_CEC_EventChannel *event_channel, const ACE_Time_Value &timeout) | |
constructor... | |
virtual | ~TAO_CEC_ProxyPullConsumer (void) |
destructor... | |
virtual void | activate (CosEventChannelAdmin::ProxyPullConsumer_ptr &activated_proxy) |
Activate in the POA. | |
virtual void | deactivate (void) |
Deactivate from the POA. | |
CORBA::Boolean | is_connected (void) const |
Return 0 if no supplier is connected... | |
CosEventComm::PullSupplier_ptr | supplier (void) const |
CORBA::Any * | try_pull_from_supplier (CORBA::Boolean_out has_event) |
Pulls from the supplier, verifies that it is connected. | |
CORBA::Any * | pull_from_supplier (void) |
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_pull_supplier (CosEventComm::PullSupplier_ptr pull_supplier) |
virtual void | disconnect_pull_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::PullSupplier_ptr supplier) |
void | supplier_i (CosEventComm::PullSupplier_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::PullSupplier_ptr | apply_policy (CosEventComm::PullSupplier_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::PullSupplier_var | supplier_ |
CosEventComm::PullSupplier_var | nopolicy_supplier_ |
The supplier without any policies applied. | |
PortableServer::POA_var | default_POA_ |
Store the default POA. |
Implement the CosEventChannelAdmin::ProxyPullConsumer interface, remember that this class is used to communicate with a PullSupplier, so, in effect, this is the ambassador for a supplier inside the event channel. = MEMORY MANAGMENT The object commits suicide when disconnect_pull_consumer() is called.
Definition at line 46 of file CEC_ProxyPullConsumer.h.
|
Definition at line 49 of file CEC_ProxyPullConsumer.h. |
|
Definition at line 50 of file CEC_ProxyPullConsumer.h. |
|
constructor...
Definition at line 24 of file CEC_ProxyPullConsumer.cpp. References TAO_CEC_EventChannel::consumer_poa(), TAO_CEC_EventChannel::create_consumer_lock(), and TAO_CEC_EventChannel::get_servant_retry_map().
00026 : event_channel_ (ec), 00027 timeout_ (timeout), 00028 refcount_ (1) 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 } |
|
destructor...
Definition at line 39 of file CEC_ProxyPullConsumer.cpp. References TAO_CEC_EventChannel::destroy_consumer_lock(), 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 } |
|
Definition at line 374 of file CEC_ProxyPullConsumer.cpp. References _incr_refcnt().
00375 { 00376 this->_incr_refcnt (); 00377 } |
|
Definition at line 243 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_RETURN, and TAO_CEC_EventChannel::destroy_proxy(). Referenced by _remove_ref().
00244 { 00245 { 00246 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00247 this->refcount_--; 00248 if (this->refcount_ != 0) 00249 return this->refcount_; 00250 } 00251 00252 // Notify the event channel 00253 this->event_channel_->destroy_proxy (this); 00254 return 0; 00255 } |
|
Definition at line 368 of file CEC_ProxyPullConsumer.cpp. Referenced by deactivate().
00369 {
00370 return PortableServer::POA::_duplicate (this->default_POA_.in ());
00371 }
|
|
Increment and decrement the reference count.
Definition at line 236 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_RETURN. Referenced by _add_ref().
00237 { 00238 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00239 return this->refcount_++; 00240 } |
|
Definition at line 380 of file CEC_ProxyPullConsumer.cpp. References _decr_refcnt().
00381 { 00382 this->_decr_refcnt (); 00383 } |
|
Activate in the POA.
Definition at line 46 of file CEC_ProxyPullConsumer.cpp.
00048 { 00049 CosEventChannelAdmin::ProxyPullConsumer_var result; 00050 try 00051 { 00052 result = this->_this (); 00053 } 00054 catch (const CORBA::Exception&) 00055 { 00056 result = CosEventChannelAdmin::ProxyPullConsumer::_nil (); 00057 } 00058 activated_proxy = result._retn (); 00059 } |
|
Assigns the parameter to both supplier_ and nopolicy_supplier_, and applies policies (when appropriate) to supplier_. Definition at line 305 of file CEC_ProxyPullConsumer.cpp. References nopolicy_supplier_. Referenced by connect_pull_supplier().
00306 { 00307 this->nopolicy_supplier_ = CosEventComm::PullSupplier::_duplicate (pre); 00308 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00309 CosEventComm::PullSupplier_var post = 00310 CosEventComm::PullSupplier::_duplicate (pre); 00311 if (this->timeout_ > ACE_Time_Value::zero) 00312 { 00313 CORBA::PolicyList policy_list; 00314 policy_list.length (1); 00315 policy_list[0] = this->event_channel_-> 00316 create_roundtrip_timeout_policy (this->timeout_); 00317 00318 CORBA::Object_var post_obj = pre->_set_policy_overrides 00319 (policy_list, CORBA::ADD_OVERRIDE); 00320 post = CosEventComm::PullSupplier::_narrow (post_obj.in ()); 00321 00322 policy_list[0]->destroy (); 00323 policy_list.length (0); 00324 } 00325 return post._retn (); 00326 #else 00327 return CosEventComm::PullSupplier::_duplicate (pre); 00328 #endif /* TAO_HAS_CORBA_MESSAGING */ 00329 } |
|
Release the supplier.
Definition at line 229 of file CEC_ProxyPullConsumer.cpp. References supplier_. Referenced by connect_pull_supplier(), and disconnect_pull_consumer().
00230 { 00231 this->supplier_ = 00232 CosEventComm::PullSupplier::_nil (); 00233 } |
|
Definition at line 258 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_THROW_EX, apply_policy(), cleanup_i(), TAO_CEC_EventChannel::connected(), TAO_CEC_EventChannel::disconnected(), is_connected_i(), CORBA::is_nil(), supplier_, TAO_CEC_EventChannel::supplier_reconnect(), and TAO_CEC_Unlock.
00260 { 00261 // Nil PullSuppliers are illegal 00262 if (CORBA::is_nil (pull_supplier)) 00263 throw CORBA::BAD_PARAM (); 00264 00265 { 00266 ACE_GUARD_THROW_EX ( 00267 ACE_Lock, ace_mon, *this->lock_, 00268 CORBA::INTERNAL ()); 00269 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00270 00271 if (this->is_connected_i ()) 00272 { 00273 if (this->event_channel_->supplier_reconnect () == 0) 00274 throw CosEventChannelAdmin::AlreadyConnected (); 00275 00276 // Re-connections are allowed, go ahead and disconnect the 00277 // consumer... 00278 this->cleanup_i (); 00279 00280 // @@ Please read the comments in CEC_ProxyPullSupplier about 00281 // possible race conditions in this area... 00282 TAO_CEC_Unlock reverse_lock (*this->lock_); 00283 00284 { 00285 ACE_GUARD_THROW_EX ( 00286 TAO_CEC_Unlock, ace_mon, reverse_lock, 00287 CORBA::INTERNAL ()); 00288 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00289 00290 this->event_channel_->disconnected (this); 00291 } 00292 00293 // What if a second thread connected us after this? 00294 if (this->is_connected_i ()) 00295 return; 00296 } 00297 this->supplier_ = apply_policy (pull_supplier); 00298 } 00299 00300 // Notify the event channel... 00301 this->event_channel_->connected (this); 00302 } |
|
Deactivate from the POA.
Definition at line 62 of file CEC_ProxyPullConsumer.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 } |
|
Definition at line 332 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_THROW_EX, cleanup_i(), TAO_CEC_EventChannel::disconnect_callbacks(), TAO_CEC_EventChannel::disconnected(), is_connected_i(), supplier(), and supplier_. Referenced by TAO_CEC_Reactive_SupplierControl::supplier_not_exist(), and TAO_CEC_Reactive_SupplierControl::system_exception().
00333 { 00334 CosEventComm::PullSupplier_var supplier; 00335 00336 { 00337 ACE_GUARD_THROW_EX ( 00338 ACE_Lock, ace_mon, *this->lock_, 00339 CORBA::INTERNAL ()); 00340 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00341 00342 if (this->is_connected_i () == 0) 00343 throw CORBA::BAD_INV_ORDER (); // @@ add user exception? 00344 00345 supplier = this->supplier_._retn (); 00346 00347 this->cleanup_i (); 00348 } 00349 00350 // Notify the event channel... 00351 this->event_channel_->disconnected (this); 00352 00353 if (this->event_channel_->disconnect_callbacks ()) 00354 { 00355 try 00356 { 00357 supplier->disconnect_pull_supplier (); 00358 } 00359 catch (const CORBA::Exception&) 00360 { 00361 // Ignore exceptions, we must isolate other clients from 00362 // failures on this one. 00363 } 00364 } 00365 } |
|
Return 0 if no supplier is connected...
Definition at line 14 of file CEC_ProxyPullConsumer.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 } |
|
The private version (without locking) of is_connected().
Definition at line 8 of file CEC_ProxyPullConsumer.inl. References CORBA::is_nil(). Referenced by connect_pull_supplier(), disconnect_pull_consumer(), is_connected(), pull_from_supplier(), supplier_non_existent(), and try_pull_from_supplier().
00009 { 00010 return !CORBA::is_nil (this->supplier_.in ()); 00011 } |
|
Definition at line 136 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_THROW_EX, is_connected_i(), and supplier().
00137 { 00138 CosEventComm::PullSupplier_var supplier; 00139 { 00140 ACE_GUARD_THROW_EX ( 00141 ACE_Lock, ace_mon, *this->lock_, 00142 CORBA::INTERNAL ()); 00143 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00144 00145 if (this->is_connected_i () == 0) 00146 return 0; // ACE_THROW (CosEventComm::Disconnected ());???? 00147 00148 supplier = 00149 CosEventComm::PullSupplier::_duplicate (this->supplier_.in ()); 00150 00151 // The refcount cannot be zero, because we have at least two 00152 // references, 00153 } 00154 00155 CORBA::Any_var any; 00156 try 00157 { 00158 any = supplier->pull (); 00159 } 00160 catch (const CORBA::Exception&) 00161 { 00162 // @@ This is where the policies for misbehaving suppliers 00163 // should kick in.... for the moment just ignore them. 00164 } 00165 return any._retn (); 00166 } |
|
The event channel is shutting down.
Definition at line 199 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_THROW_EX, deactivate(), CORBA::is_nil(), supplier(), and supplier_.
00200 { 00201 CosEventComm::PullSupplier_var supplier; 00202 00203 { 00204 ACE_GUARD_THROW_EX ( 00205 ACE_Lock, ace_mon, *this->lock_, 00206 CORBA::INTERNAL ()); 00207 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00208 00209 supplier = this->supplier_._retn (); 00210 } 00211 00212 this->deactivate (); 00213 00214 if (CORBA::is_nil (supplier.in ())) 00215 return; 00216 00217 try 00218 { 00219 supplier->disconnect_pull_supplier (); 00220 } 00221 catch (const CORBA::Exception&) 00222 { 00223 // Ignore exceptions, we must isolate other clients from 00224 // failures on this one. 00225 } 00226 } |
|
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_ProxyPullConsumer.inl. References ACE_GUARD, and supplier_i().
00036 { 00037 ACE_GUARD (ACE_Lock, ace_mon, *this->lock_); 00038 00039 this->supplier_i (supplier); 00040 } |
|
Return the consumer object reference. It returns nil() if it has not connected yet. Definition at line 22 of file CEC_ProxyPullConsumer.inl. References ACE_GUARD_RETURN. Referenced by disconnect_pull_consumer(), pull_from_supplier(), shutdown(), supplier_non_existent(), and try_pull_from_supplier().
00023 { 00024 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); 00025 return CosEventComm::PullSupplier::_duplicate (this->supplier_.in ()); 00026 } |
|
Definition at line 29 of file CEC_ProxyPullConsumer.inl. References supplier_. Referenced by supplier().
00030 { 00031 this->supplier_ = supplier; 00032 } |
|
Invoke the _non_existent() pseudo-operation on the supplier. If it is disconnected then it returns true and sets the flag. Definition at line 169 of file CEC_ProxyPullConsumer.cpp. References CORBA::Object::_duplicate(), ACE_GUARD_THROW_EX, is_connected_i(), CORBA::is_nil(), and supplier(). Referenced by TAO_CEC_Ping_Pull_Supplier::work().
00171 { 00172 CORBA::Object_var supplier; 00173 { 00174 ACE_GUARD_THROW_EX ( 00175 ACE_Lock, ace_mon, *this->lock_, 00176 CORBA::INTERNAL ()); 00177 00178 disconnected = 0; 00179 if (this->is_connected_i () == 0) 00180 { 00181 disconnected = 1; 00182 return 0; 00183 } 00184 if (CORBA::is_nil (this->nopolicy_supplier_.in ())) 00185 { 00186 return 0; 00187 } 00188 supplier = CORBA::Object::_duplicate (this->nopolicy_supplier_.in ()); 00189 } 00190 00191 #if (TAO_HAS_MINIMUM_CORBA == 0) 00192 return supplier->_non_existent (); 00193 #else 00194 return 0; 00195 #endif /* TAO_HAS_MINIMUM_CORBA */ 00196 } |
|
Pulls from the supplier, verifies that it is connected.
Definition at line 87 of file CEC_ProxyPullConsumer.cpp. References ACE_GUARD_THROW_EX, is_connected_i(), TAO_CEC_SupplierControl::successful_transmission(), supplier(), TAO_CEC_EventChannel::supplier_control(), TAO_CEC_SupplierControl::supplier_not_exist(), and TAO_CEC_SupplierControl::system_exception(). Referenced by TAO_CEC_Pull_Event::work().
00089 { 00090 has_event = 0; 00091 CosEventComm::PullSupplier_var supplier; 00092 { 00093 ACE_GUARD_THROW_EX ( 00094 ACE_Lock, ace_mon, *this->lock_, 00095 CORBA::INTERNAL ()); 00096 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); 00097 00098 if (this->is_connected_i () == 0) 00099 return 0; // ACE_THROW (CosEventComm::Disconnected ());???? 00100 00101 supplier = 00102 CosEventComm::PullSupplier::_duplicate (this->supplier_.in ()); 00103 00104 // The refcount cannot be zero, because we have at least two 00105 // references, 00106 } 00107 00108 CORBA::Any_var any; 00109 TAO_CEC_SupplierControl *control = 00110 this->event_channel_->supplier_control (); 00111 00112 try 00113 { 00114 any = supplier->try_pull (has_event); 00115 00116 // Inform the control that we got something from the supplier 00117 control->successful_transmission(this); 00118 } 00119 catch (const CORBA::OBJECT_NOT_EXIST&) 00120 { 00121 control->supplier_not_exist (this); 00122 } 00123 catch (CORBA::SystemException& sysex) 00124 { 00125 control->system_exception (this, 00126 sysex); 00127 } 00128 catch (const CORBA::Exception&) 00129 { 00130 // @@ Should not happen 00131 } 00132 return any._retn (); 00133 } |
|
Store the default POA.
Definition at line 138 of file CEC_ProxyPullConsumer.h. |
|
The supplier admin, used for activation and memory managment.
Definition at line 120 of file CEC_ProxyPullConsumer.h. |
|
The locking strategy.
Definition at line 125 of file CEC_ProxyPullConsumer.h. |
|
The supplier without any policies applied.
Definition at line 135 of file CEC_ProxyPullConsumer.h. Referenced by apply_policy(). |
|
The reference count.
Definition at line 128 of file CEC_ProxyPullConsumer.h. |
|
The supplier -- use apply_policy() instead of assigning directly to supplier_. This will keep supplier_ and nopolicy_supplier_ in sync. Definition at line 132 of file CEC_ProxyPullConsumer.h. Referenced by cleanup_i(), connect_pull_supplier(), disconnect_pull_consumer(), shutdown(), and supplier_i(). |
|
Definition at line 122 of file CEC_ProxyPullConsumer.h. |