StructuredPushConsumer.cpp

Go to the documentation of this file.
00001 // $Id: StructuredPushConsumer.cpp 76626 2007-01-26 13:50:03Z elliott_c $
00002 #include "orbsvcs/Notify/Structured/StructuredPushConsumer.h"
00003 
00004 ACE_RCSID(RT_Notify, TAO_Notify_StructuredPushConsumer, "$Id: StructuredPushConsumer.cpp 76626 2007-01-26 13:50:03Z elliott_c $")
00005 
00006 #include "ace/Bound_Ptr.h"
00007 #include "tao/Stub.h" // For debug messages printing out ORBid.
00008 #include "tao/ORB_Core.h"
00009 #include "orbsvcs/Notify/Properties.h"
00010 #include "orbsvcs/Notify/Event.h"
00011 
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 TAO_Notify_StructuredPushConsumer::TAO_Notify_StructuredPushConsumer (TAO_Notify_ProxySupplier* proxy)
00015   :TAO_Notify_Consumer (proxy)
00016 {
00017 }
00018 
00019 TAO_Notify_StructuredPushConsumer::~TAO_Notify_StructuredPushConsumer ()
00020 {
00021 }
00022 
00023 void
00024 TAO_Notify_StructuredPushConsumer::init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer)
00025 {
00026   // Initialize only once
00027   ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) );
00028 
00029   if (CORBA::is_nil (push_consumer))
00030   {
00031     throw CORBA::BAD_PARAM();
00032   }
00033 
00034   if (!TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb ())
00035     {
00036       this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer);
00037       this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer);
00038     }
00039   else
00040     {
00041       // "Port" consumer's object reference from receiving ORB to dispatching ORB.
00042       CORBA::String_var temp =
00043         TAO_Notify_PROPERTIES::instance()->orb()->object_to_string(push_consumer);
00044 
00045       CORBA::Object_var obj =
00046         TAO_Notify_PROPERTIES::instance()->dispatching_orb()->string_to_object(temp.in());
00047 
00048       try
00049         {
00050           CosNotifyComm::StructuredPushConsumer_var new_push_consumer =
00051             CosNotifyComm::StructuredPushConsumer::_unchecked_narrow(obj.in());
00052 
00053           this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (new_push_consumer.in());
00054           this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (new_push_consumer.in());
00055           //--cj verify dispatching ORB
00056           if (TAO_debug_level >= 10)
00057             {
00058               ACE_DEBUG ((LM_DEBUG,
00059                           "(%P|%t) Structured push init dispatching ORB id is %s.\n",
00060                           obj->_stubobj()->orb_core()->orbid()));
00061           }
00062           //--cj end
00063         }
00064       catch (const CORBA::TRANSIENT& ex)
00065         {
00066           ex._tao_print_exception (
00067             "Got a TRANSIENT in NS_StructuredPushConsumer::init");
00068           ACE_DEBUG ((LM_DEBUG, "(%P|%t) got it for NS_StructuredPushConsumer %@\n", this));
00069         }
00070       catch (const CORBA::Exception&)
00071         {
00072           // _narrow failed
00073         }
00074     }
00075 }
00076 
00077 void
00078 TAO_Notify_StructuredPushConsumer::release (void)
00079 {
00080   delete this;
00081   //@@ inform factory
00082 }
00083 
00084 void
00085 TAO_Notify_StructuredPushConsumer::push (const CORBA::Any& event)
00086 {
00087   CosNotification::StructuredEvent notification;
00088 
00089   TAO_Notify_Event::translate (event, notification);
00090 
00091   this->push_consumer_->push_structured_event (notification);
00092 }
00093 
00094 void
00095 TAO_Notify_StructuredPushConsumer::push (const CosNotification::StructuredEvent& event)
00096 {
00097   //--cj verify dispatching ORB
00098   if (TAO_debug_level >= 10) {
00099     ACE_DEBUG ((LM_DEBUG, "(%P|%t) Structured push dispatching ORB id is %s.\n",
00100                 this->push_consumer_->_stubobj()->orb_core()->orbid()));
00101   }
00102   //--cj end
00103 
00104   this->push_consumer_->push_structured_event (event);
00105 }
00106 
00107 /// Push a batch of events to this consumer.
00108 void
00109 TAO_Notify_StructuredPushConsumer::push (const CosNotification::EventBatch& event)
00110 {
00111   ACE_ASSERT(false);
00112   ACE_UNUSED_ARG (event);
00113   // TODO exception?
00114 }
00115 
00116 void
00117 TAO_Notify_StructuredPushConsumer::reconnect_from_consumer (TAO_Notify_Consumer* old_consumer)
00118 {
00119   TAO_Notify_StructuredPushConsumer* tmp = dynamic_cast<TAO_Notify_StructuredPushConsumer *> (old_consumer);
00120   ACE_ASSERT(tmp != 0);
00121   this->init(tmp->push_consumer_.in());
00122   this->schedule_timer(false);
00123 }
00124 
00125 ACE_CString
00126 TAO_Notify_StructuredPushConsumer::get_ior (void) const
00127 {
00128   ACE_CString result;
00129   CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
00130   try
00131   {
00132     CORBA::String_var ior = orb->object_to_string(this->push_consumer_.in());
00133     result = static_cast<const char*> (ior.in ());
00134   }
00135   catch (const CORBA::Exception&)
00136   {
00137     result.fast_clear();
00138   }
00139   return result;
00140 }
00141 
00142 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7