CEC_ProxyPushSupplier.cpp

Go to the documentation of this file.
00001 // $Id: CEC_ProxyPushSupplier.cpp 77001 2007-02-12 07:54:49Z johnnyw $
00002 
00003 // Force CORBA::release(CORBA::Request...) prototype to be parsed
00004 // before TAO_Pseudo_{Var,Out}_T templates.  All required
00005 // non-dependent names must be parsed prior to the template in
00006 // question when using compilers like g++ 3.4.x.
00007 #include "tao/DynamicInterface/DII_CORBA_methods.h"
00008 
00009 #include "orbsvcs/CosEvent/CEC_ProxyPushSupplier.h"
00010 #include "orbsvcs/CosEvent/CEC_Dispatching.h"
00011 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
00012 #include "orbsvcs/CosEvent/CEC_ConsumerControl.h"
00013 #include "orbsvcs/ESF/ESF_RefCount_Guard.h"
00014 #include "orbsvcs/ESF/ESF_Proxy_RefCount_Guard.h"
00015 
00016 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00017 #include "orbsvcs/CosEvent/CEC_TypedEvent.h"
00018 #include "orbsvcs/CosEvent/CEC_TypedEventChannel.h"
00019 #include "tao/DynamicInterface/Request.h"
00020 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00021 
00022 #include "tao/debug.h"
00023 #include "ace/Reverse_Lock_T.h"
00024 
00025 #if ! defined (__ACE_INLINE__)
00026 #include "orbsvcs/CosEvent/CEC_ProxyPushSupplier.inl"
00027 #endif /* __ACE_INLINE__ */
00028 
00029 ACE_RCSID (CosEvent,
00030            CEC_ProxyPushSupplier,
00031            "$Id: CEC_ProxyPushSupplier.cpp 77001 2007-02-12 07:54:49Z johnnyw $")
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 typedef ACE_Reverse_Lock<ACE_Lock> TAO_CEC_Unlock;
00036 
00037 // TAO_CEC_ProxyPushSupplier Constructure (Un-typed EC)
00038 TAO_CEC_ProxyPushSupplier::
00039 TAO_CEC_ProxyPushSupplier (TAO_CEC_EventChannel* ec,
00040                            const ACE_Time_Value &timeout)
00041   : event_channel_ (ec),
00042     timeout_ (timeout),
00043     refcount_ (1)
00044 {
00045 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00046   typed_event_channel_ = 0;
00047 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00048 
00049   this->lock_ =
00050     this->event_channel_->create_supplier_lock ();
00051 
00052   this->default_POA_ =
00053     this->event_channel_->supplier_poa ();
00054 
00055   this->event_channel_->get_servant_retry_map ().bind (this, 0);
00056 }
00057 
00058 // TAO_CEC_ProxyPushSupplier Constructure (Typed EC)
00059 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00060 TAO_CEC_ProxyPushSupplier::
00061 TAO_CEC_ProxyPushSupplier (TAO_CEC_TypedEventChannel* ec,
00062                            const ACE_Time_Value &timeout)
00063   : timeout_ (timeout),
00064     typed_event_channel_ (ec),
00065     refcount_ (1)
00066 {
00067   event_channel_ = 0;
00068 
00069   this->lock_ =
00070     this->typed_event_channel_->create_supplier_lock ();
00071 
00072   this->default_POA_ =
00073     this->typed_event_channel_->typed_supplier_poa ();
00074 
00075   this->typed_event_channel_->get_servant_retry_map ().bind (this, 0);
00076 }
00077 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00078 
00079 TAO_CEC_ProxyPushSupplier::~TAO_CEC_ProxyPushSupplier (void)
00080 {
00081 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00082   if (this->is_typed_ec () )
00083     {
00084       this->typed_event_channel_->get_servant_retry_map ().unbind (this);
00085       this->typed_event_channel_->destroy_supplier_lock (this->lock_);
00086     }
00087   else
00088     {
00089       this->event_channel_->get_servant_retry_map ().unbind (this);
00090       this->event_channel_->destroy_supplier_lock (this->lock_);
00091     }
00092 #else
00093   this->event_channel_->get_servant_retry_map ().unbind (this);
00094   this->event_channel_->destroy_supplier_lock (this->lock_);
00095 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00096 }
00097 
00098 void
00099 TAO_CEC_ProxyPushSupplier::activate (
00100     CosEventChannelAdmin::ProxyPushSupplier_ptr &activated_proxy)
00101 {
00102   CosEventChannelAdmin::ProxyPushSupplier_var result;
00103   try
00104     {
00105       result = this->_this ();
00106     }
00107   catch (const CORBA::Exception&)
00108     {
00109       result = CosEventChannelAdmin::ProxyPushSupplier::_nil ();
00110     }
00111   activated_proxy = result._retn ();
00112 }
00113 
00114 void
00115 TAO_CEC_ProxyPushSupplier::deactivate (void)
00116 {
00117   try
00118     {
00119       PortableServer::POA_var poa =
00120         this->_default_POA ();
00121       PortableServer::ObjectId_var id =
00122         poa->servant_to_id (this);
00123       poa->deactivate_object (id.in ());
00124     }
00125   catch (const CORBA::Exception&)
00126     {
00127       // Exceptions here should not be propagated.  They usually
00128       // indicate that an object is beign disconnected twice, or some
00129       // race condition, but not a fault that the user needs to know
00130       // about.
00131     }
00132 }
00133 
00134 void
00135 TAO_CEC_ProxyPushSupplier::shutdown (void)
00136 {
00137 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00138   if (this->is_typed_ec () )
00139     {
00140       // Save the consumer we where connected to, we need to send a
00141       // disconnect message to it.
00142       CosTypedEventComm::TypedPushConsumer_var typed_consumer;
00143       {
00144         ACE_GUARD_THROW_EX (
00145             ACE_Lock, ace_mon, *this->lock_,
00146             CORBA::INTERNAL ());
00147         // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00148 
00149         typed_consumer = this->typed_consumer_._retn ();
00150       }
00151 
00152       this->deactivate ();
00153 
00154       if (CORBA::is_nil (typed_consumer.in ()))
00155         return;
00156 
00157       try
00158         {
00159           typed_consumer->disconnect_push_consumer ();
00160         }
00161       catch (const CORBA::Exception&)
00162         {
00163           // Ignore exceptions, we must isolate other clients from
00164           // problems on this one.
00165         }
00166     } /* this->is_typed_ec */
00167   else
00168     {
00169 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00170 
00171   // Save the consumer we where connected to, we need to send a
00172   // disconnect message to it.
00173   CosEventComm::PushConsumer_var consumer;
00174 
00175   {
00176     ACE_GUARD_THROW_EX (
00177         ACE_Lock, ace_mon, *this->lock_,
00178         CORBA::INTERNAL ());
00179     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00180 
00181     consumer = this->consumer_._retn ();
00182   }
00183 
00184   this->deactivate ();
00185 
00186   if (CORBA::is_nil (consumer.in ()))
00187     return;
00188 
00189   try
00190     {
00191       consumer->disconnect_push_consumer ();
00192     }
00193   catch (const CORBA::Exception&)
00194     {
00195       // Ignore exceptions, we must isolate other clients from
00196       // problems on this one.
00197     }
00198 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00199     } /* ! this->is_typed_ec */
00200 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00201 }
00202 
00203 typedef TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_EventChannel,TAO_CEC_ProxyPushSupplier> Destroy_Guard;
00204 
00205 void
00206 TAO_CEC_ProxyPushSupplier::push (const CORBA::Any &event)
00207 {
00208   Destroy_Guard auto_destroy (this->refcount_,
00209                               this->event_channel_,
00210                               this);
00211 
00212   {
00213     ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00214 
00215     if (this->is_connected_i () == 0)
00216       return;
00217 
00218     TAO_ESF_RefCount_Guard<CORBA::ULong> cnt_mon (this->refcount_);
00219 
00220     {
00221       TAO_CEC_Unlock reverse_lock (*this->lock_);
00222 
00223       ACE_GUARD (TAO_CEC_Unlock, ace_mon, reverse_lock);
00224       this->event_channel_->dispatching ()->push (this,
00225                                                   event);
00226     }
00227   }
00228 }
00229 
00230 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00231 typedef TAO_ESF_Proxy_RefCount_Guard<TAO_CEC_TypedEventChannel,TAO_CEC_ProxyPushSupplier> Destroy_Guard_Typed;
00232 
00233 void
00234 TAO_CEC_ProxyPushSupplier::invoke (const TAO_CEC_TypedEvent& typed_event)
00235 {
00236   Destroy_Guard_Typed auto_destroy (this->refcount_,
00237                                     this->typed_event_channel_,
00238                                     this);
00239   {
00240 
00241     ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00242 
00243     if (this->is_connected_i () == 0)
00244       return;
00245 
00246     TAO_ESF_RefCount_Guard<CORBA::ULong> cnt_mon (this->refcount_);
00247 
00248     {
00249       TAO_CEC_Unlock reverse_lock (*this->lock_);
00250 
00251       ACE_GUARD (TAO_CEC_Unlock, ace_mon, reverse_lock);
00252       this->typed_event_channel_->dispatching ()->invoke (this,
00253                                                           typed_event);
00254     }
00255   }
00256 }
00257 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00258 
00259 void
00260 TAO_CEC_ProxyPushSupplier::push_nocopy (CORBA::Any &event)
00261 {
00262   Destroy_Guard auto_destroy (this->refcount_,
00263                               this->event_channel_,
00264                               this);
00265 
00266   {
00267     ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00268 
00269     if (this->is_connected_i () == 0)
00270       return;
00271 
00272     TAO_ESF_RefCount_Guard<CORBA::ULong> cnt_mon (this->refcount_);
00273 
00274     {
00275       TAO_CEC_Unlock reverse_lock (*this->lock_);
00276 
00277       ACE_GUARD (TAO_CEC_Unlock, ace_mon, reverse_lock);
00278       this->event_channel_->dispatching ()->push_nocopy (this,
00279                                                          event);
00280     }
00281   }
00282 }
00283 
00284 void
00285 TAO_CEC_ProxyPushSupplier::cleanup_i (void)
00286 {
00287   this->consumer_ =
00288     CosEventComm::PushConsumer::_nil ();
00289 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00290   this->typed_consumer_ =
00291     CosTypedEventComm::TypedPushConsumer::_nil ();
00292 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00293 }
00294 
00295 CORBA::ULong
00296 TAO_CEC_ProxyPushSupplier::_incr_refcnt (void)
00297 {
00298   ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
00299   return this->refcount_++;
00300 }
00301 
00302 CORBA::ULong
00303 TAO_CEC_ProxyPushSupplier::_decr_refcnt (void)
00304 {
00305   {
00306     ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
00307     --this->refcount_;
00308     if (this->refcount_ != 0)
00309       return this->refcount_;
00310   }
00311 
00312   // Notify the event channel
00313 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00314   if (this->is_typed_ec () )
00315     {
00316       this->typed_event_channel_->destroy_proxy (this);
00317     }
00318   else
00319     {
00320       this->event_channel_->destroy_proxy (this);
00321     }
00322 #else
00323   this->event_channel_->destroy_proxy (this);
00324 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00325   return 0;
00326 }
00327 
00328 void
00329 TAO_CEC_ProxyPushSupplier::connect_push_consumer (
00330       CosEventComm::PushConsumer_ptr push_consumer)
00331 {
00332   // Nil PushConsumers are illegal
00333   if (CORBA::is_nil (push_consumer))
00334     throw CORBA::BAD_PARAM ();
00335 
00336   {
00337 
00338 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00339     // Check if we have a typed event channel
00340     if (this->is_typed_ec () )
00341       {
00342         if (TAO_debug_level >= 10)
00343           {
00344             ACE_DEBUG ((LM_DEBUG,
00345                         ACE_TEXT ("***** connect_push_consumer, ")
00346                         ACE_TEXT ("Event channel is typed *****\n")));
00347           }
00348 
00349         // Temporary for the TypedPushConsumer and it's Typed interface,
00350         // declared and obtained before the Guard to avoid deadlock during the
00351         // _is_a (during _narrow) and get_typed_consumer invocations.
00352         // They are eventually assigned onto this object inside the Guard.
00353         CosTypedEventComm::TypedPushConsumer_var local_typed_consumer =
00354           CosTypedEventComm::TypedPushConsumer::_narrow (push_consumer);
00355 
00356         // Obtain the typed object interface from the consumer
00357         CORBA::Object_var local_typed_consumer_obj =
00358           CORBA::Object::_duplicate (local_typed_consumer->get_typed_consumer () );
00359 
00360         {
00361           ACE_GUARD_THROW_EX (
00362               ACE_Lock, ace_mon, *this->lock_,
00363               CORBA::INTERNAL ());
00364           // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00365 
00366           if (this->is_connected_i ())
00367             {
00368               if (this->typed_event_channel_->consumer_reconnect () == 0)
00369                 throw CosEventChannelAdmin::AlreadyConnected ();
00370 
00371               // Re-connections are allowed....
00372               this->cleanup_i ();
00373 
00374               this->typed_consumer_ = apply_policy (local_typed_consumer.in () );
00375 
00376               TAO_CEC_Unlock reverse_lock (*this->lock_);
00377 
00378               {
00379                 ACE_GUARD_THROW_EX (
00380                     TAO_CEC_Unlock, ace_mon, reverse_lock,
00381                     CORBA::INTERNAL ());
00382                 // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00383 
00384                 this->typed_event_channel_->reconnected (this);
00385               }
00386               return;
00387 
00388             }
00389 
00390           this->typed_consumer_ = apply_policy (local_typed_consumer.in () );
00391 
00392           // Store the typed object interface from the consumer
00393           this->typed_consumer_obj_ =
00394             apply_policy_obj (local_typed_consumer_obj.in () );
00395         }
00396 
00397         // Notify the event channel...
00398         this->typed_event_channel_->connected (this);
00399 
00400       } /* this->is_typed_ec */
00401     else
00402       {
00403 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00404 
00405         if (TAO_debug_level >= 10)
00406           {
00407             ACE_DEBUG ((LM_DEBUG,
00408                         ACE_TEXT ("***** connect_push_consumer, ")
00409                         ACE_TEXT ("Event channel is un-typed *****\n")));
00410           }
00411 
00412         {
00413 
00414     ACE_GUARD_THROW_EX (
00415         ACE_Lock, ace_mon, *this->lock_,
00416         CORBA::INTERNAL ());
00417     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00418 
00419     if (this->is_connected_i ())
00420       {
00421         if (this->event_channel_->consumer_reconnect () == 0)
00422           throw CosEventChannelAdmin::AlreadyConnected ();
00423 
00424         // Re-connections are allowed....
00425         this->cleanup_i ();
00426 
00427         this->consumer_ = apply_policy (push_consumer);
00428 
00429         TAO_CEC_Unlock reverse_lock (*this->lock_);
00430 
00431         {
00432           ACE_GUARD_THROW_EX (
00433               TAO_CEC_Unlock, ace_mon, reverse_lock,
00434               CORBA::INTERNAL ());
00435           // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00436 
00437           this->event_channel_->reconnected (this);
00438         }
00439         return;
00440       }
00441 
00442     this->consumer_ = apply_policy (push_consumer);
00443   }
00444 
00445   // Notify the event channel...
00446   this->event_channel_->connected (this);
00447 
00448 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00449       } /* ! this->is_typed_ec */
00450 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00451   }
00452 }
00453 
00454 CORBA::Object_ptr
00455 TAO_CEC_ProxyPushSupplier::apply_policy_obj (CORBA::Object_ptr pre)
00456 {
00457 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00458   CORBA::Object_var post = CORBA::Object::_duplicate (pre);
00459   if (this->timeout_ > ACE_Time_Value::zero)
00460     {
00461       CORBA::PolicyList policy_list;
00462       policy_list.length (1);
00463       if (this->typed_event_channel_)
00464         {
00465           policy_list[0] = this->typed_event_channel_->
00466             create_roundtrip_timeout_policy (this->timeout_);
00467         }
00468       else
00469         {
00470           policy_list[0] = this->event_channel_->
00471             create_roundtrip_timeout_policy (this->timeout_);
00472         }
00473       post = pre->_set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE);
00474 
00475       policy_list[0]->destroy ();
00476       policy_list.length (0);
00477     }
00478   return post._retn ();
00479 #else
00480   return CORBA::Object::_duplicate (pre);
00481 #endif /* TAO_HAS_CORBA_MESSAGING */
00482 }
00483 
00484 CosEventComm::PushConsumer_ptr
00485 TAO_CEC_ProxyPushSupplier::apply_policy (CosEventComm::PushConsumer_ptr pre)
00486 {
00487   this->nopolicy_consumer_ = CosEventComm::PushConsumer::_duplicate (pre);
00488   CORBA::Object_var post_obj = apply_policy_obj (pre);
00489   CosEventComm::PushConsumer_var post =
00490     CosEventComm::PushConsumer::_narrow (post_obj.in ());
00491   return post._retn ();
00492 }
00493 
00494 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00495 CosTypedEventComm::TypedPushConsumer_ptr
00496 TAO_CEC_ProxyPushSupplier::apply_policy
00497   (CosTypedEventComm::TypedPushConsumer_ptr pre)
00498 {
00499   this->nopolicy_typed_consumer_ =
00500     CosTypedEventComm::TypedPushConsumer::_duplicate (pre);
00501   CORBA::Object_var post_obj = apply_policy_obj (pre);
00502   CosTypedEventComm::TypedPushConsumer_var post =
00503     CosTypedEventComm::TypedPushConsumer::_narrow (post_obj.in ());
00504   return post._retn ();
00505 }
00506 #endif
00507 
00508 void
00509 TAO_CEC_ProxyPushSupplier::disconnect_push_supplier ()
00510 {
00511   CosEventComm::PushConsumer_var consumer;
00512 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00513   CosTypedEventComm::TypedPushConsumer_var typed_consumer;
00514 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00515 
00516   {
00517     ACE_GUARD_THROW_EX (
00518         ACE_Lock, ace_mon, *this->lock_,
00519         CORBA::INTERNAL ());
00520     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00521 
00522     if (this->is_connected_i () == 0)
00523       throw CORBA::BAD_INV_ORDER ();
00524 
00525 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00526     if (this->is_typed_ec () )
00527       {
00528         typed_consumer = this->typed_consumer_._retn ();
00529       }
00530     else
00531       {
00532         consumer = this->consumer_._retn ();
00533       }
00534 #else
00535     consumer = this->consumer_._retn ();
00536 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00537 
00538     this->cleanup_i ();
00539   }
00540 
00541   // Notify the event channel....
00542 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00543   if (this->is_typed_ec () )
00544     {
00545       this->typed_event_channel_->disconnected (this);
00546     }
00547   else
00548     {
00549       this->event_channel_->disconnected (this);
00550     }
00551 #else
00552   this->event_channel_->disconnected (this);
00553 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00554 
00555   // Disconnect callbacks
00556 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00557   if (this->is_typed_ec () )
00558     {
00559       if (this->typed_event_channel_->disconnect_callbacks ())
00560         {
00561           try
00562             {
00563               typed_consumer->disconnect_push_consumer ();
00564             }
00565           catch (const CORBA::Exception& ex)
00566             {
00567               // Ignore exceptions, we must isolate other clients from
00568               // problems on this one.
00569               ex._tao_print_exception (
00570                 "ProxySupplier::disconnect_push_supplier");
00571             }
00572         }
00573     } /* this->is_typed_ec */
00574   else
00575     {
00576 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00577 
00578   if (this->event_channel_->disconnect_callbacks ())
00579     {
00580       try
00581         {
00582           consumer->disconnect_push_consumer ();
00583         }
00584       catch (const CORBA::Exception& ex)
00585         {
00586           // Ignore exceptions, we must isolate other clients from
00587           // problems on this one.
00588           ex._tao_print_exception ("ProxySupplier::disconnect_push_supplier");
00589         }
00590     }
00591 
00592 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00593     } /* ! this->is_typed_ec */
00594 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00595 }
00596 
00597 void
00598 TAO_CEC_ProxyPushSupplier::push_to_consumer (const CORBA::Any& event)
00599 {
00600   CosEventComm::PushConsumer_var consumer;
00601   {
00602     ACE_GUARD_THROW_EX (
00603             ACE_Lock, ace_mon, *this->lock_,
00604             CORBA::INTERNAL ());
00605     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00606 
00607     if (this->is_connected_i () == 0)
00608       return; // ACE_THROW (CosEventComm::Disconnected ());????
00609 
00610     consumer =
00611       CosEventComm::PushConsumer::_duplicate (this->consumer_.in ());
00612   }
00613 
00614   TAO_CEC_ConsumerControl *control =
00615                this->event_channel_->consumer_control ();
00616   try
00617     {
00618       consumer->push (event);
00619 
00620       // Inform the control that we were able to push something
00621       control->successful_transmission(this);
00622     }
00623   catch (const CORBA::OBJECT_NOT_EXIST&)
00624     {
00625       control->consumer_not_exist (this);
00626     }
00627   catch (CORBA::SystemException& sysex)
00628     {
00629       control->system_exception (this,
00630                                  sysex);
00631     }
00632   catch (const CORBA::Exception&)
00633     {
00634       // Shouldn't happen, but does not hurt
00635     }
00636 }
00637 
00638 void
00639 TAO_CEC_ProxyPushSupplier::reactive_push_to_consumer (
00640     const CORBA::Any& event)
00641 {
00642   CosEventComm::PushConsumer_var consumer;
00643   {
00644     ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00645     if (this->is_connected_i () == 0)
00646       return; // TAO_THROW (CosEventComm::Disconnected ());????
00647 
00648     consumer =
00649       CosEventComm::PushConsumer::_duplicate (this->consumer_.in ());
00650   }
00651 
00652   TAO_CEC_ConsumerControl *control =
00653                   this->event_channel_->consumer_control ();
00654 
00655   try
00656     {
00657       consumer->push (event);
00658 
00659       // Inform the control that we were able to push something
00660       control->successful_transmission(this);
00661     }
00662   catch (const CORBA::OBJECT_NOT_EXIST& not_used)
00663     {
00664        if (TAO_debug_level >= 4)
00665         {
00666           not_used._tao_print_exception (
00667             "during TAO_CEC_ProxyPushSupplier::reactive_push_to_consumer");
00668         }
00669      control->consumer_not_exist (this);
00670     }
00671   catch (CORBA::SystemException& sysex)
00672     {
00673       if (TAO_debug_level >= 4)
00674         {
00675           sysex._tao_print_exception (
00676             "during TAO_CEC_ProxyPushSupplier::reactive_push_to_consumer");
00677         }
00678 
00679       control->system_exception (this,
00680                                  sysex);
00681     }
00682   catch (const CORBA::Exception&)
00683     {
00684       // Shouldn't happen, but does not hurt
00685     }
00686 }
00687 
00688 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00689 void
00690 TAO_CEC_ProxyPushSupplier::invoke_to_consumer (const TAO_CEC_TypedEvent &typed_event)
00691 {
00692   CORBA::Object_var typed_consumer_obj;
00693 
00694   // The DII target request object
00695   CORBA::Request_var target_request;
00696 
00697   {
00698     ACE_GUARD_THROW_EX (
00699             ACE_Lock, ace_mon, *this->lock_,
00700             CORBA::INTERNAL ());
00701     // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
00702 
00703     if (this->is_connected_i () == 0)
00704       return; // ACE_THROW (CosEventComm::Disconnected ());????
00705 
00706     typed_consumer_obj =
00707       CORBA::Object::_duplicate (this->typed_consumer_obj_.in ());
00708   }
00709 
00710   TAO_CEC_ConsumerControl *control =
00711                this->typed_event_channel_->consumer_control ();
00712 
00713   // Create the DII request
00714   try
00715     {
00716       typed_consumer_obj_->_create_request (0, // ctx
00717                                             typed_event.operation_,
00718                                             typed_event.list_,
00719                                             0, // result
00720                                             0, // exception_list,
00721                                             0, // context_list,
00722                                             target_request.inout(),
00723                                             0);
00724 
00725       // Call the DII invoke for the operation on the target object
00726       target_request->invoke ();
00727 
00728       // Inform the control that we were able to invoke something
00729       control->successful_transmission(this);
00730     }
00731   catch (const CORBA::OBJECT_NOT_EXIST& not_used)
00732     {
00733       if (TAO_debug_level >= 4)
00734         {
00735           not_used._tao_print_exception (
00736             "during TAO_CEC_ProxyPushSupplier::invoke_to_consumer");
00737         }
00738       control->consumer_not_exist (this);
00739     }
00740   catch (CORBA::SystemException& sysex)
00741     {
00742       if (TAO_debug_level >= 4)
00743         {
00744           sysex._tao_print_exception (
00745             "during TAO_CEC_ProxyPushSupplier::invoke_to_consumer");
00746         }
00747       control->system_exception (this,
00748                                  sysex);
00749     }
00750   catch (const CORBA::Exception& ex)
00751     {
00752       // Shouldn't happen, but does not hurt
00753       if (TAO_debug_level >= 4)
00754         {
00755           ex._tao_print_exception (
00756             "ex raised during TAO_CEC_ProxyPushSupplier::invoke_to_consumer");
00757         }
00758     }
00759 }
00760 
00761 void
00762 TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer (
00763     const TAO_CEC_TypedEvent& typed_event)
00764 {
00765   CORBA::Object_var typed_consumer_obj;
00766 
00767   // The DII target request object
00768   CORBA::Request_var target_request;
00769 
00770   {
00771     ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
00772     if (this->is_connected_i () == 0)
00773     {
00774       return; // TAO_THROW (CosEventComm::Disconnected ());????
00775     }
00776     if (CORBA::is_nil(this->typed_consumer_obj_.in()))
00777     {
00778       return; // TAO_THROW ...
00779     }
00780 
00781     typed_consumer_obj =
00782       CORBA::Object::_duplicate (this->typed_consumer_obj_.in ());
00783   }
00784 
00785   TAO_CEC_ConsumerControl *control =
00786                   this->typed_event_channel_->consumer_control ();
00787 
00788   // Create the DII request
00789   try
00790     {
00791       typed_consumer_obj_->_create_request (0, // ctx
00792                                             typed_event.operation_,
00793                                             typed_event.list_,
00794                                             0, // result
00795                                             0, // exception_list,
00796                                             0, // context_list,
00797                                             target_request.inout(),
00798                                             0);
00799 
00800       // Call the DII invoke for the operation on the target object
00801       target_request->invoke ();
00802 
00803       // Inform the control that we were able to invoke something
00804       control->successful_transmission(this);
00805     }
00806   catch (const CORBA::OBJECT_NOT_EXIST& not_used)
00807     {
00808       if (TAO_debug_level >= 4)
00809         {
00810           not_used._tao_print_exception (
00811             "during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer");
00812         }
00813       control->consumer_not_exist (this);
00814     }
00815   catch (CORBA::SystemException& sysex)
00816     {
00817       if (TAO_debug_level >= 4)
00818         {
00819           sysex._tao_print_exception (
00820             "during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer");
00821         }
00822       control->system_exception (this,
00823                                  sysex);
00824     }
00825   catch (const CORBA::Exception& ex)
00826     {
00827       if (TAO_debug_level >= 4)
00828         {
00829           ex._tao_print_exception (
00830             "ex raised during TAO_CEC_ProxyPushSupplier::reactive_invoke_to_consumer");
00831         }
00832     }
00833 }
00834 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00835 
00836 CORBA::Boolean
00837 TAO_CEC_ProxyPushSupplier::consumer_non_existent (
00838       CORBA::Boolean_out disconnected)
00839 {
00840   CORBA::Object_var consumer;
00841   {
00842     ACE_GUARD_THROW_EX (
00843         ACE_Lock, ace_mon, *this->lock_,
00844         CORBA::INTERNAL ());
00845 
00846     disconnected = 0;
00847     if (this->is_connected_i () == 0)
00848       {
00849         disconnected = 1;
00850         return 0;
00851       }
00852 
00853 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00854     if (this->is_typed_ec () )
00855       {
00856         if (CORBA::is_nil (this->nopolicy_typed_consumer_.in ()))
00857           {
00858             return 0;
00859           }
00860         consumer = CORBA::Object::_duplicate
00861           (this->nopolicy_typed_consumer_.in ());
00862       }
00863     else
00864       {
00865 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00866     if (CORBA::is_nil (this->nopolicy_consumer_.in ()))
00867       {
00868         return 0;
00869       }
00870     consumer = CORBA::Object::_duplicate (this->nopolicy_consumer_.in ());
00871 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
00872       } /* ! this->is_typed_ec */
00873 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
00874   }
00875 
00876 #if (TAO_HAS_MINIMUM_CORBA == 0)
00877   return consumer->_non_existent ();
00878 #else
00879   return 0;
00880 #endif /* TAO_HAS_MINIMUM_CORBA */
00881 }
00882 
00883 PortableServer::POA_ptr
00884 TAO_CEC_ProxyPushSupplier::_default_POA (void)
00885 {
00886   return PortableServer::POA::_duplicate (this->default_POA_.in ());
00887 }
00888 
00889 void
00890 TAO_CEC_ProxyPushSupplier::_add_ref (void)
00891 {
00892   this->_incr_refcnt ();
00893 }
00894 
00895 void
00896 TAO_CEC_ProxyPushSupplier::_remove_ref (void)
00897 {
00898   this->_decr_refcnt ();
00899 }
00900 
00901 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:44:51 2010 for TAO_CosEvent by  doxygen 1.4.7