org.picocontainer.gems.monitors
Class Log4JComponentMonitor

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

public class Log4JComponentMonitor
extends org.picocontainer.monitors.AbstractComponentMonitor
implements java.io.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.

Version:
$Revision: $
Author:
Paul Hammant, Mauro Talevi
See Also:
Serialized Form

Field Summary
private  org.picocontainer.ComponentMonitor delegate
           
private  org.apache.log4j.Logger logger
           
 
Fields inherited from class org.picocontainer.monitors.AbstractComponentMonitor
INSTANTIATED, INSTANTIATED2, INSTANTIATING, INSTANTIATION_FAILED, INVOCATION_FAILED, INVOKED, INVOKING, LIFECYCLE_INVOCATION_FAILED
 
Constructor Summary
Log4JComponentMonitor()
          Creates a Log4JComponentMonitor with no Logger instance set.
Log4JComponentMonitor(java.lang.Class loggerClass)
          Creates a Log4JComponentMonitor with a given Logger instance class.
Log4JComponentMonitor(java.lang.Class loggerClass, org.picocontainer.ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance class.
Log4JComponentMonitor(org.picocontainer.ComponentMonitor delegate)
           
Log4JComponentMonitor(org.apache.log4j.Logger logger)
          Creates a Log4JComponentMonitor with a given Logger instance
Log4JComponentMonitor(org.apache.log4j.Logger logger, org.picocontainer.ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance
Log4JComponentMonitor(java.lang.String loggerName)
          Creates a Log4JComponentMonitor with a given Logger instance name.
Log4JComponentMonitor(java.lang.String loggerName, org.picocontainer.ComponentMonitor delegate)
          Creates a Log4JComponentMonitor with a given Logger instance name.
 
Method Summary
protected  org.apache.log4j.Logger getLogger(java.lang.reflect.Member member)
           
 void instantiated(java.lang.reflect.Constructor constructor, long duration)
           
 void instantiated(java.lang.reflect.Constructor constructor, java.lang.Object instantiated, java.lang.Object[] parameters, long duration)
           
 void instantiating(java.lang.reflect.Constructor constructor)
           
 void instantiationFailed(java.lang.reflect.Constructor constructor, java.lang.Exception cause)
           
 void invocationFailed(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Exception cause)
           
 void invoked(java.lang.reflect.Method method, java.lang.Object instance, long duration)
           
 void invoking(java.lang.reflect.Method method, java.lang.Object instance)
           
 void lifecycleInvocationFailed(java.lang.reflect.Method method, java.lang.Object instance, java.lang.RuntimeException cause)
           
 
Methods inherited from class org.picocontainer.monitors.AbstractComponentMonitor
format, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.apache.log4j.Logger logger

delegate

private final org.picocontainer.ComponentMonitor delegate
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(java.lang.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(java.lang.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(java.lang.Class loggerClass,
                             org.picocontainer.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

Log4JComponentMonitor

public Log4JComponentMonitor(java.lang.String loggerName,
                             org.picocontainer.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

Log4JComponentMonitor

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

Parameters:
logger - the Logger to write to

Log4JComponentMonitor

public Log4JComponentMonitor(org.picocontainer.ComponentMonitor delegate)
Method Detail

instantiating

public void instantiating(java.lang.reflect.Constructor constructor)
Specified by:
instantiating in interface org.picocontainer.ComponentMonitor

instantiated

public void instantiated(java.lang.reflect.Constructor constructor,
                         long duration)
Specified by:
instantiated in interface org.picocontainer.ComponentMonitor

instantiated

public void instantiated(java.lang.reflect.Constructor constructor,
                         java.lang.Object instantiated,
                         java.lang.Object[] parameters,
                         long duration)
Specified by:
instantiated in interface org.picocontainer.ComponentMonitor

instantiationFailed

public void instantiationFailed(java.lang.reflect.Constructor constructor,
                                java.lang.Exception cause)
Specified by:
instantiationFailed in interface org.picocontainer.ComponentMonitor

invoking

public void invoking(java.lang.reflect.Method method,
                     java.lang.Object instance)
Specified by:
invoking in interface org.picocontainer.ComponentMonitor

invoked

public void invoked(java.lang.reflect.Method method,
                    java.lang.Object instance,
                    long duration)
Specified by:
invoked in interface org.picocontainer.ComponentMonitor

invocationFailed

public void invocationFailed(java.lang.reflect.Method method,
                             java.lang.Object instance,
                             java.lang.Exception cause)
Specified by:
invocationFailed in interface org.picocontainer.ComponentMonitor

lifecycleInvocationFailed

public void lifecycleInvocationFailed(java.lang.reflect.Method method,
                                      java.lang.Object instance,
                                      java.lang.RuntimeException cause)
Specified by:
lifecycleInvocationFailed in interface org.picocontainer.ComponentMonitor

getLogger

protected org.apache.log4j.Logger getLogger(java.lang.reflect.Member member)