Go to the documentation of this file.00001
00002 #include "orbsvcs/Notify/Admin.h"
00003 #include "orbsvcs/Notify/Validate_Worker_T.h"
00004
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/Admin.inl"
00007 #endif
00008
00009 ACE_RCSID (Notify,
00010 TAO_Notify_Admin,
00011 "$Id: Admin.cpp 84728 2009-03-05 19:58:54Z dai_y $")
00012
00013 #include "orbsvcs/CosNotifyChannelAdminC.h"
00014
00015 #include "orbsvcs/Notify/Container_T.h"
00016 #include "orbsvcs/Notify/Proxy.h"
00017 #include "orbsvcs/Notify/EventChannel.h"
00018 #include "orbsvcs/Notify/Topology_Saver.h"
00019 #include "orbsvcs/Notify/Save_Persist_Worker_T.h"
00020 #include "orbsvcs/Notify/Reconnect_Worker_T.h"
00021 #include "orbsvcs/Notify/Consumer_Map.h"
00022 #include "orbsvcs/Notify/Supplier_Map.h"
00023 #include "orbsvcs/Notify/ConsumerAdmin.h"
00024 #include "orbsvcs/Notify/SupplierAdmin.h"
00025
00026 #include "tao/debug.h"
00027
00028
00029 #ifndef DEBUG_LEVEL
00030 # define DEBUG_LEVEL TAO_debug_level
00031 #endif //DEBUG_LEVEL
00032
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034
00035 TAO_Notify_Admin::TAO_Notify_Admin ()
00036 : ec_ (0)
00037 , filter_operator_ (CosNotifyChannelAdmin::OR_OP)
00038 , is_default_ (false)
00039 {
00040
00041
00042
00043 this->subscribed_types_.insert (TAO_Notify_EventType::special ());
00044 }
00045
00046 TAO_Notify_Admin::~TAO_Notify_Admin ()
00047 {
00048 }
00049
00050 void
00051 TAO_Notify_Admin::init (TAO_Notify::Topology_Parent* parent)
00052 {
00053 ACE_ASSERT (this->ec_.get() == 0);
00054
00055 this->ec_.reset (dynamic_cast<TAO_Notify_EventChannel *>(parent));
00056 ACE_ASSERT (this->ec_.get() != 0);
00057
00058 filter_admin_.event_channel (this->ec_.get ());
00059
00060
00061 initialize (parent);
00062
00063 TAO_Notify_Proxy_Container* proxy_container = 0;
00064 ACE_NEW_THROW_EX (proxy_container,
00065 TAO_Notify_Proxy_Container (),
00066 CORBA::INTERNAL ());
00067 this->proxy_container_.reset (proxy_container);
00068
00069 this->proxy_container().init ();
00070
00071 }
00072
00073 void
00074 TAO_Notify_Admin::cleanup_proxy (TAO_Notify_Proxy *proxy,
00075 bool is_supplier,
00076 bool experienced_timeout)
00077 {
00078
00079
00080
00081 ec_->cleanup_proxy (proxy->id(), is_supplier, experienced_timeout);
00082
00083 this->remove (proxy);
00084 }
00085
00086 void
00087 TAO_Notify_Admin::remove (TAO_Notify_Proxy* proxy)
00088 {
00089 this->proxy_container().remove (proxy);
00090 }
00091
00092 void
00093 TAO_Notify_Admin::subscribed_types (TAO_Notify_EventTypeSeq& subscribed_types)
00094 {
00095 ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
00096 CORBA::INTERNAL ());
00097
00098
00099 TAO_Notify_EventTypeSeq added (this->subscribed_types_), removed;
00100
00101 added.add_and_remove (subscribed_types, removed);
00102
00103 subscribed_types = added;
00104 }
00105
00106 int
00107 TAO_Notify_Admin::shutdown (void)
00108 {
00109 if (TAO_Notify_Object::shutdown () == 1)
00110 return 1;
00111
00112 this->proxy_container().shutdown ();
00113
00114 return 0;
00115 }
00116
00117 void
00118 TAO_Notify_Admin::insert (TAO_Notify_Proxy* proxy)
00119 {
00120 this->proxy_container().insert (proxy);
00121 }
00122
00123 void
00124 TAO_Notify_Admin::save_persistent (TAO_Notify::Topology_Saver& saver)
00125 {
00126 bool changed = this->children_changed_;
00127 this->children_changed_ = false;
00128 this->self_changed_ = false;
00129
00130 if (is_persistent ())
00131 {
00132 TAO_Notify::NVPList attrs;
00133 this->save_attrs(attrs);
00134
00135 const char* type = this->get_admin_type_name();
00136
00137 bool want_all_children =
00138 saver.begin_object(this->id(), type, attrs, changed);
00139
00140 if (want_all_children || this->filter_admin_.is_changed ())
00141 {
00142 this->filter_admin_.save_persistent(saver);
00143 }
00144 if (want_all_children || this->subscribed_types_.is_changed ())
00145 {
00146 this->subscribed_types_.save_persistent(saver);
00147 }
00148
00149 TAO_Notify::Save_Persist_Worker<TAO_Notify_Proxy>
00150 wrk(saver, want_all_children);
00151 this->proxy_container().collection()->for_each(&wrk);
00152
00153 saver.end_object(this->id(), type);
00154 }
00155 }
00156
00157 void
00158 TAO_Notify_Admin::save_attrs (TAO_Notify::NVPList& attrs)
00159 {
00160 TAO_Notify_Object::save_attrs(attrs);
00161 attrs.push_back(TAO_Notify::NVP("InterFilterGroupOperator",
00162 this->filter_operator_));
00163 if (this->is_default_)
00164 {
00165 attrs.push_back (TAO_Notify::NVP ("default", "yes"));
00166 }
00167 }
00168
00169 void
00170 TAO_Notify_Admin::load_attrs(const TAO_Notify::NVPList& attrs)
00171 {
00172 TAO_Notify_Object::load_attrs (attrs);
00173 const char* value = 0;
00174 if (attrs.find ("InterFilterGroupOperator", value))
00175 {
00176 this->filter_operator_ = static_cast <CosNotifyChannelAdmin::InterFilterGroupOperator> (ACE_OS::atoi (value));
00177 }
00178
00179 if (attrs.find ("default", value))
00180 {
00181 this->is_default_ = (ACE_OS::strcmp (value, "yes") == 0);
00182 }
00183 }
00184
00185 TAO_Notify::Topology_Object*
00186 TAO_Notify_Admin::load_child (const ACE_CString &type,
00187 CORBA::Long id,
00188 const TAO_Notify::NVPList& attrs)
00189 {
00190 ACE_UNUSED_ARG (attrs);
00191 TAO_Notify::Topology_Object* result = this;
00192 if (type == "subscriptions")
00193 {
00194 if (DEBUG_LEVEL)
00195 ACE_DEBUG ((LM_DEBUG,
00196 ACE_TEXT ("(%P|%t) Admin reload subscription %d\n"),
00197 static_cast<int> (id)
00198 ));
00199
00200
00201 this->subscribed_types_.reset();
00202 result = &this->subscribed_types_;
00203 }
00204 else if (type == "filter_admin")
00205 {
00206 if (DEBUG_LEVEL)
00207 ACE_DEBUG ((LM_DEBUG,
00208 ACE_TEXT ("(%P|%t) Admin reload filter_admin %d\n"),
00209 static_cast<int> (id)
00210 ));
00211 result = & this->filter_admin_;
00212 }
00213 return result;
00214 }
00215
00216 void
00217 TAO_Notify_Admin::reconnect (void)
00218 {
00219 TAO_Notify::Reconnect_Worker<TAO_Notify_Proxy> wrk;
00220 this->proxy_container().collection()->for_each(&wrk);
00221 }
00222
00223 void
00224 TAO_Notify_Admin::validate ()
00225 {
00226 TAO_Notify::Validate_Worker<TAO_Notify_Proxy> wrk;
00227 this->proxy_container().collection()->for_each(&wrk);
00228 }
00229
00230
00231
00232 TAO_END_VERSIONED_NAMESPACE_DECL