Go to the documentation of this file.00001
00002
00003 #include "orbsvcs/Notify/MonitorControlExt/MonitorSupplierAdmin.h"
00004 #include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h"
00005 #include "orbsvcs/Notify/MonitorControl/Control_Registry.h"
00006 #include "orbsvcs/Notify/MonitorControl/Control.h"
00007
00008 #if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1)
00009
00010 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00011
00012 class SupplierAdminControl: public TAO_NS_Control
00013 {
00014 public:
00015 SupplierAdminControl (TAO_MonitorEventChannel* ec,
00016 const ACE_CString& name,
00017 CosNotifyChannelAdmin::AdminID id)
00018 : TAO_NS_Control (name.c_str ()),
00019 ec_ (ec),
00020 id_ (id) {
00021 }
00022
00023 virtual bool execute (const char* command) {
00024 if (ACE_OS::strcmp (command, TAO_NS_CONTROL_REMOVE_SUPPLIERADMIN) == 0)
00025 {
00026 CosNotifyChannelAdmin::SupplierAdmin_var admin =
00027 this->ec_->get_supplieradmin (this->id_);
00028 if (!CORBA::is_nil (admin.in ()))
00029 admin->destroy ();
00030 }
00031 else
00032 {
00033 return false;
00034 }
00035
00036 return true;
00037 }
00038
00039 private:
00040 TAO_MonitorEventChannel* ec_;
00041 CosNotifyChannelAdmin::AdminID id_;
00042 };
00043
00044 TAO_MonitorSupplierAdmin::TAO_MonitorSupplierAdmin (void)
00045 {
00046 }
00047
00048 TAO_MonitorSupplierAdmin::~TAO_MonitorSupplierAdmin (void)
00049 {
00050
00051 TAO_MonitorEventChannel* ec =
00052 dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
00053 if (ec != 0)
00054 {
00055 ec->remove_supplieradmin (this->id ());
00056 TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
00057 cinstance->remove (this->control_name_);
00058 }
00059 }
00060
00061 void
00062 TAO_MonitorSupplierAdmin::register_stats_controls (
00063 TAO_MonitorEventChannel* mec,
00064 const ACE_CString& base)
00065 {
00066 this->control_name_ = base;
00067 SupplierAdminControl* control = 0;
00068 ACE_NEW_THROW_EX (control,
00069 SupplierAdminControl (mec,
00070 this->control_name_.c_str (),
00071 this->id ()),
00072 CORBA::NO_MEMORY ());
00073 TAO_Control_Registry* cinstance = TAO_Control_Registry::instance ();
00074 if (!cinstance->add (control))
00075 {
00076 delete control;
00077 ACE_ERROR ((LM_ERROR, "Unable to add control: %s\n",
00078 this->control_name_.c_str ()));
00079 }
00080 }
00081
00082 CosNotifyChannelAdmin::ProxyConsumer_ptr
00083 TAO_MonitorSupplierAdmin::obtain_named_notification_push_consumer (
00084 CosNotifyChannelAdmin::ClientType ctype,
00085 CosNotifyChannelAdmin::ProxyID_out proxy_id,
00086 const char * name)
00087 {
00088
00089 TAO_MonitorEventChannel* ec =
00090 dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
00091 if (ec == 0)
00092 throw CORBA::INTERNAL ();
00093
00094
00095 CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00096 this->TAO_Notify_SupplierAdmin::obtain_notification_push_consumer (
00097 ctype, proxy_id);
00098
00099
00100 ec->map_consumer_proxy (proxy_id, name);
00101
00102 return proxy._retn ();
00103 }
00104
00105 CosNotifyChannelAdmin::ProxyConsumer_ptr
00106 TAO_MonitorSupplierAdmin::obtain_notification_push_consumer (
00107 CosNotifyChannelAdmin::ClientType ctype,
00108 CosNotifyChannelAdmin::ProxyID_out proxy_id)
00109 {
00110
00111 TAO_MonitorEventChannel* ec =
00112 dynamic_cast<TAO_MonitorEventChannel*> (this->ec_.get ());
00113 if (ec == 0)
00114 throw CORBA::INTERNAL ();
00115
00116
00117 CosNotifyChannelAdmin::ProxyConsumer_var proxy =
00118 this->TAO_Notify_SupplierAdmin::obtain_notification_push_consumer (
00119 ctype, proxy_id);
00120
00121
00122 char name[64];
00123 ACE_OS::sprintf(name, "%d", proxy_id);
00124 ec->map_consumer_proxy (proxy_id, name);
00125
00126 return proxy._retn ();
00127 }
00128
00129 TAO_END_VERSIONED_NAMESPACE_DECL
00130
00131 #endif
00132