TAO_CEC_TypedProxyPushConsumer Class Reference

#include <CEC_TypedProxyPushConsumer.h>

Collaboration diagram for TAO_CEC_TypedProxyPushConsumer:

Collaboration graph
[legend]
List of all members.

Public Types

typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr _ptr_type
typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_var _var_type

Public Member Functions

 TAO_CEC_TypedProxyPushConsumer (TAO_CEC_TypedEventChannel *typed_event_channel, const ACE_Time_Value &timeout)
virtual ~TAO_CEC_TypedProxyPushConsumer (void)
virtual void activate (CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr &activated_proxy)
 Activate in the POA.
virtual void deactivate (void)
 Deactivate from the POA.
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 invoke (const TAO_CEC_TypedEvent &typed_event)
virtual void disconnect_push_consumer (void)
virtual CORBA::Object_ptr get_typed_consumer ()
virtual PortableServer::POA_ptr _default_POA (void)
virtual void _add_ref (void)
virtual void _remove_ref (void)

Protected Member Functions

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 pre)

Private Attributes

TAO_CEC_TypedEventChanneltyped_event_channel_
 The typed supplier admin, used for activation and memory managment.
ACE_Time_Value timeout_
ACE_Locklock_
 The locking strategy.
CORBA::ULong refcount_
 The reference count.
CosEventComm::PushSupplier_var typed_supplier_
CosEventComm::PushSupplier_var nopolicy_typed_supplier_
 The typed supplier without any policies applied.
TAO_CEC_DynamicImplementationServerdsi_impl_
 The DSI impl.
PortableServer::ObjectId_var oid_
 The DSI Portable Server OID.
int connected_
PortableServer::POA_var default_POA_
 Store the default POA.

Friends

class TAO_CEC_TypedProxyPushConsumer_Guard

Detailed Description

Definition at line 36 of file CEC_TypedProxyPushConsumer.h.


Member Typedef Documentation

typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr TAO_CEC_TypedProxyPushConsumer::_ptr_type

Definition at line 40 of file CEC_TypedProxyPushConsumer.h.

typedef CosTypedEventChannelAdmin::TypedProxyPushConsumer_var TAO_CEC_TypedProxyPushConsumer::_var_type

Definition at line 41 of file CEC_TypedProxyPushConsumer.h.


Constructor & Destructor Documentation

TAO_CEC_TypedProxyPushConsumer::TAO_CEC_TypedProxyPushConsumer ( TAO_CEC_TypedEventChannel typed_event_channel,
const ACE_Time_Value timeout 
)

Definition at line 23 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_DEBUG, ACE_TEXT(), LM_DEBUG, and TAO_debug_level.

00024   : typed_event_channel_ (ec),
00025     timeout_ (timeout),
00026     refcount_ (1),
00027     connected_ (0)
00028 {
00029   this->lock_ =
00030     this->typed_event_channel_->create_consumer_lock ();
00031 
00032   this->default_POA_ =
00033     this->typed_event_channel_->typed_consumer_poa ();
00034 
00035   this->typed_event_channel_->get_servant_retry_map ().bind (this, 0);
00036 
00037   // DSI initialization
00038   if (TAO_debug_level >= 10)
00039     {
00040       ACE_DEBUG ((LM_DEBUG,
00041                   ACE_TEXT ("***** Initializing the DSI for the new TypedProxyPushConsumer *****\n")));
00042     }
00043 
00044   this->dsi_impl_ = new
00045     TAO_CEC_DynamicImplementationServer (this->default_POA_.in(),
00046                                          this,
00047                                          this->typed_event_channel_);
00048 
00049   try{
00050     // tempporary fix, should put this into some init function.
00051 
00052     this->oid_ =
00053       this->default_POA_->activate_object (this->dsi_impl_);
00054   }
00055   catch (...){
00056   }
00057 }

TAO_CEC_TypedProxyPushConsumer::~TAO_CEC_TypedProxyPushConsumer ( void   )  [virtual]

Definition at line 60 of file CEC_TypedProxyPushConsumer.cpp.

References default_POA_, TAO_CEC_TypedEventChannel::destroy_consumer_lock(), dsi_impl_, TAO_CEC_TypedEventChannel::get_servant_retry_map(), and typed_event_channel_.

00061 {
00062   try{
00063     this->default_POA_->deactivate_object (this->oid_.in ());
00064   }
00065   catch (...){
00066   }
00067 
00068   delete dsi_impl_;
00069 
00070   this->typed_event_channel_->get_servant_retry_map ().unbind (this);
00071   this->typed_event_channel_->destroy_consumer_lock (this->lock_);
00072 }


Member Function Documentation

void TAO_CEC_TypedProxyPushConsumer::_add_ref ( void   )  [virtual]

Definition at line 324 of file CEC_TypedProxyPushConsumer.cpp.

References _incr_refcnt().

00325 {
00326   this->_incr_refcnt ();
00327 }

CORBA::ULong TAO_CEC_TypedProxyPushConsumer::_decr_refcnt ( void   ) 

Definition at line 188 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_GUARD_RETURN, TAO_CEC_TypedEventChannel::destroy_proxy(), refcount_, and typed_event_channel_.

Referenced by _remove_ref().

00189 {
00190   {
00191     ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
00192     this->refcount_--;
00193     if (this->refcount_ != 0)
00194       return this->refcount_;
00195   }
00196 
00197   // Notify the event channel
00198   this->typed_event_channel_->destroy_proxy (this);
00199   return 0;
00200 }

PortableServer::POA_ptr TAO_CEC_TypedProxyPushConsumer::_default_POA ( void   )  [virtual]

Definition at line 318 of file CEC_TypedProxyPushConsumer.cpp.

Referenced by deactivate().

00319 {
00320   return PortableServer::POA::_duplicate (this->default_POA_.in ());
00321 }

CORBA::ULong TAO_CEC_TypedProxyPushConsumer::_incr_refcnt ( void   ) 

Increment and decrement the reference count.

Definition at line 181 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_GUARD_RETURN, and refcount_.

Referenced by _add_ref().

00182 {
00183   ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
00184   return this->refcount_++;
00185 }

void TAO_CEC_TypedProxyPushConsumer::_remove_ref ( void   )  [virtual]

Definition at line 330 of file CEC_TypedProxyPushConsumer.cpp.

References _decr_refcnt().

00331 {
00332   this->_decr_refcnt ();
00333 }

void TAO_CEC_TypedProxyPushConsumer::activate ( CosTypedEventChannelAdmin::TypedProxyPushConsumer_ptr &  activated_proxy  )  [virtual]

Activate in the POA.

Definition at line 75 of file CEC_TypedProxyPushConsumer.cpp.

00077 {
00078   CosTypedEventChannelAdmin::TypedProxyPushConsumer_var result;
00079   try
00080     {
00081       result = this->_this ();
00082     }
00083   catch (const CORBA::Exception&)
00084     {
00085       result = CosTypedEventChannelAdmin::TypedProxyPushConsumer::_nil ();
00086     }
00087   activated_proxy = result._retn ();
00088 }

CosEventComm::PushSupplier_ptr TAO_CEC_TypedProxyPushConsumer::apply_policy ( CosEventComm::PushSupplier_ptr  pre  )  [protected]

Assigns the parameter to both supplier_ and nopolicy_supplier_, and applies policies (when appropriate) to supplier_.

Definition at line 248 of file CEC_TypedProxyPushConsumer.cpp.

References TAO_CEC_TypedEventChannel::create_roundtrip_timeout_policy(), TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), and ACE_Time_Value::zero.

Referenced by connect_push_supplier().

00249 {
00250   if (CORBA::is_nil(pre)) return pre;
00251   this->nopolicy_typed_supplier_ =
00252     CosEventComm::PushSupplier::_duplicate (pre);
00253   CosEventComm::PushSupplier_var post =
00254     CosEventComm::PushSupplier::_duplicate (pre);
00255   if (this->timeout_ > ACE_Time_Value::zero)
00256     {
00257       CORBA::PolicyList policy_list;
00258       policy_list.length (1);
00259       policy_list[0] = this->typed_event_channel_->
00260         create_roundtrip_timeout_policy (this->timeout_);
00261 
00262       CORBA::Object_var post_obj = pre->_set_policy_overrides
00263         (policy_list, CORBA::ADD_OVERRIDE);
00264       post = CosEventComm::PushSupplier::_narrow(post_obj.in ());
00265 
00266       policy_list[0]->destroy ();
00267       policy_list.length (0);
00268     }
00269   return post._retn ();
00270 }

void TAO_CEC_TypedProxyPushConsumer::cleanup_i ( void   )  [protected]

Release the supplier.

Definition at line 173 of file CEC_TypedProxyPushConsumer.cpp.

References connected_, and typed_supplier_.

Referenced by connect_push_supplier(), and disconnect_push_consumer().

00174 {
00175   this->typed_supplier_ =
00176     CosEventComm::PushSupplier::_nil ();
00177   this->connected_ = 0;
00178 }

void TAO_CEC_TypedProxyPushConsumer::connect_push_supplier ( CosEventComm::PushSupplier_ptr  push_supplier  )  [virtual]

Definition at line 203 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_GUARD_THROW_EX, apply_policy(), cleanup_i(), TAO_CEC_TypedEventChannel::connected(), connected_, TAO_CEC_TypedEventChannel::disconnected(), TAO_CEC_Unlock, typed_event_channel_, and typed_supplier_.

00205 {
00206   {
00207     ACE_GUARD_THROW_EX (
00208         ACE_Lock, ace_mon, *this->lock_,
00209         CORBA::INTERNAL ());
00210     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00211 
00212     if (this->is_connected_i ())
00213       {
00214         if (this->typed_event_channel_->supplier_reconnect () == 0)
00215           throw CosEventChannelAdmin::AlreadyConnected ();
00216 
00217         // Re-connections are allowed, go ahead and disconnect the
00218         // consumer...
00219         this->cleanup_i ();
00220 
00221         // @@ Please read the comments in CEC_ProxyPushSupplier about
00222         //     possible race conditions in this area...
00223         TAO_CEC_Unlock reverse_lock (*this->lock_);
00224 
00225         {
00226           ACE_GUARD_THROW_EX (
00227               TAO_CEC_Unlock, ace_mon, reverse_lock,
00228               CORBA::INTERNAL ());
00229           // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00230 
00231           this->typed_event_channel_->disconnected (this);
00232         }
00233 
00234         // What if a second thread connected us after this?
00235         if (this->is_connected_i ())
00236           return;
00237       }
00238     this->typed_supplier_ = apply_policy (push_supplier);
00239     this->connected_ = 1;
00240   }
00241 
00242   // Notify the event channel...
00243   this->typed_event_channel_->connected (this);
00244 }

void TAO_CEC_TypedProxyPushConsumer::deactivate ( void   )  [virtual]

Deactivate from the POA.

Definition at line 91 of file CEC_TypedProxyPushConsumer.cpp.

References _default_POA().

Referenced by shutdown().

00092 {
00093   try
00094     {
00095       PortableServer::POA_var poa =
00096         this->_default_POA ();
00097       PortableServer::ObjectId_var id =
00098         poa->servant_to_id (this);
00099       poa->deactivate_object (id.in ());
00100     }
00101   catch (const CORBA::Exception&)
00102     {
00103       // Exceptions here should not be propagated.  They usually
00104       // indicate that an object is beign disconnected twice, or some
00105       // race condition, but not a fault that the user needs to know
00106       // about.
00107     }
00108 }

void TAO_CEC_TypedProxyPushConsumer::disconnect_push_consumer ( void   )  [virtual]

Definition at line 279 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_GUARD_THROW_EX, cleanup_i(), TAO_CEC_TypedEventChannel::disconnected(), CORBA::is_nil(), typed_event_channel_, and typed_supplier_.

00280 {
00281   CosEventComm::PushSupplier_var supplier;
00282 
00283   {
00284     ACE_GUARD_THROW_EX (
00285         ACE_Lock, ace_mon, *this->lock_,
00286         CORBA::INTERNAL ());
00287     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00288 
00289     if (this->is_connected_i () == 0)
00290       throw CORBA::BAD_INV_ORDER (); // @@ add user exception?
00291 
00292     supplier = this->typed_supplier_._retn ();
00293 
00294     this->cleanup_i ();
00295   }
00296 
00297   // Notify the event channel...
00298   this->typed_event_channel_->disconnected (this);
00299 
00300   if (!CORBA::is_nil (supplier.in ()))
00301     {
00302       if (this->typed_event_channel_->disconnect_callbacks ())
00303         {
00304           try
00305             {
00306               supplier->disconnect_push_supplier ();
00307             }
00308           catch (const CORBA::Exception&)
00309             {
00310               // Ignore exceptions, we must isolate other clients from
00311               // failures on this one.
00312             }
00313         }
00314     }
00315 }

CORBA::Object_ptr TAO_CEC_TypedProxyPushConsumer::get_typed_consumer (  )  [virtual]

Definition at line 336 of file CEC_TypedProxyPushConsumer.cpp.

References CORBA::Object::_duplicate(), default_POA_, and TAO_Pseudo_Var_T< T >::in().

00338 {
00339   CORBA::Object_var server =
00340          default_POA_->id_to_reference (this->oid_.in ());
00341 
00342   return CORBA::Object::_duplicate (server.in());
00343 }

void TAO_CEC_TypedProxyPushConsumer::invoke ( const TAO_CEC_TypedEvent typed_event  )  [virtual]

Definition at line 346 of file CEC_TypedProxyPushConsumer.cpp.

References TAO_CEC_TypedConsumerAdmin::invoke(), TAO_CEC_TypedProxyPushConsumer_Guard::locked(), TAO_CEC_TypedEventChannel::typed_consumer_admin(), and typed_event_channel_.

Referenced by TAO_CEC_DynamicImplementationServer::invoke().

00347 {
00348   TAO_CEC_TypedProxyPushConsumer_Guard ace_mon (this->lock_,
00349                                                 this->refcount_,
00350                                                 this->typed_event_channel_,
00351                                                 this);
00352   if (!ace_mon.locked ())
00353     return;
00354 
00355   this->typed_event_channel_->typed_consumer_admin ()->invoke (typed_event);
00356 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::Boolean TAO_CEC_TypedProxyPushConsumer::is_connected_i ( void   )  const [protected]

The private version (without locking) of is_connected().

Definition at line 8 of file CEC_TypedProxyPushConsumer.inl.

References connected_.

Referenced by TAO_CEC_TypedProxyPushConsumer_Guard::TAO_CEC_TypedProxyPushConsumer_Guard().

00009 {
00010   return this->connected_;
00011 }

void TAO_CEC_TypedProxyPushConsumer::push ( const CORBA::Any &  event  )  [virtual]

Definition at line 273 of file CEC_TypedProxyPushConsumer.cpp.

00274 {
00275   throw CORBA::NO_IMPLEMENT ();
00276 }

void TAO_CEC_TypedProxyPushConsumer::shutdown ( void   )  [virtual]

The event channel is shutting down.

Definition at line 142 of file CEC_TypedProxyPushConsumer.cpp.

References ACE_GUARD_THROW_EX, connected_, deactivate(), CORBA::is_nil(), and typed_supplier_.

00143 {
00144   CosEventComm::PushSupplier_var supplier;
00145 
00146   {
00147     ACE_GUARD_THROW_EX (
00148         ACE_Lock, ace_mon, *this->lock_,
00149         CORBA::INTERNAL ());
00150     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00151 
00152     supplier = this->typed_supplier_._retn ();
00153     this->connected_ = 0;
00154   }
00155 
00156   this->deactivate ();
00157 
00158   if (CORBA::is_nil (supplier.in ()))
00159     return;
00160 
00161   try
00162     {
00163       supplier->disconnect_push_supplier ();
00164     }
00165   catch (const CORBA::Exception&)
00166     {
00167       // Ignore exceptions, we must isolate other clients from
00168       // failures on this one.
00169     }
00170 }

CORBA::Boolean TAO_CEC_TypedProxyPushConsumer::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 111 of file CEC_TypedProxyPushConsumer.cpp.

References CORBA::Object::_duplicate(), ACE_GUARD_THROW_EX, and CORBA::is_nil().

00113 {
00114   CORBA::Object_var supplier;
00115   {
00116     ACE_GUARD_THROW_EX (
00117         ACE_Lock, ace_mon, *this->lock_,
00118         CORBA::INTERNAL ());
00119 
00120     disconnected = 0;
00121     if (this->is_connected_i () == 0)
00122       {
00123         disconnected = 1;
00124         return 0;
00125       }
00126     if (CORBA::is_nil (this->nopolicy_typed_supplier_.in ()))
00127       {
00128         return 0;
00129       }
00130     supplier = CORBA::Object::_duplicate
00131       (this->nopolicy_typed_supplier_.in ());
00132   }
00133 
00134 #if (TAO_HAS_MINIMUM_CORBA == 0)
00135   return supplier->_non_existent ();
00136 #else
00137   return 0;
00138 #endif /* TAO_HAS_MINIMUM_CORBA */
00139 }


Friends And Related Function Documentation

friend class TAO_CEC_TypedProxyPushConsumer_Guard [friend]

Definition at line 94 of file CEC_TypedProxyPushConsumer.h.


Member Data Documentation

int TAO_CEC_TypedProxyPushConsumer::connected_ [private]

If the flag is not zero then we are connected, notice that the supplier can be nil.

Definition at line 135 of file CEC_TypedProxyPushConsumer.h.

Referenced by cleanup_i(), connect_push_supplier(), is_connected_i(), and shutdown().

PortableServer::POA_var TAO_CEC_TypedProxyPushConsumer::default_POA_ [private]

Store the default POA.

Definition at line 138 of file CEC_TypedProxyPushConsumer.h.

Referenced by get_typed_consumer(), and ~TAO_CEC_TypedProxyPushConsumer().

TAO_CEC_DynamicImplementationServer* TAO_CEC_TypedProxyPushConsumer::dsi_impl_ [private]

The DSI impl.

Definition at line 128 of file CEC_TypedProxyPushConsumer.h.

Referenced by ~TAO_CEC_TypedProxyPushConsumer().

ACE_Lock* TAO_CEC_TypedProxyPushConsumer::lock_ [private]

The locking strategy.

Definition at line 114 of file CEC_TypedProxyPushConsumer.h.

CosEventComm::PushSupplier_var TAO_CEC_TypedProxyPushConsumer::nopolicy_typed_supplier_ [private]

The typed supplier without any policies applied.

Definition at line 125 of file CEC_TypedProxyPushConsumer.h.

PortableServer::ObjectId_var TAO_CEC_TypedProxyPushConsumer::oid_ [private]

The DSI Portable Server OID.

Definition at line 131 of file CEC_TypedProxyPushConsumer.h.

CORBA::ULong TAO_CEC_TypedProxyPushConsumer::refcount_ [private]

The reference count.

Definition at line 117 of file CEC_TypedProxyPushConsumer.h.

Referenced by _decr_refcnt(), and _incr_refcnt().

ACE_Time_Value TAO_CEC_TypedProxyPushConsumer::timeout_ [private]

Definition at line 111 of file CEC_TypedProxyPushConsumer.h.

TAO_CEC_TypedEventChannel* TAO_CEC_TypedProxyPushConsumer::typed_event_channel_ [private]

The typed supplier admin, used for activation and memory managment.

Definition at line 109 of file CEC_TypedProxyPushConsumer.h.

Referenced by _decr_refcnt(), connect_push_supplier(), disconnect_push_consumer(), invoke(), and ~TAO_CEC_TypedProxyPushConsumer().

CosEventComm::PushSupplier_var TAO_CEC_TypedProxyPushConsumer::typed_supplier_ [private]

The typed supplier -- use apply_policy() instead of assigning directly to typed_supplier_. This will keep typed_supplier_ and nopolicy_typed_supplier_ in sync.

Definition at line 122 of file CEC_TypedProxyPushConsumer.h.

Referenced by cleanup_i(), connect_push_supplier(), disconnect_push_consumer(), and shutdown().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:45:02 2010 for TAO_CosEvent by  doxygen 1.4.7