com.ibm.ras
Interface RASIHandler

All Superinterfaces:
RASIMaskChangeGenerator, RASIObject, java.io.Serializable
All Known Implementing Classes:
WsHandler

public interface RASIHandler
extends RASIMaskChangeGenerator

RASIHandler defines the methods that must be implemented to process RASEvents generated by a RASLogger.


Method Summary
 void addFormatter(RASIFormatter formatter)
          Registers a RAS event formatter with this handler.
 void closeDevice()
          Closes the device to which the handler is sending its log entries, if it is open.
 java.util.Hashtable getConfig()
          Gets the configuration of this object.
 java.util.Enumeration getFormatters()
          Gets the set of formatters associated with this handler.
 int getMaximumQueueSize()
          Gets the maximum number of RASIEvents which the handler will hold.
 int getQueueSize()
          Gets the current number of RASIEvents in the handler's queue.
 int getRetryInterval()
          Gets the amount of time (in milliseconds) that this handler will wait before retrying a failed write.
 void logEvent(RASIEvent event)
          Passes a RAS event asynchronously from a logger to a handler.
 void openDevice()
          Opens the device to which the handler will send its log entries.
 void removeFormatter(RASIFormatter formatter)
          Removes a RAS event formatter from this handler.
 void setConfig(java.util.Hashtable ht)
          Sets the configuration of this object.
 void setMaximumQueueSize(int size)
          Sets the maximum number of RASIEvents which the handler will hold.
 void setRetryInterval(int interval)
          Sets the amount of time (in milliseconds) that this handler will wait before retrying a failed write.
 void stop()
          Stops the handler.
 void writeEvent(RASIEvent event)
          Passes a RAS event synchronously from a logger to a handler.
 
Methods inherited from interface com.ibm.ras.RASIMaskChangeGenerator
addMaskChangeListener, addMessageEventClass, addTraceEventClass, fireMaskChangedEvent, getMaskChangeListeners, getMessageEventClasses, getMessageMask, getTraceEventClasses, getTraceMask, removeMaskChangeListener, removeMessageEventClass, removeTraceEventClass, setMessageMask, setTraceMask
 
Methods inherited from interface com.ibm.ras.RASIObject
getDescription, getGroup, getName, setDescription, setName
 

Method Detail

getConfig

public java.util.Hashtable getConfig()
Gets the configuration of this object.
Specified by:
getConfig in interface RASIMaskChangeGenerator
Returns:
A Hashtable containing the configuration. This object inserts the following key/value pairs into the the configuration:

maxQueueSize

The maximum number of RASIEvents which this handler will hold.

retryInterval

The number of milliseconds that this handler will wait before retrying a failed write.

formatterNames

The names of the formatters attached to this handler.

All values are Strings. Extensions to this object may add additional keys.


setConfig

public void setConfig(java.util.Hashtable ht)
Sets the configuration of this object. This method is used by a RASManager to initialize a RAS object. It should not be necessary for an application to use this method.
Specified by:
setConfig in interface RASIMaskChangeGenerator
Parameters:
ht - A Hashtable containing the configuration. This object searches for the following keys:

maxQueueSize

The maximum number of RASIEvents which this handler will hold.

retryInterval

The number of milliseconds that this handler will wait before retrying a failed write.

formatterNames

The names of the formatters attached to this handler.

All values are Strings. If a key is not found, an internal default for that element is set instead. Extensions to this object may add additional keys.


getMaximumQueueSize

public int getMaximumQueueSize()
Gets the maximum number of RASIEvents which the handler will hold. If not set, the default value of 10,000 is returned.
Returns:
The maximum queue size.

setMaximumQueueSize

public void setMaximumQueueSize(int size)
                         throws java.lang.IllegalStateException
Sets the maximum number of RASIEvents which the handler will hold. If this maximum is exceeded, objects which call logEvent will be throttled-back, until the queue has enough space for the new object. If the size is set to zero, no maximum is in effect. If the size is less than zero, the current value is not changed.
Parameters:
size - The maximum queue size.
Throws:
java.lang.IllegalStateException - This exception is thrown if any RAS events are on the queue when an attempt is made to change the queue's size.

getRetryInterval

public int getRetryInterval()
Gets the amount of time (in milliseconds) that this handler will wait before retrying a failed write. If not set, the default value of 5000 (five seconds) is returned.
Returns:
The retry interval.

setRetryInterval

public void setRetryInterval(int interval)
Sets the amount of time (in milliseconds) that this handler will wait before retrying a failed write. If the size is set to zero, no delay is in effect and the retry occurs immediately. If the interval is less than zero, the current value is not changed.
Parameters:
interval - The retry interval.

getQueueSize

public int getQueueSize()
Gets the current number of RASIEvents in the handler's queue.
Returns:
The current queue size.

addFormatter

public void addFormatter(RASIFormatter formatter)
Registers a RAS event formatter with this handler. The formatter must be configured with the set of RASIEvent classes which it supports before this method is called. If the formatter is null, this method does nothing. If the formatter supports an event class which is already registered with this handler, this new formatter replaces the old one.
Parameters:
formatter - The event formatter.

removeFormatter

public void removeFormatter(RASIFormatter formatter)
Removes a RAS event formatter from this handler. If the formatter is null or is not registered, this method does nothing.
Parameters:
formatter - The event formatter.

getFormatters

public java.util.Enumeration getFormatters()
Gets the set of formatters associated with this handler.
Returns:
An Enumeration of registered formatters. If no formatters have been registered, the Enumeration is empty.

openDevice

public void openDevice()
Opens the device to which the handler will send its log entries. If an error occurs during this process, the handler will write a message to System.err.

If the device is already open, it will be closed and then reopened.


closeDevice

public void closeDevice()
Closes the device to which the handler is sending its log entries, if it is open.

stop

public void stop()
Stops the handler. This method should be called when a handler is no longer needed. Be careful not to stop a handler prematurely if it is shared by more than one logger.

logEvent

public void logEvent(RASIEvent event)
Passes a RAS event asynchronously from a logger to a handler. The log entry is saved for processing by the handler. The logger must compare the message type against the handler's message mask before calling this method. If the log event is null, this method does nothing.
Parameters:
event - A RAS event.

writeEvent

public void writeEvent(RASIEvent event)
Passes a RAS event synchronously from a logger to a handler. The handler processes the log entry immediately by calling the format method of the configured formatter and then the println method of the configured print writer. The logger must compare the event type against the handler's message or trace mask before calling this method. If the log event is null, this method does nothing.
Parameters:
event - A RAS event.