uk.org.iscream.cms.server.client
Class AlerterSkeleton

java.lang.Object
  extended byjava.lang.Thread
      extended byuk.org.iscream.cms.server.client.AlerterSkeleton
All Implemented Interfaces:
PluginAlerter, Runnable
Direct Known Subclasses:
EMail__Alerter, IRC__Alerter, Logging__Alerter, WebFeeder__Alerter

public abstract class AlerterSkeleton
extends Thread
implements PluginAlerter

Skeleton class for Alerters This skeleton reads alerts from the alert queue designated to the Alerter, it then feeds the alerts to the sendAlert method, which the extending class should implement. The class should then handle sending the message. This class also has a method to allow formatting of messages.

Version:
$Id: AlerterSkeleton.java,v 1.13 2004/08/01 10:40:40 tdb Exp $
Author:
$Author: tdb $

Field Summary
protected  ConfigurationProxy _cp
          A reference to the singleton configuration proxy in use, through which alerter configuration can be obtained
protected  Logger _logger
          This holds a reference to the system logger that is being used.
protected  String _name
          This is the friendly identifier of the component this class is running in.
protected  int _qID
          The ID of the queue the alerter will use.
protected  boolean _running
          The state of the alerter thread
 String DEFAULT_LEVEL
          The default level to send alerts at
 String NOT_CONFIGURED
          If a configuration property is not configured, this will be used instead.
 String REVISION
          The current CVS revision of this class
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AlerterSkeleton()
          Constructs and starts the alerter reading alerts
 
Method Summary
abstract  String getDescription()
          Return the String representation of what the alerter does
protected abstract  String getFName()
          Returns the "friendly" name of this class.
protected  Queue getQueue()
          Gets hold of the Alerts queue from the AlerterManager.
protected  int getQueueId()
          Gets an id to an individual queue
protected  String processAlertMessage(String message, Alert alert)
          Processes a message, replace key fields (eg.
 void run()
          Reads the next alert from the alerter queue for this alerter.
protected abstract  void sendAlert(Alert alert)
          Sends an alert object using whatever transport mechanism the extending class is implementing.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

DEFAULT_LEVEL

public final String DEFAULT_LEVEL
The default level to send alerts at


NOT_CONFIGURED

public final String NOT_CONFIGURED
If a configuration property is not configured, this will be used instead.

See Also:
Constant Field Values

_name

protected String _name
This is the friendly identifier of the component this class is running in. eg, a Filter may be called "filter1", If this class does not have an owning component, a name from the configuration can be placed here. This name could also be changed to null for utility classes.


_logger

protected Logger _logger
This holds a reference to the system logger that is being used.


_cp

protected ConfigurationProxy _cp
A reference to the singleton configuration proxy in use, through which alerter configuration can be obtained


_qID

protected int _qID
The ID of the queue the alerter will use. Initially -1, but initialised on first use.


_running

protected boolean _running
The state of the alerter thread

Constructor Detail

AlerterSkeleton

public AlerterSkeleton()
Constructs and starts the alerter reading alerts

Method Detail

run

public void run()
Reads the next alert from the alerter queue for this alerter. It then looks up Alerter..level in the configuration to determine the lowest level of alert the extending alerter should send. If the alert is above this level, or if the alert is an OK for an alert escalation which did rise above this alerters level, it then calls sendAlert to tell the alerter to send the alert. If it isn't above this level, it ignores the alert.

Specified by:
run in interface Runnable

sendAlert

protected abstract void sendAlert(Alert alert)
Sends an alert object using whatever transport mechanism the extending class is implementing.

Parameters:
alert - the Alert to send

processAlertMessage

protected String processAlertMessage(String message,
                                     Alert alert)
Processes a message, replace key fields (eg. %level%) with representative text from the given Alert object.

Parameters:
message - The message to process
alert - The Alert object to get data from
Returns:
the processed message

getDescription

public abstract String getDescription()
Return the String representation of what the alerter does

Specified by:
getDescription in interface PluginAlerter
Returns:
the description

getQueue

protected Queue getQueue()
Gets hold of the Alerts queue from the AlerterManager.

Returns:
The Alerts queue

getQueueId

protected int getQueueId()
Gets an id to an individual queue

Returns:
the id to the queue

getFName

protected abstract String getFName()
Returns the "friendly" name of this class. This is simply an accessor for _name, required due to inheritance issues with extending AlerterSkeleton.

Returns:
the friendly name


Copyright © 2000-2003 i-scream. All Rights Reserved.