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 79750 2007-10-04 19:07:26Z johnc $")
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 const CosNotification::QoSProperties &default_ps_qos =
00041 TAO_Notify_PROPERTIES::instance ()->default_proxy_supplier_qos_properties ();
00042
00043 {
00044 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00045 CORBA::INTERNAL ());
00046 this->TAO_Notify_Object::set_qos (default_ps_qos);
00047 }
00048 }
00049
00050 TAO_Notify_Peer*
00051 TAO_Notify_ProxySupplier:: peer (void)
00052 {
00053 return this->consumer ();
00054 }
00055
00056 void
00057 TAO_Notify_ProxySupplier::connect (TAO_Notify_Consumer *consumer)
00058 {
00059
00060 ACE_Auto_Ptr< TAO_Notify_Consumer > auto_consumer (consumer);
00061
00062 TAO_Notify_Atomic_Property_Long& consumer_count = this->admin_properties().consumers ();
00063 const TAO_Notify_Property_Long& max_consumers = this->admin_properties().max_consumers ();
00064
00065 if (max_consumers != 0 && consumer_count >= max_consumers.value ())
00066 {
00067 throw CORBA::IMP_LIMIT (
00068 );
00069 }
00070
00071 {
00072 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00073 CORBA::INTERNAL ());
00074
00075
00076 if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false)
00077 {
00078 throw CosEventChannelAdmin::AlreadyConnected ();
00079 }
00080
00081
00082 if (this->consumer_.get() != 0)
00083 auto_consumer->assume_pending_events (*this->consumer_.get ());
00084 this->consumer_ = auto_consumer;
00085
00086 this->consumer_admin_->subscribed_types (this->subscribed_types_);
00087 }
00088
00089
00090 ACE_ASSERT (this->consumer_.get() != 0);
00091 this->consumer_->qos_changed (this->qos_properties_);
00092
00093 TAO_Notify_EventTypeSeq removed;
00094
00095 this->event_manager().subscription_change (this, this->subscribed_types_, removed);
00096
00097 this->event_manager().connect (this);
00098
00099
00100 ++consumer_count;
00101 }
00102
00103 void
00104 TAO_Notify_ProxySupplier::disconnect (void)
00105 {
00106 TAO_Notify_EventTypeSeq added;
00107
00108 this->event_manager().subscription_change (this, added, this->subscribed_types_);
00109
00110 this->event_manager().disconnect (this);
00111
00112
00113 this->admin_properties().consumers ()--;
00114 }
00115
00116 int
00117 TAO_Notify_ProxySupplier::shutdown (void)
00118 {
00119 if (this->TAO_Notify_Object::shutdown () == 1)
00120 return 1;
00121
00122
00123 this->disconnect ();
00124
00125 if (this->consumer_.get() != 0)
00126 {
00127 this->consumer_->shutdown ();
00128 }
00129 return 0;
00130 }
00131
00132 void
00133 TAO_Notify_ProxySupplier::destroy (void)
00134 {
00135 this->shutdown ();
00136 this->consumer_admin_->cleanup_proxy (this, true);
00137
00138
00139
00140 }
00141
00142 void
00143 TAO_Notify_ProxySupplier::deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request)
00144 {
00145 this->execute_task (request);
00146 }
00147
00148 void
00149 TAO_Notify_ProxySupplier::qos_changed (const TAO_Notify_QoSProperties& qos_properties)
00150 {
00151 TAO_Notify_Proxy::qos_changed (qos_properties);
00152 }
00153
00154 TAO_END_VERSIONED_NAMESPACE_DECL