logahawk.listeners
Class FailSafeListener

java.lang.Object
  extended by logahawk.listeners.ProxyListener
      extended by logahawk.listeners.FailSafeListener
All Implemented Interfaces:
Listener

@ThreadSafe
public class FailSafeListener
extends ProxyListener

A special Listener designed to handle exceptions thrown by the Listener.log(LogMeta, String) method. The FailSafeListener encapsulates two Listeners, a primary and a backup. When Listener.log(LogMeta, String) is called on this class, the primary Listener's log() is called. If no exception is thrown, nothing special happens. But if an exception is thrown, the log is re-tried on the backup Listener. Additional notes: - This Listener will catch any Throwable thrown from the primary Listener, not just Exceptions. - If the primary Listener throws, the original message and Exception will be logged to the backup Listener. - Multiple FailSafeListeners can be chained together if there are multiple Listeners that might throw.

See Also:
SafeListener

Field Summary
protected  Listener backup
           
protected  LogMetaProvider logMetaProvider
          Used only when backup is used.
 
Fields inherited from class logahawk.listeners.ProxyListener
listener
 
Constructor Summary
FailSafeListener(Listener primary, Listener backup, LogMetaProvider logMetaProvider)
           
 
Method Summary
 void log(LogMeta meta, String text)
          Logs the provided statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backup

protected final Listener backup

logMetaProvider

protected final LogMetaProvider logMetaProvider
Used only when backup is used.

Constructor Detail

FailSafeListener

public FailSafeListener(Listener primary,
                        Listener backup,
                        LogMetaProvider logMetaProvider)
Method Detail

log

public void log(LogMeta meta,
                String text)
Description copied from interface: Listener
Logs the provided statement. Normally this method should not throw any exceptions. If exceptions are expected it is recommend to wrap this Listener with a FailSafeListener.