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