SupplierAdmin.cpp

Go to the documentation of this file.
00001 // SupplierAdmin.cpp,v 1.21 2006/03/14 06:14:34 jtc Exp
00002 
00003 #include "orbsvcs/Notify/SupplierAdmin.h"
00004 
00005 ACE_RCSID (RT_Notify,
00006            TAO_Notify_SupplierAdmin,
00007            "SupplierAdmin.cpp,v 1.21 2006/03/14 06:14:34 jtc Exp")
00008 
00009 #include "orbsvcs/Notify/Builder.h"
00010 #include "orbsvcs/Notify/ProxyConsumer.h"
00011 #include "orbsvcs/Notify/EventChannel.h"
00012 #include "orbsvcs/Notify/Subscription_Change_Worker.h"
00013 #include "orbsvcs/Notify/Find_Worker_T.h"
00014 #include "orbsvcs/Notify/Seq_Worker_T.h"
00015 #include "orbsvcs/Notify/Properties.h"
00016 
00017 #include "tao/debug.h"
00018 
00019 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00020 
00021 //#define DEBUG_LEVEL 9
00022 #ifndef DEBUG_LEVEL
00023 # define DEBUG_LEVEL TAO_debug_level
00024 #endif //DEBUG_LEVEL
00025 
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 typedef TAO_Notify_Find_Worker_T<TAO_Notify_Proxy
00029                                  , CosNotifyChannelAdmin::ProxyConsumer
00030                                  , CosNotifyChannelAdmin::ProxyConsumer_ptr
00031                                  , CosNotifyChannelAdmin::ProxyNotFound>
00032 TAO_Notify_ProxyConsumer_Find_Worker;
00033 
00034 typedef TAO_Notify_Seq_Worker_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Seq_Worker;
00035 
00036 TAO_Notify_SupplierAdmin::TAO_Notify_SupplierAdmin (void)
00037   : TAO_Notify_Admin ()
00038 {
00039 }
00040 
00041 const char *
00042 TAO_Notify_SupplierAdmin::get_admin_type_name () const
00043 {
00044   return "supplier_admin";
00045 }
00046 
00047 TAO_Notify_SupplierAdmin::~TAO_Notify_SupplierAdmin ()
00048 {
00049 }
00050 
00051 void
00052 TAO_Notify_SupplierAdmin::init (TAO_Notify_EventChannel *ec ACE_ENV_ARG_DECL)
00053 {
00054   TAO_Notify_Admin::init (ec ACE_ENV_ARG_PARAMETER);
00055   ACE_CHECK;
00056 
00057   const CosNotification::QoSProperties &default_sa_qos =
00058     TAO_Notify_PROPERTIES::instance ()->default_supplier_admin_qos_properties ();
00059 
00060   this->set_qos (default_sa_qos ACE_ENV_ARG_PARAMETER);
00061 }
00062 
00063 void
00064 TAO_Notify_SupplierAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00065 {
00066   this->_incr_refcnt ();
00067 }
00068 
00069 void
00070 TAO_Notify_SupplierAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00071 {
00072   this->_decr_refcnt ();
00073 }
00074 
00075 void
00076 TAO_Notify_SupplierAdmin::release (void)
00077 {
00078   delete this;
00079   //@@ inform factory
00080 }
00081 
00082 void
00083 TAO_Notify_SupplierAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL)
00084   ACE_THROW_SPEC ((
00085                    CORBA::SystemException
00086                    ))
00087 {
00088   int result = this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
00089   ACE_CHECK;
00090   if ( result == 1)
00091     return;
00092 
00093   this->ec_->remove (this ACE_ENV_ARG_PARAMETER);
00094   ACE_CHECK;
00095 }
00096 
00097 TAO_Notify::Topology_Object*
00098 TAO_Notify_SupplierAdmin::load_child (const ACE_CString &type,
00099   CORBA::Long id, const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL)
00100 {
00101   TAO_Notify::Topology_Object* result = this;
00102   if (type == "proxy_push_consumer")
00103   {
00104     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00105       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00106       , static_cast<int> (id)
00107       ));
00108     result = this->load_proxy(id, CosNotifyChannelAdmin::ANY_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00109     ACE_CHECK_RETURN (0);
00110   }
00111   else if (type == "structured_proxy_push_consumer")
00112   {
00113     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00114       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00115       , static_cast<int> (id)
00116       ));
00117     result = this->load_proxy(id, CosNotifyChannelAdmin::STRUCTURED_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00118     ACE_CHECK_RETURN (0);
00119   }
00120   else if (type == "sequence_proxy_push_consumer")
00121   {
00122     if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG,
00123       ACE_TEXT ("(%P|%t) Admin reload proxy %d\n")
00124       , static_cast<int> (id)
00125       ));
00126     result = this->load_proxy(id, CosNotifyChannelAdmin::SEQUENCE_EVENT, attrs ACE_ENV_ARG_PARAMETER);
00127     ACE_CHECK_RETURN (0);
00128   }
00129   else
00130   {
00131     result = TAO_Notify_Admin::load_child (type, id, attrs ACE_ENV_ARG_PARAMETER);
00132     ACE_CHECK_RETURN (0);
00133   }
00134   return result;
00135 }
00136 
00137 TAO_Notify::Topology_Object*
00138 TAO_Notify_SupplierAdmin::load_proxy (
00139   CORBA::Long id,
00140   CosNotifyChannelAdmin::ClientType ctype,
00141   const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL)
00142 {
00143   TAO_Notify_Builder* bld = TAO_Notify_PROPERTIES::instance()->builder();
00144   TAO_Notify_ProxyConsumer * proxy =
00145     bld->build_proxy (this
00146                , ctype
00147                , id
00148                ACE_ENV_ARG_PARAMETER);
00149   ACE_CHECK_RETURN(0);
00150   ACE_ASSERT(proxy != 0);
00151   proxy->load_attrs (attrs);
00152   return proxy;
00153 }
00154 
00155 
00156 void
00157 TAO_Notify_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL)
00158   ACE_THROW_SPEC ((
00159                    CORBA::SystemException
00160                    , CosNotification::UnsupportedQoS
00161                    ))
00162 {
00163   this->TAO_Notify_Object::set_qos (qos ACE_ENV_ARG_PARAMETER);
00164 }
00165 
00166 CosNotification::QoSProperties*
00167 TAO_Notify_SupplierAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL)
00168   ACE_THROW_SPEC ((
00169                    CORBA::SystemException
00170                    ))
00171 {
00172   return this->TAO_Notify_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER);
00173 }
00174 
00175 CosNotifyChannelAdmin::ProxyConsumer_ptr
00176 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype
00177                                                          , CosNotifyChannelAdmin::ProxyID_out proxy_id
00178                                                          ACE_ENV_ARG_DECL)
00179   ACE_THROW_SPEC ((
00180                    CORBA::SystemException
00181                    , CosNotifyChannelAdmin::AdminLimitExceeded
00182                    ))
00183 
00184 {
00185   CosNotification::QoSProperties initial_qos;
00186 
00187   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00188     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00189                                                                 , ctype
00190                                                                 , proxy_id
00191                                                                 , initial_qos
00192                                                                 ACE_ENV_ARG_PARAMETER);
00193   ACE_CHECK_RETURN (proxy._retn ());
00194   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00195   ACE_CHECK_RETURN (proxy._retn ());
00196   return proxy._retn ();
00197 }
00198 
00199 CosNotifyChannelAdmin::ProxyConsumer_ptr
00200 TAO_Notify_SupplierAdmin::obtain_notification_push_consumer_with_qos (CosNotifyChannelAdmin::ClientType ctype,
00201                                                                   CosNotifyChannelAdmin::ProxyID_out proxy_id,
00202                                                                   const CosNotification::QoSProperties & initial_qos
00203                                                                   ACE_ENV_ARG_DECL
00204                                                                   )
00205   ACE_THROW_SPEC ((
00206                    CORBA::SystemException
00207                    , CosNotifyChannelAdmin::AdminLimitExceeded
00208                    , CosNotification::UnsupportedQoS
00209                    ))
00210 {
00211   CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00212     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this
00213                                                                 , ctype
00214                                                                 , proxy_id,
00215                                                                 initial_qos
00216                                                                 ACE_ENV_ARG_PARAMETER);
00217   ACE_CHECK_RETURN (proxy._retn ());
00218   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00219   ACE_CHECK_RETURN (proxy._retn ());
00220   return proxy._retn ();
00221 }
00222 
00223 
00224 CosEventChannelAdmin::ProxyPushConsumer_ptr
00225 TAO_Notify_SupplierAdmin::obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL)
00226   ACE_THROW_SPEC ((
00227                    CORBA::SystemException
00228                    ))
00229 {
00230   CosEventChannelAdmin::ProxyPushConsumer_var proxy =
00231     TAO_Notify_PROPERTIES::instance()->builder()->build_proxy (this ACE_ENV_ARG_PARAMETER);
00232   ACE_CHECK_RETURN (proxy._retn ());
00233   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00234   ACE_CHECK_RETURN (proxy._retn ());
00235   return proxy._retn ();
00236 }
00237 
00238 CosNotifyChannelAdmin::AdminID
00239 TAO_Notify_SupplierAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00240   ACE_THROW_SPEC ((
00241                    CORBA::SystemException
00242                    ))
00243 {
00244   return this->id ();
00245 }
00246 
00247 CosNotifyChannelAdmin::EventChannel_ptr
00248 TAO_Notify_SupplierAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL)
00249   ACE_THROW_SPEC ((
00250                    CORBA::SystemException
00251                    ))
00252 {
00253   return this->ec_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00254 }
00255 
00256 ::CosNotifyChannelAdmin::InterFilterGroupOperator
00257 TAO_Notify_SupplierAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00258   ACE_THROW_SPEC ((
00259                    CORBA::SystemException
00260                    ))
00261 {
00262   return this->filter_operator_;
00263 }
00264 
00265 CosNotifyChannelAdmin::ProxyIDSeq*
00266 TAO_Notify_SupplierAdmin::push_consumers (ACE_ENV_SINGLE_ARG_DECL)
00267   ACE_THROW_SPEC ((
00268                    CORBA::SystemException
00269                    ))
00270 {
00271   TAO_Notify_Proxy_Seq_Worker seq_worker;
00272 
00273   return seq_worker.create (this->proxy_container() ACE_ENV_ARG_PARAMETER);
00274 }
00275 
00276 CosNotifyChannelAdmin::ProxyConsumer_ptr
00277 TAO_Notify_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL)
00278   ACE_THROW_SPEC ((
00279                    CORBA::SystemException
00280                    , CosNotifyChannelAdmin::ProxyNotFound
00281                    ))
00282 {
00283   TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00284 
00285   return find_worker.resolve (proxy_id, this->proxy_container() ACE_ENV_ARG_PARAMETER);
00286 }
00287 
00288 void
00289 TAO_Notify_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added,
00290                                     const CosNotification::EventTypeSeq & removed
00291                                     ACE_ENV_ARG_DECL
00292                                     )
00293   ACE_THROW_SPEC ((
00294                    CORBA::SystemException
00295                    , CosNotifyComm::InvalidEventType
00296                    ))
00297 
00298 {
00299   TAO_Notify_EventTypeSeq seq_added (added);
00300   TAO_Notify_EventTypeSeq seq_removed (removed);
00301 
00302   {
00303     ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00304                         CORBA::INTERNAL ());
00305     ACE_CHECK;
00306 
00307     this->subscribed_types_.add_and_remove (seq_added, seq_removed);
00308 
00309     TAO_Notify_Subscription_Change_Worker worker (added, removed);
00310 
00311     this->proxy_container().collection ()->for_each (&worker ACE_ENV_ARG_PARAMETER);
00312   }
00313 }
00314 
00315 CosNotifyFilter::FilterID
00316 TAO_Notify_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL)
00317   ACE_THROW_SPEC ((
00318                    CORBA::SystemException
00319                    ))
00320 {
00321   CosNotifyFilter::FilterID fid =
00322     this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER);
00323   ACE_CHECK_RETURN (fid);
00324   this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER);
00325   ACE_CHECK_RETURN (fid);
00326   return fid;
00327 }
00328 
00329 void
00330 TAO_Notify_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL)
00331   ACE_THROW_SPEC ((
00332                    CORBA::SystemException
00333                    , CosNotifyFilter::FilterNotFound
00334                    ))
00335 {
00336   this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER);
00337 }
00338 
00339 ::CosNotifyFilter::Filter_ptr
00340 TAO_Notify_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL)
00341   ACE_THROW_SPEC ((
00342                    CORBA::SystemException
00343                    , CosNotifyFilter::FilterNotFound
00344                    ))
00345 {
00346   return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER);
00347 }
00348 
00349 ::CosNotifyFilter::FilterIDSeq*
00350 TAO_Notify_SupplierAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL)
00351   ACE_THROW_SPEC ((
00352                    CORBA::SystemException
00353                    ))
00354 {
00355   return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER);
00356 }
00357 
00358 void
00359 TAO_Notify_SupplierAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL)
00360   ACE_THROW_SPEC ((
00361                    CORBA::SystemException
00362                    ))
00363 {
00364   this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER);
00365 }
00366 
00367 /************** UNIMPLEMENTED METHODS ***************/
00368 
00369 CosEventChannelAdmin::ProxyPullConsumer_ptr
00370 TAO_Notify_SupplierAdmin::obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL)
00371   ACE_THROW_SPEC ((
00372                    CORBA::SystemException
00373                    ))
00374 {
00375   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullConsumer::_nil ());
00376 }
00377 
00378 CosNotifyChannelAdmin::ProxyIDSeq*
00379 TAO_Notify_SupplierAdmin::pull_consumers (ACE_ENV_SINGLE_ARG_DECL)
00380   ACE_THROW_SPEC ((
00381                    CORBA::SystemException
00382                    ))
00383 {
00384   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
00385 }
00386 
00387 
00388 void
00389 TAO_Notify_SupplierAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/,
00390                                     CosNotification::NamedPropertyRangeSeq_out /*available_qos*/
00391                                     ACE_ENV_ARG_DECL)
00392   ACE_THROW_SPEC ((
00393                    CORBA::SystemException
00394                    , CosNotification::UnsupportedQoS
00395                    ))
00396 {
00397   ACE_THROW (CORBA::NO_IMPLEMENT ());
00398 }
00399 
00400 CosNotifyChannelAdmin::ProxyConsumer_ptr
00401 TAO_Notify_SupplierAdmin::obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType /*ctype*/,
00402                                                          CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/
00403                                                          ACE_ENV_ARG_DECL)
00404   ACE_THROW_SPEC ((
00405                    CORBA::SystemException
00406                    , CosNotifyChannelAdmin::AdminLimitExceeded
00407                    ))
00408 {
00409   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxyConsumer::_nil ());
00410 }
00411 
00412 TAO_Notify_ProxyConsumer *
00413 TAO_Notify_SupplierAdmin::find_proxy_consumer (
00414     TAO_Notify::IdVec & id_path,
00415     size_t position
00416     ACE_ENV_ARG_DECL)
00417 {
00418   TAO_Notify_ProxyConsumer * result = 0;
00419   size_t path_size = id_path.size ();
00420   if (position < path_size)
00421   {
00422     TAO_Notify_ProxyConsumer_Find_Worker find_worker;
00423     TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container() ACE_ENV_ARG_PARAMETER);
00424     ACE_CHECK_RETURN (0);
00425     result = dynamic_cast <TAO_Notify_ProxyConsumer *> (proxy);
00426   }
00427   return result;
00428 }
00429 
00430 TAO_END_VERSIONED_NAMESPACE_DECL

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