00001 // $Id: CosEC_ProxyPushConsumer.cpp 87253 2009-10-28 23:29:32Z dai_y $ 00002 00003 #include "orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h" 00004 00005 ACE_RCSID (Notify, TAO_Notify_CosEC_ProxyPushConsumer, "$Id: CosEC_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/Method_Request_Lookup.h" 00010 #include "orbsvcs/Notify/Worker_Task.h" 00011 #include "orbsvcs/Notify/Any/AnyEvent.h" 00012 #include "orbsvcs/Notify/Any/PushSupplier.h" 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 TAO_Notify_CosEC_ProxyPushConsumer::TAO_Notify_CosEC_ProxyPushConsumer (void) 00017 { 00018 } 00019 00020 TAO_Notify_CosEC_ProxyPushConsumer::~TAO_Notify_CosEC_ProxyPushConsumer () 00021 { 00022 } 00023 00024 void 00025 TAO_Notify_CosEC_ProxyPushConsumer::release (void) 00026 { 00027 delete this; 00028 //@@ inform factory 00029 } 00030 00031 void 00032 TAO_Notify_CosEC_ProxyPushConsumer::push (const CORBA::Any& any) 00033 { 00034 // Check if we should proceed at all. 00035 if (this->admin_properties().reject_new_events () == 1 00036 && this->admin_properties().queue_full ()) 00037 throw CORBA::IMP_LIMIT (); 00038 00039 if (this->is_connected () == 0) 00040 { 00041 throw CosEventComm::Disconnected (); 00042 } 00043 00044 TAO_Notify_AnyEvent_No_Copy event (any); 00045 00046 TAO_Notify_Method_Request_Lookup_No_Copy request (&event, this); 00047 00048 this->execute_task (request); 00049 } 00050 00051 void 00052 TAO_Notify_CosEC_ProxyPushConsumer::connect_push_supplier (CosEventComm::PushSupplier_ptr push_supplier) 00053 { 00054 // Convert Supplier to Base Type 00055 TAO_Notify_PushSupplier *supplier; 00056 ACE_NEW_THROW_EX (supplier, 00057 TAO_Notify_PushSupplier (this), 00058 CORBA::NO_MEMORY ()); 00059 00060 supplier->init (push_supplier); 00061 00062 this->connect (supplier); 00063 } 00064 00065 void 00066 TAO_Notify_CosEC_ProxyPushConsumer::disconnect_push_consumer (void) 00067 { 00068 TAO_Notify_CosEC_ProxyPushConsumer::Ptr guard( this ); 00069 this->destroy (); 00070 } 00071 00072 const char * 00073 TAO_Notify_CosEC_ProxyPushConsumer::get_proxy_type_name (void) const 00074 { 00075 return "ec_proxy_push_consumer"; 00076 } 00077 00078 void 00079 TAO_Notify_CosEC_ProxyPushConsumer::validate () 00080 { 00081 TAO_Notify_Supplier* sup = this->supplier (); 00082 if (sup != 0 && ! sup->is_alive (true)) 00083 { 00084 if (TAO_debug_level > 0) 00085 { 00086 ACE_DEBUG ((LM_DEBUG, 00087 ACE_TEXT ("(%P|%t) TAO_Notify_CosEC_ProxyPushConsumer::validate(%d)") 00088 ACE_TEXT ("disconnecting \n"), this->id ())); 00089 } 00090 00091 this->disconnect_push_consumer (); 00092 } 00093 } 00094 00095 void 00096 TAO_Notify_CosEC_ProxyPushConsumer::configure( 00097 TAO_Notify_SupplierAdmin & /*admin*/, 00098 CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/) 00099 { 00100 // Nothing to do. 00101 // This virtual method was added to support Notification MC 00102 } 00103 00104 00105 TAO_END_VERSIONED_NAMESPACE_DECL