00001 // $Id: ProxyPushSupplier.cpp 87253 2009-10-28 23:29:32Z dai_y $ 00002 00003 #include "orbsvcs/Notify/Any/ProxyPushSupplier.h" 00004 00005 ACE_RCSID (Notify, TAO_Notify_ProxyPushSupplier, "$Id: ProxyPushSupplier.cpp 87253 2009-10-28 23:29:32Z dai_y $") 00006 00007 #include "tao/debug.h" 00008 #include "orbsvcs/Notify/Any/PushConsumer.h" 00009 #include "orbsvcs/Notify/Properties.h" 00010 00011 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00012 00013 TAO_Notify_ProxyPushSupplier::TAO_Notify_ProxyPushSupplier (void) 00014 { 00015 } 00016 00017 TAO_Notify_ProxyPushSupplier::~TAO_Notify_ProxyPushSupplier () 00018 { 00019 } 00020 00021 void 00022 TAO_Notify_ProxyPushSupplier::release (void) 00023 { 00024 delete this; 00025 //@@ inform factory 00026 } 00027 00028 void 00029 TAO_Notify_ProxyPushSupplier::connect_any_push_consumer (CosEventComm::PushConsumer_ptr push_consumer) 00030 { 00031 // Convert Consumer to Base Type 00032 TAO_Notify_PushConsumer* consumer; 00033 ACE_NEW_THROW_EX (consumer, 00034 TAO_Notify_PushConsumer (this), 00035 CORBA::NO_MEMORY ()); 00036 00037 consumer->init (push_consumer); 00038 00039 this->connect (consumer); 00040 this->self_change (); 00041 } 00042 00043 void 00044 TAO_Notify_ProxyPushSupplier::disconnect_push_supplier (void) 00045 { 00046 TAO_Notify_ProxyPushSupplier::Ptr guard( this ); 00047 this->destroy (); 00048 this->self_change (); 00049 } 00050 00051 CosNotifyChannelAdmin::ProxyType 00052 TAO_Notify_ProxyPushSupplier::MyType (void) 00053 { 00054 return CosNotifyChannelAdmin::PUSH_ANY; 00055 } 00056 00057 const char * 00058 TAO_Notify_ProxyPushSupplier::get_proxy_type_name (void) const 00059 { 00060 return "proxy_push_supplier"; 00061 } 00062 00063 void 00064 TAO_Notify_ProxyPushSupplier::validate () 00065 { 00066 TAO_Notify_Consumer* con = this->consumer (); 00067 if (con != 0 && ! con->is_alive (true)) 00068 { 00069 if (TAO_debug_level > 0) 00070 { 00071 ACE_DEBUG ((LM_DEBUG, 00072 ACE_TEXT ("(%P|%t) TAO_Notify_ProxyPushSupplier::validate(%d)") 00073 ACE_TEXT ("disconnecting \n"), this->id ())); 00074 } 00075 00076 this->disconnect_push_supplier (); 00077 } 00078 } 00079 00080 void 00081 TAO_Notify_ProxyPushSupplier::load_attrs (const TAO_Notify::NVPList& attrs) 00082 { 00083 SuperClass::load_attrs(attrs); 00084 ACE_CString ior; 00085 if (attrs.load("PeerIOR", ior)) 00086 { 00087 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00088 try 00089 { 00090 CosNotifyComm::PushConsumer_var pc = 00091 CosNotifyComm::PushConsumer::_nil(); 00092 if (ior.length() > 0) 00093 { 00094 CORBA::Object_var obj = 00095 orb->string_to_object(ior.c_str()); 00096 pc = CosNotifyComm::PushConsumer::_unchecked_narrow(obj.in()); 00097 } 00098 this->connect_any_push_consumer(pc.in()); 00099 } 00100 catch (const CORBA::Exception&) 00101 { 00102 // if we can't reconnect, tough... 00103 } 00104 } 00105 } 00106 00107 void 00108 TAO_Notify_ProxyPushSupplier::configure( 00109 TAO_Notify_ConsumerAdmin & /*admin*/, 00110 CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/) 00111 { 00112 // presently nothing to do here. 00113 // this method was added to support NotificationMC 00114 } 00115 00116 00117 00118 TAO_END_VERSIONED_NAMESPACE_DECL