SequenceProxyPushConsumer.cpp

Go to the documentation of this file.
00001 // $Id: SequenceProxyPushConsumer.cpp 77001 2007-02-12 07:54:49Z johnnyw $
00002 
00003 #include "orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h"
00004 
00005 ACE_RCSID (Notify, TAO_Notify_SequenceProxyPushConsumer, "$Id: SequenceProxyPushConsumer.cpp 77001 2007-02-12 07:54:49Z johnnyw $")
00006 
00007 #include "tao/debug.h"
00008 #include "orbsvcs/Notify/Sequence/SequencePushSupplier.h"
00009 #include "orbsvcs/Notify/AdminProperties.h"
00010 #include "orbsvcs/Notify/Structured/StructuredEvent.h"
00011 #include "orbsvcs/Notify/Properties.h"
00012 
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 TAO_Notify_SequenceProxyPushConsumer::TAO_Notify_SequenceProxyPushConsumer (void)
00016 :pacing_interval_ (CosNotification::PacingInterval)
00017 {
00018 }
00019 
00020 TAO_Notify_SequenceProxyPushConsumer::~TAO_Notify_SequenceProxyPushConsumer ()
00021 {
00022 }
00023 
00024 void
00025 TAO_Notify_SequenceProxyPushConsumer::release (void)
00026 {
00027   delete this;
00028   //@@ inform factory
00029 }
00030 
00031 CosNotifyChannelAdmin::ProxyType
00032 TAO_Notify_SequenceProxyPushConsumer::MyType (void)
00033 {
00034   return CosNotifyChannelAdmin::PUSH_SEQUENCE;
00035 }
00036 
00037 void
00038 TAO_Notify_SequenceProxyPushConsumer::connect_sequence_push_supplier (CosNotifyComm::SequencePushSupplier_ptr push_supplier)
00039 {
00040   // Convert Supplier to Base Type
00041   TAO_Notify_SequencePushSupplier *supplier;
00042   ACE_NEW_THROW_EX (supplier,
00043                     TAO_Notify_SequencePushSupplier (this),
00044                     CORBA::NO_MEMORY ());
00045 
00046   supplier->init (push_supplier);
00047 
00048   this->connect (supplier);
00049   this->self_change ();
00050 }
00051 
00052 void
00053 TAO_Notify_SequenceProxyPushConsumer::push_structured_events (const CosNotification::EventBatch& event_batch)
00054 {
00055   // Check if we should proceed at all.
00056   if (this->admin_properties().reject_new_events () == 1 && this->admin_properties().queue_full ())
00057     throw CORBA::IMP_LIMIT ();
00058 
00059   if (this->is_connected () == 0)
00060     {
00061       throw CosEventComm::Disconnected ();
00062     }
00063 
00064   for (CORBA::ULong i = 0; i < event_batch.length (); ++i)
00065     {
00066       const CosNotification::StructuredEvent& notification = event_batch[i];
00067 
00068       TAO_Notify_StructuredEvent_No_Copy event (notification);
00069       this->push_i (&event);
00070     }
00071 }
00072 
00073 void
00074 TAO_Notify_SequenceProxyPushConsumer::disconnect_sequence_push_consumer (void)
00075 {
00076   TAO_Notify_SequenceProxyPushConsumer::Ptr guard( this );
00077   this->destroy ();
00078   this->self_change ();
00079 }
00080 
00081 const char *
00082 TAO_Notify_SequenceProxyPushConsumer::get_proxy_type_name (void) const
00083 {
00084   return "sequence_proxy_push_consumer";
00085 }
00086 
00087 void
00088 TAO_Notify_SequenceProxyPushConsumer::load_attrs (const TAO_Notify::NVPList& attrs)
00089 {
00090   SuperClass::load_attrs(attrs);
00091   ACE_CString ior;
00092   if (attrs.load("PeerIOR", ior))
00093   {
00094     CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
00095     try
00096     {
00097       CosNotifyComm::SequencePushSupplier_var ps = CosNotifyComm::SequencePushSupplier::_nil();
00098       if ( ior.length() > 0 )
00099       {
00100         CORBA::Object_var obj = orb->string_to_object(ior.c_str());
00101         ps = CosNotifyComm::SequencePushSupplier::_unchecked_narrow(obj.in());
00102       }
00103       // minor hack: suppress generating subscription updates during reload.
00104       bool save_updates = this->updates_off_;
00105       this->updates_off_ = true;
00106       this->connect_sequence_push_supplier(ps.in());
00107       this->updates_off_ = save_updates;
00108     }
00109     catch (const CORBA::Exception&)
00110     {
00111       ACE_ASSERT(0);
00112     }
00113   }
00114 }
00115 
00116 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7