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