org.rhq.enterprise.server.plugin.pc.alert
Class AlertSender<T extends ServerPluginComponent>

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.pc.alert.AlertSender<T>

public abstract class AlertSender<T extends ServerPluginComponent>
extends Object

Abstract base class for all Alert senders. In order to implement your AlertSender, you need to at least overwrite #send(). When the AlertSenderManager constructs this object, it will inject the preferences for your specific alert sender type. For each Alert a new instance of your implementation will be called and destroyed afterwards.

Author:
Heiko W. Rupp

Field Summary
protected  org.rhq.core.domain.configuration.Configuration alertParameters
          Configuration from the per alert definition parameters
protected  org.rhq.core.domain.configuration.Configuration extraParameters
          Configuration from the per alert definition parameters
protected  T pluginComponent
          Global component holding persistent resources
protected  org.rhq.core.domain.configuration.Configuration preferences
          Configuration from the global per plugin type preferences
protected  ServerPluginEnvironment serverPluginEnvironment
          Environement of the plugin to e.g.
 
Constructor Summary
AlertSender()
           
 
Method Summary
static String fence(List<?> elements)
          Takes the list of elements e1, e2, e3 and fences them with '|' delimiters such that the result looks like "|e1|e2|e3|"
 String previewConfiguration()
          Allow users to see a preview of the stored configuration data without having to edit it.
abstract  org.rhq.core.domain.alert.notification.SenderResult send(org.rhq.core.domain.alert.Alert alert)
          This method is called to actually send an alert notification.
static
<T> List<T>
unfence(String fencedData, Class<T> type)
          Presumes the data is in the format "|a|b|c|d|e|" where '|' delimits all elements as well as wraps the entire expression.
static
<T> List<T>
unfence(String fencedData, Class<T> type, String delimiter)
           
 AlertSenderValidationResults validateAndFinalizeConfiguration(org.rhq.core.domain.auth.Subject subject)
          Validates the alert and extra parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preferences

protected org.rhq.core.domain.configuration.Configuration preferences
Configuration from the global per plugin type preferences


alertParameters

protected org.rhq.core.domain.configuration.Configuration alertParameters
Configuration from the per alert definition parameters


extraParameters

protected org.rhq.core.domain.configuration.Configuration extraParameters
Configuration from the per alert definition parameters


pluginComponent

protected T extends ServerPluginComponent pluginComponent
Global component holding persistent resources


serverPluginEnvironment

protected ServerPluginEnvironment serverPluginEnvironment
Environement of the plugin to e.g. get the classloader

Constructor Detail

AlertSender

public AlertSender()
Method Detail

send

public abstract org.rhq.core.domain.alert.notification.SenderResult send(org.rhq.core.domain.alert.Alert alert)
This method is called to actually send an alert notification. This is where you implement all functionality. The return value is a SenderResult object, which encodes a log message, success or failure and can contain email addresses that got computed by your AlertSender and which will be sent by the system after *all* senders have been run.

Parameters:
alert - the Alert to operate on
Returns:
result of sending - a ResultState and a message for auditing

previewConfiguration

public String previewConfiguration()
Allow users to see a preview of the stored configuration data without having to edit it. A default implementation is already provided which will print the properties in alphabetical order, one per line, each followed by a string representation of that property's data.


validateAndFinalizeConfiguration

public AlertSenderValidationResults validateAndFinalizeConfiguration(org.rhq.core.domain.auth.Subject subject)
Validates the alert and extra parameters. The results should be initialized with the current parameters of this alert sender and the erroneous properties should have their error messages set.

The implementation is free to change (add/update/delete) properties in either of the configurations (i.e. finalize them). This is to support scenarios where the user inputs values that need to be further processed in an alert sender specific way before they get stored into the database.

The default implementation makes no changes to the configurations.

Parameters:
subject - the subject requesting the changes in the configuration
Returns:
the validation results

unfence

public static <T> List<T> unfence(String fencedData,
                                  Class<T> type)
Presumes the data is in the format "|a|b|c|d|e|" where '|' delimits all elements as well as wraps the entire expression.


unfence

public static <T> List<T> unfence(String fencedData,
                                  Class<T> type,
                                  String delimiter)

fence

public static String fence(List<?> elements)
Takes the list of elements e1, e2, e3 and fences them with '|' delimiters such that the result looks like "|e1|e2|e3|"



Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.