00001
00002
00003 #include "orbsvcs/Notify/ConsumerAdmin.h"
00004
00005 ACE_RCSID (RT_Notify,
00006 TAO_Notify_ConsumerAdmin,
00007 "$Id: ConsumerAdmin.cpp 84685 2009-03-02 22:49:17Z mesnier_p $")
00008
00009 #include "orbsvcs/Notify/Subscription_Change_Worker.h"
00010 #include "orbsvcs/Notify/Proxy.h"
00011 #include "orbsvcs/Notify/EventChannel.h"
00012 #include "orbsvcs/Notify/Properties.h"
00013 #include "orbsvcs/Notify/Factory.h"
00014 #include "orbsvcs/Notify/Builder.h"
00015 #include "orbsvcs/Notify/Find_Worker_T.h"
00016 #include "orbsvcs/Notify/Seq_Worker_T.h"
00017 #include "orbsvcs/Notify/ProxySupplier.h"
00018
00019 #include "tao/debug.h"
00020
00021 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00022
00023 #include "ace/Auto_Ptr.h"
00024
00025
00026 #ifndef DEBUG_LEVEL
00027 # define DEBUG_LEVEL TAO_debug_level
00028 #endif //DEBUG_LEVEL
00029
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031
00032 typedef TAO_Notify_Find_Worker_T<TAO_Notify_Proxy
00033 , CosNotifyChannelAdmin::ProxySupplier
00034 , CosNotifyChannelAdmin::ProxySupplier_ptr
00035 , CosNotifyChannelAdmin::ProxyNotFound>
00036 TAO_Notify_ProxySupplier_Find_Worker;
00037
00038 typedef TAO_Notify_Seq_Worker_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Seq_Worker;
00039
00040 TAO_Notify_ConsumerAdmin::TAO_Notify_ConsumerAdmin (void)
00041 : TAO_Notify_Admin ()
00042 {
00043 }
00044
00045 const char *
00046 TAO_Notify_ConsumerAdmin::get_admin_type_name () const
00047 {
00048 return "consumer_admin";
00049 }
00050
00051
00052
00053 TAO_Notify_ConsumerAdmin::~TAO_Notify_ConsumerAdmin ()
00054 {
00055 }
00056
00057 void
00058 TAO_Notify_ConsumerAdmin::init (TAO_Notify_EventChannel *ec)
00059 {
00060 TAO_Notify_Admin::init (ec);
00061
00062 const CosNotification::QoSProperties &default_ca_qos =
00063 TAO_Notify_PROPERTIES::instance ()->default_consumer_admin_qos_properties ();
00064
00065 this->set_qos (default_ca_qos);
00066 }
00067
00068 void
00069 TAO_Notify_ConsumerAdmin::_add_ref (void)
00070 {
00071 this->_incr_refcnt ();
00072 }
00073
00074 void
00075 TAO_Notify_ConsumerAdmin::_remove_ref (void)
00076 {
00077 this->_decr_refcnt ();
00078 }
00079
00080 void
00081 TAO_Notify_ConsumerAdmin::release (void)
00082 {
00083 delete this;
00084
00085 }
00086
00087 void
00088 TAO_Notify_ConsumerAdmin::destroy (void)
00089 {
00090 this->shutdown ();
00091 this->ec_->remove (this);
00092 this->proxy_container ().destroy ();
00093 }
00094
00095
00096 TAO_Notify::Topology_Object*
00097 TAO_Notify_ConsumerAdmin::load_child (const ACE_CString &type,
00098 CORBA::Long id, const TAO_Notify::NVPList& attrs)
00099 {
00100 TAO_Notify::Topology_Object* result = this;
00101 if (type == "proxy_push_supplier")
00102 {
00103 if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00104 ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00105 , static_cast<int> (id)
00106 ));
00107 result = this->load_proxy(id, CosNotifyChannelAdmin::ANY_EVENT, attrs);
00108 }
00109 else if (type == "structured_proxy_push_supplier")
00110 {
00111 if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00112 ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00113 , static_cast<int> (id)
00114 ));
00115 result = this->load_proxy(id, CosNotifyChannelAdmin::STRUCTURED_EVENT, attrs);
00116 }
00117 else if (type == "sequence_proxy_push_supplier")
00118 {
00119 if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00120 ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00121 , static_cast<int> (id)
00122 ));
00123 result = this->load_proxy(id, CosNotifyChannelAdmin::SEQUENCE_EVENT, attrs);
00124 }
00125 #if 0
00126 else if (type == "ec_proxy_push_supplier")
00127 {
00128 if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00129 ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00130 , static_cast<int> (id)
00131 ));
00132 result = this->load_proxy(id, attrs);
00133 }
00134 #endif
00135 else
00136 {
00137 result = TAO_Notify_Admin::load_child (type, id, attrs);
00138 }
00139 return result;
00140 }
00141
00142 TAO_Notify::Topology_Object*
00143 TAO_Notify_ConsumerAdmin::load_proxy (
00144 CORBA::Long id,
00145 CosNotifyChannelAdmin::ClientType ctype,
00146 const TAO_Notify::NVPList& attrs)
00147 {
00148 TAO_Notify_Builder* bld = TAO_Notify_PROPERTIES::instance()->builder();
00149 TAO_Notify_ProxySupplier * proxy =
00150 bld->build_proxy (this
00151 , ctype
00152 , id);
00153 ACE_ASSERT(proxy != 0);
00154 proxy->load_attrs (attrs);
00155 return proxy;
00156 }
00157
00158 CosNotifyChannelAdmin::ProxySupplier_ptr
00159 TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype,
00160 CosNotifyChannelAdmin::ProxyID_out proxy_id
00161 )
00162 {
00163 CosNotification::QoSProperties initial_qos;
00164
00165 CosNotifyChannelAdmin::ProxySupplier_var proxy =
00166 TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00167 , ctype
00168 , proxy_id
00169 , initial_qos);
00170 this->self_change ();
00171 return proxy._retn ();
00172 }
00173
00174 CosNotifyChannelAdmin::ProxySupplier_ptr
00175 TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier_with_qos (CosNotifyChannelAdmin::ClientType ctype,
00176 CosNotifyChannelAdmin::ProxyID_out proxy_id,
00177 const CosNotification::QoSProperties & initial_qos
00178 )
00179 {
00180 CosNotifyChannelAdmin::ProxySupplier_var proxy =
00181 TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00182 , ctype
00183 , proxy_id
00184 , initial_qos);
00185 this->self_change ();
00186 return proxy._retn ();
00187 }
00188
00189 CosEventChannelAdmin::ProxyPushSupplier_ptr
00190 TAO_Notify_ConsumerAdmin::obtain_push_supplier (void)
00191 {
00192 CosEventChannelAdmin::ProxyPushSupplier_var proxy =
00193 TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this);
00194 this->self_change ();
00195 return proxy._retn ();
00196 }
00197
00198 CosNotifyChannelAdmin::AdminID
00199 TAO_Notify_ConsumerAdmin::MyID (void)
00200 {
00201 return this->id ();
00202 }
00203
00204 CosNotifyChannelAdmin::EventChannel_ptr
00205 TAO_Notify_ConsumerAdmin::MyChannel (void)
00206 {
00207 return this->ec_->_this ();
00208 }
00209
00210 ::CosNotifyChannelAdmin::InterFilterGroupOperator
00211 TAO_Notify_ConsumerAdmin::MyOperator (void)
00212 {
00213 return this->filter_operator_;
00214 }
00215
00216 CosNotifyChannelAdmin::ProxyIDSeq*
00217 TAO_Notify_ConsumerAdmin::push_suppliers (void)
00218 {
00219 TAO_Notify_Proxy_Seq_Worker seq_worker;
00220
00221 return seq_worker.create (this->proxy_container());
00222 }
00223
00224 CosNotifyChannelAdmin::ProxySupplier_ptr
00225 TAO_Notify_ConsumerAdmin::get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id)
00226 {
00227 TAO_Notify_ProxySupplier_Find_Worker find_worker;
00228
00229 return find_worker.resolve (proxy_id, this->proxy_container());
00230 }
00231
00232 void TAO_Notify_ConsumerAdmin::set_qos (const CosNotification::QoSProperties & qos)
00233 {
00234 this->TAO_Notify_Object::set_qos (qos);
00235 }
00236
00237
00238 CosNotification::QoSProperties*
00239 TAO_Notify_ConsumerAdmin::get_qos (void)
00240 {
00241 return this->TAO_Notify_Object::get_qos ();
00242 }
00243
00244 void
00245 TAO_Notify_ConsumerAdmin::subscription_change (const CosNotification::EventTypeSeq & added,
00246 const CosNotification::EventTypeSeq & removed
00247 )
00248 {
00249 TAO_Notify_EventTypeSeq seq_added (added);
00250 TAO_Notify_EventTypeSeq seq_removed (removed);
00251
00252 {
00253 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00254 CORBA::INTERNAL ());
00255
00256 this->subscribed_types_.add_and_remove (seq_added, seq_removed);
00257
00258 TAO_Notify_Subscription_Change_Worker worker (added, removed);
00259
00260 this->proxy_container().collection()->for_each (&worker);
00261 }
00262 this->self_change ();
00263 }
00264
00265 CosNotifyFilter::FilterID
00266 TAO_Notify_ConsumerAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter)
00267 {
00268 CosNotifyFilter::FilterID fid =
00269 this->filter_admin_.add_filter (new_filter);
00270 this->self_change ();
00271 return fid;
00272 }
00273
00274 void
00275 TAO_Notify_ConsumerAdmin::remove_filter (CosNotifyFilter::FilterID filter)
00276 {
00277 this->filter_admin_.remove_filter (filter);
00278 }
00279
00280 ::CosNotifyFilter::Filter_ptr
00281 TAO_Notify_ConsumerAdmin::get_filter (CosNotifyFilter::FilterID filter)
00282 {
00283 return this->filter_admin_.get_filter (filter);
00284 }
00285
00286 ::CosNotifyFilter::FilterIDSeq*
00287 TAO_Notify_ConsumerAdmin::get_all_filters (void)
00288 {
00289 return this->filter_admin_.get_all_filters ();
00290 }
00291
00292 void
00293 TAO_Notify_ConsumerAdmin::remove_all_filters (void)
00294 {
00295 this->filter_admin_.remove_all_filters ();
00296 }
00297
00298
00299
00300 CosNotifyFilter::MappingFilter_ptr
00301 TAO_Notify_ConsumerAdmin::priority_filter (void)
00302 {
00303 throw CORBA::NO_IMPLEMENT ();
00304 }
00305
00306 void
00307 TAO_Notify_ConsumerAdmin::priority_filter (CosNotifyFilter::MappingFilter_ptr )
00308
00309 {
00310 throw CORBA::NO_IMPLEMENT ();
00311 }
00312
00313 CosNotifyFilter::MappingFilter_ptr
00314 TAO_Notify_ConsumerAdmin::lifetime_filter (void)
00315
00316 {
00317 throw CORBA::NO_IMPLEMENT ();
00318 }
00319
00320 void
00321 TAO_Notify_ConsumerAdmin::lifetime_filter (CosNotifyFilter::MappingFilter_ptr )
00322 {
00323 throw CORBA::NO_IMPLEMENT ();
00324 }
00325
00326 ::CosNotifyChannelAdmin::ProxyIDSeq*
00327 TAO_Notify_ConsumerAdmin::pull_suppliers (void)
00328 {
00329 throw CORBA::NO_IMPLEMENT ();
00330 }
00331
00332 CosNotifyChannelAdmin::ProxySupplier_ptr
00333 TAO_Notify_ConsumerAdmin::obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType ,
00334 CosNotifyChannelAdmin::ProxyID_out )
00335
00336 {
00337 throw CORBA::NO_IMPLEMENT ();
00338 }
00339
00340 void
00341 TAO_Notify_ConsumerAdmin::validate_qos (const CosNotification::QoSProperties & ,
00342 CosNotification::NamedPropertyRangeSeq_out
00343 )
00344 {
00345 throw CORBA::NO_IMPLEMENT ();
00346 }
00347
00348 CosEventChannelAdmin::ProxyPullSupplier_ptr
00349 TAO_Notify_ConsumerAdmin::obtain_pull_supplier (void)
00350 {
00351 throw CORBA::NO_IMPLEMENT ();
00352 }
00353
00354 TAO_Notify_ProxySupplier *
00355 TAO_Notify_ConsumerAdmin::find_proxy_supplier (
00356 TAO_Notify::IdVec & id_path,
00357 size_t position)
00358 {
00359 TAO_Notify_ProxySupplier * result = 0;
00360 size_t path_size = id_path.size ();
00361 if (position < path_size)
00362 {
00363 TAO_Notify_ProxySupplier_Find_Worker find_worker;
00364 TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container());
00365 result = dynamic_cast <TAO_Notify_ProxySupplier *> (proxy);
00366 }
00367 return result;
00368 }
00369
00370 TAO_END_VERSIONED_NAMESPACE_DECL