PushConsumer.cpp

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

Generated on Thu Nov 9 13:24:14 2006 for TAO_CosNotification by doxygen 1.3.6