org.geotools.util.logging
Class LoggerFactory<L>

java.lang.Object
  extended by org.geotools.util.logging.LoggerFactory<L>
Direct Known Subclasses:
CommonsLoggerFactory, Log4JLoggerFactory

public abstract class LoggerFactory<L>
extends java.lang.Object

A factory for Java Logger wrapping an other logging framework. This factory is used only when wanting to log to an other framework than Java logging. The getLogger(java.lang.String) method returns some subclass of Logger (typicallly LoggerAdapter) that forward directly all log methods to an other framework.

Since:
2.4
Version:
$Id: LoggerFactory.java 30640 2008-06-12 17:34:32Z acuster $
Author:
Martin Desruisseaux
See Also:
Logging, LoggerAdapter

Constructor Summary
protected LoggerFactory(java.lang.Class<L> loggerClass)
          Creates a new factory.
 
Method Summary
protected abstract  L getImplementation(java.lang.String name)
          Returns the implementation to use for the logger of the specified name.
 java.lang.Class<L> getImplementationClass()
          Returns the base class of objects to be returned by getImplementation(java.lang.String).
 java.util.logging.Logger getLogger(java.lang.String name)
          Returns the logger of the specified name, or null.
protected abstract  L unwrap(java.util.logging.Logger logger)
          Returns the implementation wrapped by the specified logger, or null if none.
protected abstract  java.util.logging.Logger wrap(java.lang.String name, L implementation)
          Wraps the specified implementation in a Java logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerFactory

protected LoggerFactory(java.lang.Class<L> loggerClass)
Creates a new factory.

Parameters:
loggerClass - The class of the wrapped logger.
Method Detail

getLogger

public java.util.logging.Logger getLogger(java.lang.String name)
Returns the logger of the specified name, or null. If this method has already been invoked previously with the same name argument, then it may returns the same logger provided that: Otherwise this method returns a new Logger instance, or null if the standard Java logging framework should be used.

Parameters:
name - The name of the logger.
Returns:
The logger, or null.

getImplementationClass

public java.lang.Class<L> getImplementationClass()
Returns the base class of objects to be returned by getImplementation(java.lang.String). The class depends on the underlying logging framework (Log4J, SLF4J, etc.).


getImplementation

protected abstract L getImplementation(java.lang.String name)
Returns the implementation to use for the logger of the specified name. The object to be returned depends on the logging framework (Log4J, SLF4J, etc.). If the target framework redirects logging events to Java logging, then this method should returns null since we should not use wrapper at all.

Parameters:
name - The name of the logger.
Returns:
The logger as an object of the target logging framework (Log4J, SLF4J, etc.), or null if the target framework would redirect to the Java logging framework.

wrap

protected abstract java.util.logging.Logger wrap(java.lang.String name,
                                                 L implementation)
Wraps the specified implementation in a Java logger.

Parameters:
name - The name of the logger.
implementation - An implementation returned by getImplementation(java.lang.String).
Returns:
A new logger wrapping the specified implementation.

unwrap

protected abstract L unwrap(java.util.logging.Logger logger)
Returns the implementation wrapped by the specified logger, or null if none. If the specified logger is not an instance of the expected class, then this method should returns null.

Parameters:
logger - The logger to test.
Returns:
The implementation wrapped by the specified logger, or null if none.


Copyright © 1996-2010 Geotools. All Rights Reserved.