ConsumerAdmin.cpp

Go to the documentation of this file.
00001 // ConsumerAdmin.cpp,v 1.23 2006/03/14 06:14:34 jtc Exp
00002 
00003 #include "orbsvcs/Notify/ConsumerAdmin.h"
00004 
00005 ACE_RCSID (RT_Notify,
00006            TAO_Notify_ConsumerAdmin,
00007            "ConsumerAdmin.cpp,v 1.23 2006/03/14 06:14:34 jtc Exp")
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 //#define DEBUG_LEVEL 9
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 ACE_ENV_ARG_DECL)
00059 {
00060   TAO_Notify_Admin::init (ec ACE_ENV_ARG_PARAMETER);
00061   ACE_CHECK;
00062 
00063   const CosNotification::QoSProperties &default_ca_qos =
00064     TAO_Notify_PROPERTIES::instance ()->default_consumer_admin_qos_properties ();
00065 
00066   this->set_qos (default_ca_qos ACE_ENV_ARG_PARAMETER);
00067   ACE_CHECK;
00068 }
00069 
00070 void
00071 TAO_Notify_ConsumerAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00072 {
00073   this->_incr_refcnt ();
00074 }
00075 
00076 void
00077 TAO_Notify_ConsumerAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00078 {
00079   this->_decr_refcnt ();
00080 }
00081 
00082 void
00083 TAO_Notify_ConsumerAdmin::release (void)
00084 {
00085   delete this;
00086   //@@ inform factory
00087 }
00088 
00089 void
00090 TAO_Notify_ConsumerAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL)
00091   ACE_THROW_SPEC ((
00092                    CORBA::SystemException
00093                    ))
00094 {
00095   int result = this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
00096   ACE_CHECK;
00097   if ( result == 1)
00098     return;
00099 
00100   this->ec_->remove (this ACE_ENV_ARG_PARAMETER);
00101   ACE_CHECK;
00102 }
00103 
00104 
00105 TAO_Notify::Topology_Object*
00106 TAO_Notify_ConsumerAdmin::load_child (const ACE_CString &type,
00107   CORBA::Long id, const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL)
00108 {
00109   TAO_Notify::Topology_Object* result = this;
00110   if (type == "proxy_push_supplier")
00111   {
00112     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00113       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00114       , static_cast<int> (id)
00115       ));
00116     result = this->load_proxy(id, CosNotifyChannelAdmin::ANY_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00117     ACE_CHECK_RETURN (0);
00118   }
00119   else if (type == "structured_proxy_push_supplier")
00120   {
00121     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00122       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00123       , static_cast<int> (id)
00124       ));
00125     result = this->load_proxy(id, CosNotifyChannelAdmin::STRUCTURED_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00126     ACE_CHECK_RETURN (0);
00127   }
00128   else if (type == "sequence_proxy_push_supplier")
00129   {
00130     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00131       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00132       , static_cast<int> (id)
00133       ));
00134     result = this->load_proxy(id, CosNotifyChannelAdmin::SEQUENCE_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00135     ACE_CHECK_RETURN (0);
00136   }
00137 #if 0
00138   else if (type == "ec_proxy_push_supplier")
00139   {
00140     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00141       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00142       , static_cast<int> (id)
00143       ));
00144     result = this->load_proxy(id, attrs ACE_ENV_ARG_PARAMETER);
00145     ACE_CHECK_RETURN (0);
00146   }
00147 #endif
00148   else
00149   {
00150     result = TAO_Notify_Admin::load_child (type, id, attrs ACE_ENV_ARG_PARAMETER);
00151     ACE_CHECK_RETURN (0);
00152   }
00153   return result;
00154 }
00155 
00156 TAO_Notify::Topology_Object*
00157 TAO_Notify_ConsumerAdmin::load_proxy (
00158   CORBA::Long id,
00159   CosNotifyChannelAdmin::ClientType ctype,
00160   const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL)
00161 {
00162   TAO_Notify_Builder* bld = TAO_Notify_PROPERTIES::instance()->builder();
00163   TAO_Notify_ProxySupplier * proxy =
00164     bld->build_proxy (this
00165                , ctype
00166                , id
00167                ACE_ENV_ARG_PARAMETER);
00168   ACE_CHECK_RETURN(0);
00169   ACE_ASSERT(proxy != 0);
00170   proxy->load_attrs (attrs);
00171   return proxy;
00172 }
00173 
00174 CosNotifyChannelAdmin::ProxySupplier_ptr
00175 TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype,
00176                                                          CosNotifyChannelAdmin::ProxyID_out proxy_id
00177                                                          ACE_ENV_ARG_DECL
00178                                                          )
00179   ACE_THROW_SPEC ((
00180                    CORBA::SystemException
00181                    , CosNotifyChannelAdmin::AdminLimitExceeded
00182                    ))
00183 {
00184   CosNotification::QoSProperties initial_qos;
00185 
00186   CosNotifyChannelAdmin::ProxySupplier_var proxy =
00187     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00188                                                                 , ctype
00189                                                                 , proxy_id
00190                                                                 , initial_qos
00191                                                                 ACE_ENV_ARG_PARAMETER);
00192   ACE_CHECK_RETURN (proxy._retn ());
00193   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00194   ACE_CHECK_RETURN (proxy._retn ());
00195   return proxy._retn ();
00196 }
00197 
00198 CosNotifyChannelAdmin::ProxySupplier_ptr
00199 TAO_Notify_ConsumerAdmin::obtain_notification_push_supplier_with_qos (CosNotifyChannelAdmin::ClientType ctype,
00200                                                                   CosNotifyChannelAdmin::ProxyID_out proxy_id,
00201                                                                   const CosNotification::QoSProperties & initial_qos
00202                                                                   ACE_ENV_ARG_DECL
00203                                                                   )
00204     ACE_THROW_SPEC ((
00205                      CORBA::SystemException
00206                      , CosNotifyChannelAdmin::AdminLimitExceeded
00207                      , CosNotification::UnsupportedQoS
00208                      ))
00209 {
00210   CosNotifyChannelAdmin::ProxySupplier_var proxy =
00211     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00212                                                                 , ctype
00213                                                                 , proxy_id
00214                                                                 , initial_qos
00215                                                                 ACE_ENV_ARG_PARAMETER);
00216   ACE_CHECK_RETURN (proxy._retn ());
00217   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00218   ACE_CHECK_RETURN (proxy._retn ());
00219   return proxy._retn ();
00220 }
00221 
00222 CosEventChannelAdmin::ProxyPushSupplier_ptr
00223 TAO_Notify_ConsumerAdmin::obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL)
00224   ACE_THROW_SPEC ((
00225                    CORBA::SystemException
00226                    ))
00227 {
00228   CosEventChannelAdmin::ProxyPushSupplier_var proxy =
00229     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this ACE_ENV_ARG_PARAMETER);
00230   ACE_CHECK_RETURN (proxy._retn ());
00231   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00232   ACE_CHECK_RETURN (proxy._retn ());
00233   return proxy._retn ();
00234 }
00235 
00236 CosNotifyChannelAdmin::AdminID
00237 TAO_Notify_ConsumerAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00238   ACE_THROW_SPEC ((
00239                    CORBA::SystemException
00240                    ))
00241 {
00242   return this->id ();
00243 }
00244 
00245 CosNotifyChannelAdmin::EventChannel_ptr
00246 TAO_Notify_ConsumerAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL)
00247   ACE_THROW_SPEC ((
00248                    CORBA::SystemException
00249                    ))
00250 {
00251   return this->ec_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00252 }
00253 
00254 ::CosNotifyChannelAdmin::InterFilterGroupOperator
00255 TAO_Notify_ConsumerAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00256   ACE_THROW_SPEC ((
00257                    CORBA::SystemException
00258                    ))
00259 {
00260   return this->filter_operator_;
00261 }
00262 
00263 CosNotifyChannelAdmin::ProxyIDSeq*
00264 TAO_Notify_ConsumerAdmin::push_suppliers (ACE_ENV_SINGLE_ARG_DECL)
00265   ACE_THROW_SPEC ((
00266                    CORBA::SystemException
00267                    ))
00268 {
00269   TAO_Notify_Proxy_Seq_Worker seq_worker;
00270 
00271   return seq_worker.create (this->proxy_container() ACE_ENV_ARG_PARAMETER);
00272 }
00273 
00274 CosNotifyChannelAdmin::ProxySupplier_ptr
00275 TAO_Notify_ConsumerAdmin::get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL)
00276   ACE_THROW_SPEC ((
00277                    CORBA::SystemException
00278                    , CosNotifyChannelAdmin::ProxyNotFound
00279                    ))
00280 {
00281   TAO_Notify_ProxySupplier_Find_Worker find_worker;
00282 
00283   return find_worker.resolve (proxy_id, this->proxy_container() ACE_ENV_ARG_PARAMETER);
00284 }
00285 
00286 void TAO_Notify_ConsumerAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL)
00287   ACE_THROW_SPEC ((
00288                    CORBA::SystemException
00289                    , CosNotification::UnsupportedQoS
00290                    ))
00291 {
00292   this->TAO_Notify_Object::set_qos (qos ACE_ENV_ARG_PARAMETER);
00293 }
00294 
00295 
00296 CosNotification::QoSProperties*
00297 TAO_Notify_ConsumerAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL)
00298   ACE_THROW_SPEC ((
00299                    CORBA::SystemException
00300                    ))
00301 {
00302   return this->TAO_Notify_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER);
00303 }
00304 
00305 void
00306 TAO_Notify_ConsumerAdmin::subscription_change (const CosNotification::EventTypeSeq & added,
00307                                            const CosNotification::EventTypeSeq & removed
00308                                            ACE_ENV_ARG_DECL
00309                                            )
00310   ACE_THROW_SPEC ((
00311                    CORBA::SystemException
00312                    , CosNotifyComm::InvalidEventType
00313                    ))
00314 {
00315   TAO_Notify_EventTypeSeq seq_added (added);
00316   TAO_Notify_EventTypeSeq seq_removed (removed);
00317 
00318   {
00319     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00320                         CORBA::INTERNAL ());
00321     ACE_CHECK;
00322 
00323     this->subscribed_types_.add_and_remove (seq_added, seq_removed);
00324 
00325     TAO_Notify_Subscription_Change_Worker worker (added, removed);
00326 
00327     this->proxy_container().collection()->for_each (&worker ACE_ENV_ARG_PARAMETER);
00328     ACE_CHECK;
00329   }
00330   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00331   ACE_CHECK;
00332 }
00333 
00334 CosNotifyFilter::FilterID
00335 TAO_Notify_ConsumerAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL)
00336   ACE_THROW_SPEC ((
00337                    CORBA::SystemException
00338                    ))
00339 {
00340   CosNotifyFilter::FilterID fid =
00341     this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER);
00342   ACE_CHECK_RETURN (fid);
00343   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00344   ACE_CHECK_RETURN (fid);
00345   return fid;
00346 }
00347 
00348 void
00349 TAO_Notify_ConsumerAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL)
00350   ACE_THROW_SPEC ((
00351                    CORBA::SystemException
00352                    , CosNotifyFilter::FilterNotFound
00353                    ))
00354 {
00355   this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER);
00356 }
00357 
00358 ::CosNotifyFilter::Filter_ptr
00359 TAO_Notify_ConsumerAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL)
00360   ACE_THROW_SPEC ((
00361                    CORBA::SystemException
00362                    , CosNotifyFilter::FilterNotFound
00363                    ))
00364 {
00365   return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER);
00366 }
00367 
00368 ::CosNotifyFilter::FilterIDSeq*
00369 TAO_Notify_ConsumerAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL)
00370   ACE_THROW_SPEC ((
00371                    CORBA::SystemException
00372                    ))
00373 {
00374   return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER);
00375 }
00376 
00377 void
00378 TAO_Notify_ConsumerAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL)
00379   ACE_THROW_SPEC ((
00380                    CORBA::SystemException
00381                    ))
00382 {
00383   this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER);
00384 }
00385 
00386 /************ UNIMPLMENTED METHODS *************************/
00387 
00388 CosNotifyFilter::MappingFilter_ptr
00389 TAO_Notify_ConsumerAdmin::priority_filter (ACE_ENV_SINGLE_ARG_DECL)
00390   ACE_THROW_SPEC ((
00391                    CORBA::SystemException
00392                    ))
00393 {
00394   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ());
00395 }
00396 
00397 void
00398 TAO_Notify_ConsumerAdmin::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/ ACE_ENV_ARG_DECL)
00399   ACE_THROW_SPEC ((
00400                    CORBA::SystemException
00401                    ))
00402 
00403 {
00404   ACE_THROW (CORBA::NO_IMPLEMENT ());
00405 }
00406 
00407 CosNotifyFilter::MappingFilter_ptr
00408 TAO_Notify_ConsumerAdmin::lifetime_filter (ACE_ENV_SINGLE_ARG_DECL)
00409   ACE_THROW_SPEC ((
00410                    CORBA::SystemException
00411                    ))
00412 
00413 {
00414   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ());
00415 }
00416 
00417 void
00418 TAO_Notify_ConsumerAdmin::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/ ACE_ENV_ARG_DECL)
00419   ACE_THROW_SPEC ((
00420                    CORBA::SystemException
00421                    ))
00422 {
00423   ACE_THROW (CORBA::NO_IMPLEMENT ());
00424 }
00425 
00426 ::CosNotifyChannelAdmin::ProxyIDSeq*
00427 TAO_Notify_ConsumerAdmin::pull_suppliers (ACE_ENV_SINGLE_ARG_DECL)
00428   ACE_THROW_SPEC ((
00429                    CORBA::SystemException
00430                    ))
00431 {
00432   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
00433 }
00434 
00435 CosNotifyChannelAdmin::ProxySupplier_ptr
00436 TAO_Notify_ConsumerAdmin::obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType /*ctype*/,
00437                                                          CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/
00438                                                          ACE_ENV_ARG_DECL)
00439   ACE_THROW_SPEC ((
00440                    CORBA::SystemException
00441                    , CosNotifyChannelAdmin::AdminLimitExceeded
00442                    ))
00443 
00444 {
00445   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxySupplier::_nil ());
00446 }
00447 
00448 void
00449 TAO_Notify_ConsumerAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/,
00450                                     CosNotification::NamedPropertyRangeSeq_out /*available_qos*/
00451                                     ACE_ENV_ARG_DECL
00452                                     )
00453   ACE_THROW_SPEC ((
00454                    CORBA::SystemException
00455                    , CosNotification::UnsupportedQoS
00456                    ))
00457 {
00458   ACE_THROW (CORBA::NO_IMPLEMENT ());
00459 }
00460 
00461 CosEventChannelAdmin::ProxyPullSupplier_ptr
00462 TAO_Notify_ConsumerAdmin::obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL)
00463   ACE_THROW_SPEC ((
00464                    CORBA::SystemException
00465                    ))
00466 {
00467   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullSupplier::_nil ());
00468 }
00469 
00470 TAO_Notify_ProxySupplier *
00471 TAO_Notify_ConsumerAdmin::find_proxy_supplier (
00472     TAO_Notify::IdVec & id_path,
00473     size_t position
00474     ACE_ENV_ARG_DECL)
00475 {
00476   TAO_Notify_ProxySupplier * result = 0;
00477   size_t path_size = id_path.size ();
00478   if (position < path_size)
00479   {
00480     TAO_Notify_ProxySupplier_Find_Worker find_worker;
00481     TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container() ACE_ENV_ARG_PARAMETER);
00482     ACE_CHECK_RETURN (0);
00483     result = dynamic_cast <TAO_Notify_ProxySupplier *> (proxy);
00484   }
00485   return result;
00486 }
00487 
00488 TAO_END_VERSIONED_NAMESPACE_DECL

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