00001 // $Id: ProxyPushConsumer.cpp 87253 2009-10-28 23:29:32Z dai_y $ 00002 00003 #include "orbsvcs/Notify/Any/ProxyPushConsumer.h" 00004 00005 ACE_RCSID (Notify, TAO_Notify_ProxyPushConsumer, "$Id: ProxyPushConsumer.cpp 87253 2009-10-28 23:29:32Z dai_y $") 00006 00007 #include "tao/debug.h" 00008 #include "orbsvcs/Notify/AdminProperties.h" 00009 #include "orbsvcs/Notify/Properties.h" 00010 #include "orbsvcs/Notify/Any/AnyEvent.h" 00011 #include "orbsvcs/Notify/Any/PushSupplier.h" 00012 00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00014 00015 TAO_Notify_ProxyPushConsumer::TAO_Notify_ProxyPushConsumer (void) 00016 { 00017 } 00018 00019 TAO_Notify_ProxyPushConsumer::~TAO_Notify_ProxyPushConsumer () 00020 { 00021 } 00022 00023 void 00024 TAO_Notify_ProxyPushConsumer::release (void) 00025 { 00026 delete this; 00027 //@@ inform factory 00028 } 00029 00030 CosNotifyChannelAdmin::ProxyType 00031 TAO_Notify_ProxyPushConsumer::MyType (void) 00032 { 00033 return CosNotifyChannelAdmin::PUSH_ANY; 00034 } 00035 00036 void 00037 TAO_Notify_ProxyPushConsumer::push (const CORBA::Any& any) 00038 { 00039 // Check if we should proceed at all. 00040 if (this->admin_properties().reject_new_events () == 1 00041 && this->admin_properties().queue_full ()) 00042 throw CORBA::IMP_LIMIT (); 00043 00044 if (this->is_connected () == 0) 00045 { 00046 throw CosEventComm::Disconnected (); 00047 } 00048 00049 TAO_Notify_AnyEvent_No_Copy event (any); 00050 this->push_i (&event); 00051 } 00052 00053 void 00054 TAO_Notify_ProxyPushConsumer::connect_any_push_supplier (CosEventComm::PushSupplier_ptr push_supplier) 00055 { 00056 // Convert Supplier to Base Type 00057 TAO_Notify_PushSupplier *supplier; 00058 ACE_NEW_THROW_EX (supplier, 00059 TAO_Notify_PushSupplier (this), 00060 CORBA::NO_MEMORY ()); 00061 00062 supplier->init (push_supplier); 00063 00064 this->connect (supplier); 00065 this->self_change (); 00066 } 00067 00068 void TAO_Notify_ProxyPushConsumer::disconnect_push_consumer (void) 00069 { 00070 TAO_Notify_ProxyPushConsumer::Ptr guard( this ); 00071 this->destroy (); 00072 this->self_change (); 00073 } 00074 00075 const char * 00076 TAO_Notify_ProxyPushConsumer::get_proxy_type_name (void) const 00077 { 00078 return "proxy_push_consumer"; 00079 } 00080 00081 void 00082 TAO_Notify_ProxyPushConsumer::validate () 00083 { 00084 TAO_Notify_Supplier* sup = this->supplier (); 00085 if (sup != 0 && ! sup->is_alive (true)) 00086 { 00087 if (TAO_debug_level > 0) 00088 { 00089 ACE_DEBUG ((LM_DEBUG, 00090 ACE_TEXT ("(%P|%t) TAO_Notify_ProxyPushConsumer::validate(%d)") 00091 ACE_TEXT ("disconnecting \n"), this->id ())); 00092 } 00093 this->disconnect_push_consumer (); 00094 } 00095 } 00096 00097 00098 void 00099 TAO_Notify_ProxyPushConsumer::load_attrs (const TAO_Notify::NVPList& attrs) 00100 { 00101 SuperClass::load_attrs(attrs); 00102 ACE_CString ior; 00103 if (attrs.load("PeerIOR", ior)) 00104 { 00105 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00106 try 00107 { 00108 CosNotifyComm::PushSupplier_var ps = CosNotifyComm::PushSupplier::_nil(); 00109 if ( ior.length() > 0 ) 00110 { 00111 CORBA::Object_var obj = 00112 orb->string_to_object(ior.c_str()); 00113 ps = CosNotifyComm::PushSupplier::_unchecked_narrow(obj.in()); 00114 } 00115 // minor hack: suppress generating subscription updates during reload. 00116 bool save_updates = this->updates_off_; 00117 this->updates_off_ = true; 00118 this->connect_any_push_supplier(ps.in()); 00119 this->updates_off_ = save_updates; 00120 } 00121 catch (...) 00122 { 00123 ACE_ASSERT(0); 00124 } 00125 } 00126 } 00127 00128 void 00129 TAO_Notify_ProxyPushConsumer::configure( 00130 TAO_Notify_SupplierAdmin & /*admin*/, 00131 CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/) 00132 { 00133 // presently nothing to do here. 00134 // this method was added to support NotificationMC 00135 } 00136 00137 00138 TAO_END_VERSIONED_NAMESPACE_DECL