org.picocontainer.gems.monitors
Class Log4JComponentMonitor

java.lang.Object
  extended by org.picocontainer.gems.monitors.Log4JComponentMonitor
All Implemented Interfaces:
Serializable, ComponentMonitor

public class Log4JComponentMonitor
extends Object
implements ComponentMonitor, Serializable

A ComponentMonitor which writes to a Log4J Logger instance. The Logger instance can either be injected or, if not set, the LogManager will be used to retrieve it at every invocation of the monitor.

Author:
Paul Hammant, Mauro Talevi
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.picocontainer.ComponentMonitor
KEEP
 
Constructor Summary
Log4JComponentMonitor()
          Creates a Log4JComponentMonitor with no Logger instance set.
Log4JComponentMonitor(Class<?> loggerClass)
          Creates a Log4JComponentMonitor with a given Logger instance class.
Log4JComponentMonitor(Class<?> loggerClass, ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance class.
Log4JComponentMonitor(ComponentMonitor delegate)
           
Log4JComponentMonitor(org.apache.log4j.Logger logger)
          Creates a Log4JComponentMonitor with a given Logger instance
Log4JComponentMonitor(org.apache.log4j.Logger logger, ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance
Log4JComponentMonitor(String loggerName)
          Creates a Log4JComponentMonitor with a given Logger instance name.
Log4JComponentMonitor(String loggerName, ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance name.
 
Method Summary
protected  org.apache.log4j.Logger getLogger(Member member)
           
<T> void
instantiated(PicoContainer container, ComponentAdapter<T> componentAdapter, Constructor<T> constructor, Object instantiated, Object[] parameters, long duration)
          
<T> Constructor<T>
instantiating(PicoContainer container, ComponentAdapter<T> componentAdapter, Constructor<T> constructor)
          
<T> void
instantiationFailed(PicoContainer container, ComponentAdapter<T> componentAdapter, Constructor<T> constructor, Exception cause)
          
 void invocationFailed(Member member, Object instance, Exception cause)
          
 void invoked(PicoContainer container, ComponentAdapter<?> componentAdapter, Member member, Object instance, long duration, Object[] args, Object retVal)
          
 Object invoking(PicoContainer container, ComponentAdapter<?> componentAdapter, Member member, Object instance, Object[] args)
          
 void lifecycleInvocationFailed(MutablePicoContainer container, ComponentAdapter<?> componentAdapter, Method method, Object instance, RuntimeException cause)
          
 Behavior newBehavior(Behavior behavior)
          
 Injector newInjector(Injector injector)
          
 Object noComponentFound(MutablePicoContainer container, Object componentKey)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JComponentMonitor

public Log4JComponentMonitor()
Creates a Log4JComponentMonitor with no Logger instance set. The LogManager will be used to retrieve the Logger instance at every invocation of the monitor.


Log4JComponentMonitor

public Log4JComponentMonitor(Class<?> loggerClass)
Creates a Log4JComponentMonitor with a given Logger instance class. The class name is used to retrieve the Logger instance.

Parameters:
loggerClass - the class of the Logger

Log4JComponentMonitor

public Log4JComponentMonitor(String loggerName)
Creates a Log4JComponentMonitor with a given Logger instance name. It uses the LogManager to create the Logger instance.

Parameters:
loggerName - the name of the Log

Log4JComponentMonitor

public Log4JComponentMonitor(org.apache.log4j.Logger logger)
Creates a Log4JComponentMonitor with a given Logger instance

Parameters:
logger - the Logger to write to

Log4JComponentMonitor

public Log4JComponentMonitor(Class<?> loggerClass,
                             ComponentMonitor delegate)
Creates a Log4JComponentMonitor with a given Logger instance class. The class name is used to retrieve the Logger instance.

Parameters:
loggerClass - the class of the Logger
delegate - the delegate

Log4JComponentMonitor

public Log4JComponentMonitor(String loggerName,
                             ComponentMonitor delegate)
Creates a Log4JComponentMonitor with a given Logger instance name. It uses the LogManager to create the Logger instance.

Parameters:
loggerName - the name of the Log
delegate - the delegate

Log4JComponentMonitor

public Log4JComponentMonitor(org.apache.log4j.Logger logger,
                             ComponentMonitor delegate)
Creates a Log4JComponentMonitor with a given Logger instance

Parameters:
logger - the Logger to write to
delegate - the delegate

Log4JComponentMonitor

public Log4JComponentMonitor(ComponentMonitor delegate)
Method Detail

instantiating

public <T> Constructor<T> instantiating(PicoContainer container,
                                        ComponentAdapter<T> componentAdapter,
                                        Constructor<T> constructor)

Specified by:
instantiating in interface ComponentMonitor

instantiated

public <T> void instantiated(PicoContainer container,
                             ComponentAdapter<T> componentAdapter,
                             Constructor<T> constructor,
                             Object instantiated,
                             Object[] parameters,
                             long duration)

Specified by:
instantiated in interface ComponentMonitor

instantiationFailed

public <T> void instantiationFailed(PicoContainer container,
                                    ComponentAdapter<T> componentAdapter,
                                    Constructor<T> constructor,
                                    Exception cause)

Specified by:
instantiationFailed in interface ComponentMonitor

invoking

public Object invoking(PicoContainer container,
                       ComponentAdapter<?> componentAdapter,
                       Member member,
                       Object instance,
                       Object[] args)

Specified by:
invoking in interface ComponentMonitor

invoked

public void invoked(PicoContainer container,
                    ComponentAdapter<?> componentAdapter,
                    Member member,
                    Object instance,
                    long duration,
                    Object[] args,
                    Object retVal)

Specified by:
invoked in interface ComponentMonitor

invocationFailed

public void invocationFailed(Member member,
                             Object instance,
                             Exception cause)

Specified by:
invocationFailed in interface ComponentMonitor

lifecycleInvocationFailed

public void lifecycleInvocationFailed(MutablePicoContainer container,
                                      ComponentAdapter<?> componentAdapter,
                                      Method method,
                                      Object instance,
                                      RuntimeException cause)

Specified by:
lifecycleInvocationFailed in interface ComponentMonitor

noComponentFound

public Object noComponentFound(MutablePicoContainer container,
                               Object componentKey)

Specified by:
noComponentFound in interface ComponentMonitor

newInjector

public Injector newInjector(Injector injector)

Specified by:
newInjector in interface ComponentMonitor

newBehavior

public Behavior newBehavior(Behavior behavior)

Specified by:
newBehavior in interface ComponentMonitor

getLogger

protected org.apache.log4j.Logger getLogger(Member member)


Copyright © 2003-2010 Codehaus. All Rights Reserved.