00001 // $Id: ProxyPushConsumer.cpp 77001 2007-02-12 07:54:49Z johnnyw $ 00002 00003 #include "orbsvcs/Notify/Any/ProxyPushConsumer.h" 00004 00005 ACE_RCSID (Notify, TAO_Notify_ProxyPushConsumer, "$Id: ProxyPushConsumer.cpp 77001 2007-02-12 07:54:49Z johnnyw $") 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::load_attrs (const TAO_Notify::NVPList& attrs) 00083 { 00084 SuperClass::load_attrs(attrs); 00085 ACE_CString ior; 00086 if (attrs.load("PeerIOR", ior)) 00087 { 00088 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00089 try 00090 { 00091 CosNotifyComm::PushSupplier_var ps = CosNotifyComm::PushSupplier::_nil(); 00092 if ( ior.length() > 0 ) 00093 { 00094 CORBA::Object_var obj = 00095 orb->string_to_object(ior.c_str()); 00096 ps = CosNotifyComm::PushSupplier::_unchecked_narrow(obj.in()); 00097 } 00098 // minor hack: suppress generating subscription updates during reload. 00099 bool save_updates = this->updates_off_; 00100 this->updates_off_ = true; 00101 this->connect_any_push_supplier(ps.in()); 00102 this->updates_off_ = save_updates; 00103 } 00104 catch (...) 00105 { 00106 ACE_ASSERT(0); 00107 } 00108 } 00109 } 00110 00111 TAO_END_VERSIONED_NAMESPACE_DECL