org.opends.server.extensions
Class JMXAlertHandler

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.opends.server.extensions.JMXAlertHandler
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, ConfigurationChangeListener<JMXAlertHandlerCfg>, AlertHandler<JMXAlertHandlerCfg>, DirectoryServerMBean

public class JMXAlertHandler
extends javax.management.NotificationBroadcasterSupport
implements AlertHandler<JMXAlertHandlerCfg>, ConfigurationChangeListener<JMXAlertHandlerCfg>, javax.management.DynamicMBean, DirectoryServerMBean

This class provides an implementation of a Directory Server alert handler that will send alerts using JMX notifications.


Constructor Summary
JMXAlertHandler()
          Creates a new instance of this JMX alert handler.
 
Method Summary
 ConfigChangeResult applyConfigurationChange(JMXAlertHandlerCfg configuration)
          Applies the configuration changes to this change listener.
 void finalizeAlertHandler()
          Performs any necessary cleanup that may be necessary when this alert handler is finalized.
 AlertHandlerCfg getAlertHandlerConfiguration()
          Retrieves the current configuration for this alert handler.
 javax.management.Attribute getAttribute(java.lang.String attribute)
          Obtain the value of a specific attribute of the Dynamic MBean.
 javax.management.AttributeList getAttributes(java.lang.String[] attributes)
          Get the values of several attributes of the Dynamic MBean.
 javax.management.MBeanInfo getMBeanInfo()
          Provides the exposed attributes and actions of the Dynamic MBean using an MBeanInfo object.
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
          Retrieves information about the types of JMX notifications that may be generated.
 javax.management.ObjectName getObjectName()
          Retrieves the JMX object name for this JMX alert handler.
 void initializeAlertHandler(JMXAlertHandlerCfg configuration)
          Initializes this alert handler based on the information in the provided configuration entry.
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          Allows an action to be invoked on the Dynamic MBean.
 boolean isConfigurationAcceptable(AlertHandlerCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the provided configuration is acceptable for this alert handler.
 boolean isConfigurationChangeAcceptable(JMXAlertHandlerCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 void sendAlertNotification(AlertGenerator generator, java.lang.String alertType, Message alertMessage)
          Sends an alert notification based on the provided information.
 void setAttribute(javax.management.Attribute attribute)
          Set the value of a specific attribute of the Dynamic MBean.
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
          Sets the values of several attributes of the Dynamic MBean.
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXAlertHandler

public JMXAlertHandler()
Creates a new instance of this JMX alert handler. No initialization should be done here, as it should all be performed in the initializeAlertHandler method.

Method Detail

initializeAlertHandler

public void initializeAlertHandler(JMXAlertHandlerCfg configuration)
                            throws ConfigException,
                                   InitializationException
Initializes this alert handler based on the information in the provided configuration entry.

Specified by:
initializeAlertHandler in interface AlertHandler<JMXAlertHandlerCfg>
Parameters:
configuration - The configuration to use to initialize this alert handler.
Throws:
ConfigException - If the provided entry does not contain a valid configuration for this alert handler.
InitializationException - If a problem occurs during initialization that is not related to the server configuration.

getAlertHandlerConfiguration

public AlertHandlerCfg getAlertHandlerConfiguration()
Retrieves the current configuration for this alert handler.

Specified by:
getAlertHandlerConfiguration in interface AlertHandler<JMXAlertHandlerCfg>
Returns:
The current configuration for this alert handler.

isConfigurationAcceptable

public boolean isConfigurationAcceptable(AlertHandlerCfg configuration,
                                         java.util.List<Message> unacceptableReasons)
Indicates whether the provided configuration is acceptable for this alert handler.

Specified by:
isConfigurationAcceptable in interface AlertHandler<JMXAlertHandlerCfg>
Parameters:
configuration - The configuration for which to make tje determination.
unacceptableReasons - A list to which human-readable reasons may be added to explain why the configuration is not acceptable.
Returns:
true if the provided configuration is acceptable, or false if it is not.

finalizeAlertHandler

public void finalizeAlertHandler()
Performs any necessary cleanup that may be necessary when this alert handler is finalized.

Specified by:
finalizeAlertHandler in interface AlertHandler<JMXAlertHandlerCfg>

getObjectName

public javax.management.ObjectName getObjectName()
Retrieves the JMX object name for this JMX alert handler.

Specified by:
getObjectName in interface DirectoryServerMBean
Returns:
The JMX object name for this JMX alert handler.

sendAlertNotification

public void sendAlertNotification(AlertGenerator generator,
                                  java.lang.String alertType,
                                  Message alertMessage)
Sends an alert notification based on the provided information.

Specified by:
sendAlertNotification in interface AlertHandler<JMXAlertHandlerCfg>
Parameters:
generator - The alert generator that created the alert.
alertType - The alert type name for this alert.
alertMessage - A message (possibly null) that can provide more information about this alert.

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Retrieves information about the types of JMX notifications that may be generated.

Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
Overrides:
getNotificationInfo in class javax.management.NotificationBroadcasterSupport
Returns:
Information about the types of JMX notifications that may be generated.

getAttribute

public javax.management.Attribute getAttribute(java.lang.String attribute)
                                        throws javax.management.AttributeNotFoundException
Obtain the value of a specific attribute of the Dynamic MBean.

Specified by:
getAttribute in interface javax.management.DynamicMBean
Parameters:
attribute - The name of the attribute to be retrieved.
Returns:
The requested MBean attribute.
Throws:
javax.management.AttributeNotFoundException - If the specified attribute is not associated with this MBean.

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException
Set the value of a specific attribute of the Dynamic MBean.

Specified by:
setAttribute in interface javax.management.DynamicMBean
Parameters:
attribute - The identification of the attribute to be set and the value it is to be set to.
Throws:
javax.management.AttributeNotFoundException - If the specified attribute is not associated with this MBean.
javax.management.InvalidAttributeValueException - If the provided value is not acceptable for this MBean.

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attributes)
Get the values of several attributes of the Dynamic MBean.

Specified by:
getAttributes in interface javax.management.DynamicMBean
Parameters:
attributes - A list of the attributes to be retrieved.
Returns:
The list of attributes retrieved.

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Sets the values of several attributes of the Dynamic MBean.

Specified by:
setAttributes in interface javax.management.DynamicMBean
Parameters:
attributes - A list of attributes: The identification of the attributes to be set and the values they are to be set to.
Returns:
The list of attributes that were set with their new values.

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException
Allows an action to be invoked on the Dynamic MBean.

Specified by:
invoke in interface javax.management.DynamicMBean
Parameters:
actionName - The name of the action to be invoked.
params - An array containing the parameters to be set when the action is invoked.
signature - An array containing the signature of the action. The class objects will be loaded through the same class loader as the one used for loading the MBean on which action is invoked.
Returns:
The object returned by the action, which represents the result of invoking the action on the MBean specified.
Throws:
javax.management.MBeanException - If a problem is encountered while invoking the method.

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Provides the exposed attributes and actions of the Dynamic MBean using an MBeanInfo object.

Specified by:
getMBeanInfo in interface javax.management.DynamicMBean
Returns:
An instance of MBeanInfo allowing all attributes and actions exposed by this Dynamic MBean to be retrieved.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(JMXAlertHandlerCfg configuration,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<JMXAlertHandlerCfg>
Parameters:
configuration - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(JMXAlertHandlerCfg configuration)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<JMXAlertHandlerCfg>
Parameters:
configuration - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.