ProxyPushConsumer.cpp

Go to the documentation of this file.
00001 // ProxyPushConsumer.cpp,v 1.19 2006/03/15 21:29:09 jtc Exp
00002 
00003 #include "orbsvcs/Notify/Any/ProxyPushConsumer.h"
00004 
00005 ACE_RCSID (Notify, TAO_Notify_ProxyPushConsumer, "ProxyPushConsumer.cpp,v 1.19 2006/03/15 21:29:09 jtc Exp")
00006 
00007 #include "tao/debug.h"
00008 #include "orbsvcs/Notify/AdminProperties.h"
00009 #include "orbsvcs/Notify/Properties.h"
00010 #include "orbsvcs/Notify/Any/AnyEvent.h"
00011 #include "orbsvcs/Notify/Any/PushSupplier.h"
00012 
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 TAO_Notify_ProxyPushConsumer::TAO_Notify_ProxyPushConsumer (void)
00016 {
00017 }
00018 
00019 TAO_Notify_ProxyPushConsumer::~TAO_Notify_ProxyPushConsumer ()
00020 {
00021 }
00022 
00023 void
00024 TAO_Notify_ProxyPushConsumer::release (void)
00025 {
00026   delete this;
00027   //@@ inform factory
00028 }
00029 
00030 CosNotifyChannelAdmin::ProxyType
00031 TAO_Notify_ProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00032   ACE_THROW_SPEC ((
00033                    CORBA::SystemException
00034                    ))
00035 {
00036   return CosNotifyChannelAdmin::PUSH_ANY;
00037 }
00038 
00039 void
00040 TAO_Notify_ProxyPushConsumer::push (const CORBA::Any& any ACE_ENV_ARG_DECL)
00041   ACE_THROW_SPEC ((
00042                    CORBA::SystemException
00043                    , CosEventComm::Disconnected
00044                    ))
00045 {
00046   // Check if we should proceed at all.
00047   if (this->admin_properties().reject_new_events () == 1
00048       && this->admin_properties().queue_full ())
00049     ACE_THROW (CORBA::IMP_LIMIT ());
00050 
00051   if (this->is_connected () == 0)
00052     {
00053       ACE_THROW (CosEventComm::Disconnected ());
00054     }
00055 
00056   TAO_Notify_AnyEvent_No_Copy event (any);
00057   this->push_i (&event ACE_ENV_ARG_PARAMETER);
00058 }
00059 
00060 void
00061 TAO_Notify_ProxyPushConsumer::connect_any_push_supplier (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL)
00062   ACE_THROW_SPEC ((
00063                    CORBA::SystemException
00064                    , CosEventChannelAdmin::AlreadyConnected
00065                    ))
00066 {
00067   // Convert Supplier to Base Type
00068   TAO_Notify_PushSupplier *supplier;
00069   ACE_NEW_THROW_EX (supplier,
00070                     TAO_Notify_PushSupplier (this),
00071                     CORBA::NO_MEMORY ());
00072 
00073   supplier->init (push_supplier ACE_ENV_ARG_PARAMETER);
00074   ACE_CHECK;
00075 
00076   this->connect (supplier ACE_ENV_ARG_PARAMETER);
00077   ACE_CHECK;
00078   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00079 }
00080 
00081 void TAO_Notify_ProxyPushConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL)
00082   ACE_THROW_SPEC ((
00083                    CORBA::SystemException
00084                    ))
00085 {
00086   TAO_Notify_ProxyPushConsumer::Ptr guard( this );
00087   this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00088   ACE_CHECK;
00089   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00090 }
00091 
00092 const char *
00093 TAO_Notify_ProxyPushConsumer::get_proxy_type_name (void) const
00094 {
00095   return "proxy_push_consumer";
00096 }
00097 
00098 void
00099 TAO_Notify_ProxyPushConsumer::load_attrs (const TAO_Notify::NVPList& attrs)
00100 {
00101   SuperClass::load_attrs(attrs);
00102   ACE_CString ior;
00103   if (attrs.load("PeerIOR", ior))
00104     {
00105       CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
00106       ACE_DECLARE_NEW_CORBA_ENV;
00107       ACE_TRY
00108         {
00109           ACE_TRY_CHECK;
00110           CosNotifyComm::PushSupplier_var ps = CosNotifyComm::PushSupplier::_nil();
00111           if ( ior.length() > 0 )
00112             {
00113               CORBA::Object_var obj =
00114                 orb->string_to_object(ior.c_str() ACE_ENV_ARG_PARAMETER);
00115               ACE_TRY_CHECK;
00116               ps = CosNotifyComm::PushSupplier::_unchecked_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
00117               ACE_TRY_CHECK;
00118             }
00119           // minor hack: suppress generating subscription updates during reload.
00120           bool save_updates = this->updates_off_;
00121           this->updates_off_ = true;
00122           this->connect_any_push_supplier(ps.in() ACE_ENV_ARG_PARAMETER);
00123           ACE_TRY_CHECK;
00124           this->updates_off_ = save_updates;
00125         }
00126       ACE_CATCHALL
00127         {
00128           ACE_ASSERT(0);
00129         }
00130       ACE_ENDTRY;
00131     }
00132 }
00133 
00134 TAO_END_VERSIONED_NAMESPACE_DECL

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