00001 // StructuredPushConsumer.cpp,v 1.16 2006/03/15 21:29:10 jtc Exp 00002 #include "orbsvcs/Notify/Structured/StructuredPushConsumer.h" 00003 00004 ACE_RCSID(RT_Notify, TAO_Notify_StructuredPushConsumer, "StructuredPushConsumer.cpp,v 1.16 2006/03/15 21:29:10 jtc Exp") 00005 00006 #include "orbsvcs/Notify/Properties.h" 00007 #include "orbsvcs/Notify/Event.h" 00008 #include "ace/Bound_Ptr.h" 00009 00010 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00011 00012 TAO_Notify_StructuredPushConsumer::TAO_Notify_StructuredPushConsumer (TAO_Notify_ProxySupplier* proxy) 00013 :TAO_Notify_Consumer (proxy) 00014 { 00015 } 00016 00017 TAO_Notify_StructuredPushConsumer::~TAO_Notify_StructuredPushConsumer () 00018 { 00019 } 00020 00021 void 00022 TAO_Notify_StructuredPushConsumer::init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) 00023 { 00024 // Initialize only once 00025 ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) ); 00026 00027 if (CORBA::is_nil (push_consumer)) 00028 { 00029 ACE_THROW (CORBA::BAD_PARAM()); 00030 } 00031 00032 this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer); 00033 00034 this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer); 00035 00036 } 00037 00038 void 00039 TAO_Notify_StructuredPushConsumer::release (void) 00040 { 00041 delete this; 00042 //@@ inform factory 00043 } 00044 00045 void 00046 TAO_Notify_StructuredPushConsumer::push (const CORBA::Any& event ACE_ENV_ARG_DECL) 00047 { 00048 CosNotification::StructuredEvent notification; 00049 00050 TAO_Notify_Event::translate (event, notification); 00051 00052 this->push_consumer_->push_structured_event (notification ACE_ENV_ARG_PARAMETER); 00053 } 00054 00055 void 00056 TAO_Notify_StructuredPushConsumer::push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) 00057 { 00058 this->push_consumer_->push_structured_event (event ACE_ENV_ARG_PARAMETER); 00059 } 00060 00061 /// Push a batch of events to this consumer. 00062 void 00063 TAO_Notify_StructuredPushConsumer::push (const CosNotification::EventBatch& event ACE_ENV_ARG_DECL_NOT_USED) 00064 { 00065 ACE_ASSERT(false); 00066 ACE_UNUSED_ARG (event); 00067 // TODO exception? 00068 } 00069 00070 void 00071 TAO_Notify_StructuredPushConsumer::reconnect_from_consumer (TAO_Notify_Consumer* old_consumer 00072 ACE_ENV_ARG_DECL) 00073 { 00074 TAO_Notify_StructuredPushConsumer* tmp = dynamic_cast<TAO_Notify_StructuredPushConsumer *> (old_consumer); 00075 ACE_ASSERT(tmp != 0); 00076 this->init(tmp->push_consumer_.in() ACE_ENV_ARG_PARAMETER); 00077 ACE_CHECK; 00078 this->schedule_timer(false); 00079 } 00080 00081 ACE_CString 00082 TAO_Notify_StructuredPushConsumer::get_ior (void) const 00083 { 00084 ACE_CString result; 00085 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00086 ACE_DECLARE_NEW_CORBA_ENV; 00087 ACE_TRY 00088 { 00089 CORBA::String_var ior = orb->object_to_string(this->push_consumer_.in() ACE_ENV_ARG_PARAMETER); 00090 ACE_TRY_CHECK; 00091 result = static_cast<const char*> (ior.in ()); 00092 } 00093 ACE_CATCHANY 00094 { 00095 result.fast_clear(); 00096 } 00097 ACE_ENDTRY; 00098 return result; 00099 } 00100 00101 TAO_END_VERSIONED_NAMESPACE_DECL