fr.umlv.tatoo.cc.common.log
Class ReporterFactory

java.lang.Object
  extended by fr.umlv.tatoo.cc.common.log.ReporterFactory

public class ReporterFactory
extends Object

This class permits to install/uninstall a reporter on the current thread.

Author:
Remi

Constructor Summary
ReporterFactory()
           
 
Method Summary
protected  Reporter createDefaultReporter()
          Creates a default reporter used as thread local reporter.
 Reporter getCurrentReporter()
          Returns the reporter attached to the current thread.
static Info getDefaultInfo()
          Returns the Info object used to derive the info object used to report an event or an error.
static ReporterFactory getFactory()
          Returns the reporter factory currently used.
static Level getLogLevel()
          Returns the log level of the reporter attached to the current thread.
 void installCurrentReporter(Reporter reporter)
          Changes the reporter of the current thread.
static void setAndSealDefaultInfo(Info defaultInfo)
          Changes the info object attached on the thread local reporter and used to derive the info object used to report an event or an error .
static void setFactory(ReporterFactory factory)
          Changes the Reporter Factory used.
static void setLogLevel(Level level)
          Sets log level of the reporter attached to the current thread.
 void uninstallCurrentReporter()
          Reverts the reporter of the current thread to the default reporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReporterFactory

public ReporterFactory()
Method Detail

installCurrentReporter

public void installCurrentReporter(Reporter reporter)
Changes the reporter of the current thread.

Parameters:
reporter - the new reporter

uninstallCurrentReporter

public void uninstallCurrentReporter()
Reverts the reporter of the current thread to the default reporter.

See Also:
createDefaultReporter()

getCurrentReporter

public Reporter getCurrentReporter()
Returns the reporter attached to the current thread.

Returns:
the thread local reporter.

createDefaultReporter

protected Reporter createDefaultReporter()
Creates a default reporter used as thread local reporter. This method is called :
  1. When a method lookup its reporter and none was defined.
  2. When installCurrentReporter(Reporter) is called.

Returns:
a default reporter.

setLogLevel

public static void setLogLevel(Level level)
Sets log level of the reporter attached to the current thread.

Parameters:
level - the new log level.
See Also:
getFactory(), getCurrentReporter(), Reporter.setLogLevel(Level)

getLogLevel

public static Level getLogLevel()
Returns the log level of the reporter attached to the current thread.

Returns:
the log level of the thread local reporter.
See Also:
getFactory(), getCurrentReporter(), Reporter.getLogLevel()

getDefaultInfo

public static Info getDefaultInfo()
Returns the Info object used to derive the info object used to report an event or an error. The returned info is always sealed so any modification will not change the default info of the thread local reporter.

Returns:
a sealed info
See Also:
setAndSealDefaultInfo(Info), Info.derive(Level, String, Object[]), Info.isSealed()

setAndSealDefaultInfo

public static void setAndSealDefaultInfo(Info defaultInfo)
Changes the info object attached on the thread local reporter and used to derive the info object used to report an event or an error . If the info taken as parameter is not sealed, this method seal it.

Parameters:
defaultInfo - the new default info of the thread local reporter.
See Also:
Info.derive(Level, String, Object[])

getFactory

public static ReporterFactory getFactory()
Returns the reporter factory currently used.

Returns:
a reporter factory.

setFactory

public static void setFactory(ReporterFactory factory)
Changes the Reporter Factory used. This method will not change reporters already attached on a thread.

Parameters:
factory - the new reporter factory.
See Also:
uninstallCurrentReporter()