StructuredProxyPushConsumer.cpp

Go to the documentation of this file.
00001 // $Id: StructuredProxyPushConsumer.cpp 78955 2007-07-19 15:15:34Z zhangw $
00002 
00003 #include "orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h"
00004 
00005 ACE_RCSID(RT_Notify, TAO_Notify_StructuredProxyPushConsumer, "$Id: StructuredProxyPushConsumer.cpp 78955 2007-07-19 15:15:34Z zhangw $")
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::load_attrs (const TAO_Notify::NVPList& attrs)
00085 {
00086   SuperClass::load_attrs(attrs);
00087   ACE_CString ior;
00088   if (attrs.load("PeerIOR", ior))
00089   {
00090     CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
00091     try
00092     {
00093       CosNotifyComm::StructuredPushSupplier_var ps = CosNotifyComm::StructuredPushSupplier::_nil();
00094       if ( ior.length() > 0 )
00095       {
00096         CORBA::Object_var obj = orb->string_to_object(ior.c_str());
00097         ps = CosNotifyComm::StructuredPushSupplier::_unchecked_narrow(obj.in());
00098       }
00099       // minor hack: suppress generating subscription updates during reload.
00100       bool save_updates = this->updates_off_;
00101       this->updates_off_ = true;
00102       this->connect_structured_push_supplier(ps.in());
00103       this->updates_off_ = save_updates;
00104     }
00105     catch (const CORBA::Exception&)
00106     {
00107       // if we can't reconnect to peer, tough...
00108     }
00109   }
00110 }
00111 
00112 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 15:40:01 2008 for TAO_CosNotification by doxygen 1.3.6