com.resilientedge.util.logger
Class AbstractHandler

java.lang.Object
  |
  +--com.resilientedge.util.logger.AbstractHandler
All Implemented Interfaces:
Handler
Direct Known Subclasses:
ConsoleHandler, MemoryHandler

public abstract class AbstractHandler
extends java.lang.Object
implements Handler

This abstract class provides the core Handler attributes and behavior.

Author:
odh

Constructor Summary
AbstractHandler()
           
 
Method Summary
abstract  Formatter getDefaultFormatter()
          The implementation of this method returns the default Formatter for the handler.
 Formatter getFormatter()
          Get the Handler's Formatter.
protected  java.lang.String lookupConfig(java.lang.String key)
          This method returns the configuraton String value from the Application Preferences.
 void publish(LogRecord logRecord)
          This method does the real work for a handler.
 void setFormatter(Formatter formatter)
          Set the Handler's Formatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHandler

public AbstractHandler()
Method Detail

setFormatter

public void setFormatter(Formatter formatter)
Set the Handler's Formatter.
Specified by:
setFormatter in interface Handler
Parameters:
formatter - The Handler's Formatter.

getFormatter

public Formatter getFormatter()
Get the Handler's Formatter.
Returns:
the Handler's Formatter or null if the Handler does not have a Formatter.

getDefaultFormatter

public abstract Formatter getDefaultFormatter()
The implementation of this method returns the default Formatter for the handler.
Returns:
The fully-defined and ready-to-use default Formatter for the Handler.

publish

public void publish(LogRecord logRecord)
             throws LoggerException
This method does the real work for a handler. A logger can pass this method a log record and expect that it will be fully processed and logged. Subclasses are expected to overide this method with their specific implementations.

Note: When a subclass overides this method, the very first line should always be super.publish(logRecord) . This will give the super class an opportunity to perform any required higher level behavior.

Specified by:
publish in interface Handler
Parameters:
logRecord - contains the log message
Throws:
LoggerException - Thrown if exception occurs during publishing. This may be a nested exception.

lookupConfig

protected java.lang.String lookupConfig(java.lang.String key)
This method returns the configuraton String value from the Application Preferences. If the supplied key is not recognized, then this method returns null.
Parameters:
key - the text string to use as a lookup key
Returns:
the located message corresponding the the key. Null is returned if the lookup does not find anything matching the key.


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.