From 295f7dc1ac02bee5cb01095a624e53bb22414746 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 30 Jul 2007 05:22:32 +0000
Subject: [PATCH] Add two new configuration attributes, ds-cfg-enabled-alert-type and ds-cfg-disabled-alert-type to alert handler configuration entries.  If a set of enabled alert types is given, then only alerts with one of those types will be passed to the associated alert handler.  If a set of disabled alert types is given, then only alerts without one of those types will be passed to the associated alert handler.  If both enabled and disabled lists are provided, then only alerts with a type on the enabled list and not on the disabled list will be processed.

---
 opends/src/server/org/opends/server/extensions/JMXAlertHandler.java |   48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/JMXAlertHandler.java b/opends/src/server/org/opends/server/extensions/JMXAlertHandler.java
index 9a792db..e06478f 100644
--- a/opends/src/server/org/opends/server/extensions/JMXAlertHandler.java
+++ b/opends/src/server/org/opends/server/extensions/JMXAlertHandler.java
@@ -48,6 +48,7 @@
 import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
 
+import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.AlertHandlerCfg;
 import org.opends.server.api.AlertGenerator;
 import org.opends.server.api.AlertHandler;
@@ -56,9 +57,11 @@
 import org.opends.server.config.JMXMBean;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.DN;
 import org.opends.server.types.InitializationException;
-import org.opends.server.types.DebugLogLevel;
+import org.opends.server.types.ResultCode;
 
 import static org.opends.server.loggers.debug.DebugLogger.*;
 import static org.opends.server.messages.ConfigMessages.*;
@@ -74,7 +77,8 @@
  */
 public class JMXAlertHandler
        extends NotificationBroadcasterSupport
-       implements AlertHandler<AlertHandlerCfg>, DynamicMBean,
+       implements AlertHandler<AlertHandlerCfg>,
+                  ConfigurationChangeListener<AlertHandlerCfg>, DynamicMBean,
                   DirectoryServerMBean
 {
   /**
@@ -90,6 +94,9 @@
 
 
 
+  // The current configuration for this alert handler.
+  private AlertHandlerCfg currentConfig;
+
   // The sequence number generator used for this alert handler.
   private AtomicLong sequenceNumber;
 
@@ -157,6 +164,19 @@
         throw new InitializationException(msgID, message, e);
       }
     }
+
+    configuration.addChangeListener(this);
+    currentConfig = configuration;
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  public AlertHandlerCfg getAlertHandlerConfiguration()
+  {
+    return currentConfig;
   }
 
 
@@ -374,5 +394,29 @@
                          new MBeanAttributeInfo[0], new MBeanConstructorInfo[0],
                          new MBeanOperationInfo[0], getNotificationInfo());
   }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  public boolean isConfigurationChangeAcceptable(AlertHandlerCfg configuration,
+                      List<String> unacceptableReasons)
+  {
+    return true;
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  public ConfigChangeResult applyConfigurationChange(
+                                        AlertHandlerCfg configuration)
+  {
+    currentConfig = configuration;
+
+    return new ConfigChangeResult(ResultCode.SUCCESS, false);
+  }
 }
 

--
Gitblit v1.10.0