00001 // $Id: SequenceProxyPushConsumer.cpp 87253 2009-10-28 23:29:32Z dai_y $ 00002 00003 #include "orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h" 00004 00005 ACE_RCSID (Notify, TAO_Notify_SequenceProxyPushConsumer, "$Id: SequenceProxyPushConsumer.cpp 87253 2009-10-28 23:29:32Z dai_y $") 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::validate () 00089 { 00090 TAO_Notify_Supplier* sup = this->supplier (); 00091 if (sup != 0 && ! sup->is_alive (true)) 00092 { 00093 if (TAO_debug_level > 0) 00094 { 00095 ACE_DEBUG ((LM_DEBUG, 00096 ACE_TEXT ("(%P|%t) TAO_Notify_SequenceProxyPushConsumer::validate(%d)") 00097 ACE_TEXT ("disconnecting \n"), this->id ())); 00098 } 00099 00100 this->disconnect_sequence_push_consumer (); 00101 } 00102 } 00103 00104 void 00105 TAO_Notify_SequenceProxyPushConsumer::load_attrs (const TAO_Notify::NVPList& attrs) 00106 { 00107 SuperClass::load_attrs(attrs); 00108 ACE_CString ior; 00109 if (attrs.load("PeerIOR", ior)) 00110 { 00111 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00112 try 00113 { 00114 CosNotifyComm::SequencePushSupplier_var ps = CosNotifyComm::SequencePushSupplier::_nil(); 00115 if ( ior.length() > 0 ) 00116 { 00117 CORBA::Object_var obj = orb->string_to_object(ior.c_str()); 00118 ps = CosNotifyComm::SequencePushSupplier::_unchecked_narrow(obj.in()); 00119 } 00120 // minor hack: suppress generating subscription updates during reload. 00121 bool save_updates = this->updates_off_; 00122 this->updates_off_ = true; 00123 this->connect_sequence_push_supplier(ps.in()); 00124 this->updates_off_ = save_updates; 00125 } 00126 catch (const CORBA::Exception&) 00127 { 00128 ACE_ASSERT(0); 00129 } 00130 } 00131 } 00132 00133 void 00134 TAO_Notify_SequenceProxyPushConsumer::configure( 00135 TAO_Notify_SupplierAdmin & /*admin*/, 00136 CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/) 00137 { 00138 // Nothing to do. 00139 // This virtual method was added to support Notification MC 00140 } 00141 00142 00143 TAO_END_VERSIONED_NAMESPACE_DECL