Go to the documentation of this file.00001
00002
00003 #include "orbsvcs/Notify/ProxySupplier.h"
00004
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/ProxySupplier.inl"
00007 #endif
00008
00009 ACE_RCSID(Notify, TAO_Notify_ProxySupplier, "$Id: ProxySupplier.cpp 90935 2010-06-29 13:22:03Z johnnyw $")
00010
00011 #include "orbsvcs/Notify/Event_Manager.h"
00012 #include "orbsvcs/Notify/AdminProperties.h"
00013 #include "orbsvcs/Notify/Consumer.h"
00014 #include "orbsvcs/Notify/Method_Request_Dispatch.h"
00015 #include "orbsvcs/Notify/Worker_Task.h"
00016 #include "orbsvcs/Notify/Buffering_Strategy.h"
00017 #include "orbsvcs/Notify/Properties.h"
00018 #include "orbsvcs/Notify/ConsumerAdmin.h"
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 TAO_Notify_ProxySupplier::TAO_Notify_ProxySupplier (void)
00023 : consumer_admin_ (0)
00024 {
00025 }
00026
00027 TAO_Notify_ProxySupplier::~TAO_Notify_ProxySupplier ()
00028 {
00029 }
00030
00031 void
00032 TAO_Notify_ProxySupplier::init (TAO_Notify_ConsumerAdmin* consumer_admin)
00033 {
00034 ACE_ASSERT (consumer_admin != 0 && this->consumer_admin_.get() == 0);
00035
00036 TAO_Notify_Proxy::initialize (consumer_admin);
00037
00038 this->consumer_admin_.reset (consumer_admin);
00039
00040 this->filter_admin_.event_channel (
00041 this->consumer_admin_->event_channel());
00042
00043 const CosNotification::QoSProperties &default_ps_qos =
00044 TAO_Notify_PROPERTIES::instance ()->default_proxy_supplier_qos_properties ();
00045
00046 {
00047 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00048 CORBA::INTERNAL ());
00049 this->TAO_Notify_Object::set_qos (default_ps_qos);
00050 }
00051 }
00052
00053 TAO_Notify_Peer*
00054 TAO_Notify_ProxySupplier:: peer (void)
00055 {
00056 return this->consumer ();
00057 }
00058
00059 void
00060 TAO_Notify_ProxySupplier::connect (TAO_Notify_Consumer *consumer)
00061 {
00062
00063 TAO_Notify_Consumer::Ptr auto_consumer (consumer);
00064
00065 TAO_Notify_Atomic_Property_Long& consumer_count = this->admin_properties().consumers ();
00066 const TAO_Notify_Property_Long& max_consumers = this->admin_properties().max_consumers ();
00067
00068 if (max_consumers != 0 && consumer_count >= max_consumers.value ())
00069 {
00070 throw CORBA::IMP_LIMIT ();
00071 }
00072
00073 {
00074 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00075 CORBA::INTERNAL ());
00076
00077
00078 if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false)
00079 {
00080 throw CosEventChannelAdmin::AlreadyConnected ();
00081 }
00082
00083
00084 if (this->consumer_.get() != 0)
00085 auto_consumer->assume_pending_events (*this->consumer_.get ());
00086 this->consumer_ = auto_consumer;
00087
00088 this->consumer_admin_->subscribed_types (this->subscribed_types_);
00089 }
00090
00091
00092 ACE_ASSERT (this->consumer_.get() != 0);
00093 this->consumer_->qos_changed (this->qos_properties_);
00094
00095 TAO_Notify_EventTypeSeq removed;
00096
00097 this->event_manager().subscription_change (this, this->subscribed_types_, removed);
00098
00099 this->event_manager().connect (this);
00100
00101
00102 ++consumer_count;
00103 }
00104
00105 void
00106 TAO_Notify_ProxySupplier::disconnect (void)
00107 {
00108 TAO_Notify_EventTypeSeq added;
00109
00110 this->event_manager().subscription_change (this, added, this->subscribed_types_);
00111
00112 this->event_manager().disconnect (this);
00113
00114
00115 this->admin_properties().consumers ()--;
00116 }
00117
00118 int
00119 TAO_Notify_ProxySupplier::shutdown (void)
00120 {
00121 if (this->TAO_Notify_Object::shutdown () == 1)
00122 return 1;
00123
00124
00125 this->disconnect ();
00126
00127 if (this->consumer_.get() != 0)
00128 {
00129 this->consumer_->shutdown ();
00130 }
00131 return 0;
00132 }
00133
00134 void
00135 TAO_Notify_ProxySupplier::destroy (void)
00136 {
00137 this->destroy (false);
00138 }
00139
00140 void
00141 TAO_Notify_ProxySupplier::destroy (bool from_timeout)
00142 {
00143 this->shutdown ();
00144 this->consumer_admin_->cleanup_proxy (this, true, from_timeout);
00145
00146
00147
00148 }
00149
00150 void
00151 TAO_Notify_ProxySupplier::deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request)
00152 {
00153 this->execute_task (request);
00154 }
00155
00156 void
00157 TAO_Notify_ProxySupplier::qos_changed (const TAO_Notify_QoSProperties& qos_properties)
00158 {
00159 TAO_Notify_Proxy::qos_changed (qos_properties);
00160 }
00161
00162 TAO_END_VERSIONED_NAMESPACE_DECL