org.apache.avalon.excalibur.logger.decorator
Class LoggerManagerDecorator

java.lang.Object
  extended by org.apache.avalon.excalibur.logger.decorator.LoggerManagerDecorator
All Implemented Interfaces:
LoggerManager, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Startable, Configurable, Contextualizable, LogEnabled
Direct Known Subclasses:
CachingDecorator, LogToSelfDecorator, OverrideDefaultDecorator, PrefixDecorator

public abstract class LoggerManagerDecorator
extends Object
implements LoggerManager, LogEnabled, Contextualizable, Configurable, org.apache.avalon.framework.activity.Startable, org.apache.avalon.framework.activity.Disposable

This is the base class to create LoggerManager decorators. It passes all lifecycle and LoggerManagerc calls onto the wrapped object.

Decorators are expected to be slim - be able to run for instance both with and without having their enableLogging() method called.

This constraint is imposed to allow decorators to be applicable to an object both at its burth, like

 C c = new C();
 DecoratorX d = new DecoratorX( c );
 x.enableLogging( logger );
 
and after the object has been completely configured
 C c = (C)manager.lookup( C.ROLE );
 DecoratorX d = new DecoratorX( c );
 
If this constrianed is not obeyed this should be clearly stated in the javadocs. For instance, LogToSelfDecorator _only_ makes sense if it passes the enableLogging call through it.

This implementation is incomplete, it passes only those calls that are needed in org.apache.avalon.excalibur.logger.decorator.* and org.apache.avalon.excalibur.logger.adapter.*:

    LogEnabled
    Contextualizable
    Configurable
    Startable
    Disposable
 
This object differes from LoggerManagerTee by being abstract, by absence of addTee() public method and by implementation. LoggerManagerTee might be used instead of this but maintaining it as a separate class seemed cleaner.

Since:
4.0
Version:
CVS $Revision: 1.4 $ $Date: 2004/03/10 13:54:50 $
Author:
Avalon Development Team

Field Summary
protected  LoggerManager m_loggerManager
          The wrapped-in LoggerManager.
 
Fields inherited from interface org.apache.avalon.excalibur.logger.LoggerManager
ROLE
 
Constructor Summary
LoggerManagerDecorator(LoggerManager loggerManager)
           
 
Method Summary
 void configure(Configuration configuration)
           
 void contextualize(Context context)
           
 void dispose()
           
 void enableLogging(Logger logger)
           
 Logger getDefaultLogger()
          Return the default Logger.
 Logger getLoggerForCategory(String categoryName)
          Return the Logger for the specified category.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_loggerManager

protected final LoggerManager m_loggerManager
The wrapped-in LoggerManager.

Constructor Detail

LoggerManagerDecorator

public LoggerManagerDecorator(LoggerManager loggerManager)
Method Detail

enableLogging

public void enableLogging(Logger logger)
Specified by:
enableLogging in interface LogEnabled

contextualize

public void contextualize(Context context)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

start

public void start()
           throws Exception
Specified by:
start in interface org.apache.avalon.framework.activity.Startable
Throws:
Exception

stop

public void stop()
          throws Exception
Specified by:
stop in interface org.apache.avalon.framework.activity.Startable
Throws:
Exception

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

getLoggerForCategory

public Logger getLoggerForCategory(String categoryName)
Return the Logger for the specified category.

Specified by:
getLoggerForCategory in interface LoggerManager

getDefaultLogger

public Logger getDefaultLogger()
Return the default Logger. This is basically the same as getting the Logger for the "" category.

Specified by:
getDefaultLogger in interface LoggerManager


Copyright © 1997-2012 Apache Software Foundation. All Rights Reserved.