org.picocontainer.gems.monitors
Class CommonsLoggingComponentMonitor

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

public class CommonsLoggingComponentMonitor
extends org.picocontainer.monitors.AbstractComponentMonitor
implements java.io.Serializable

A ComponentMonitor which writes to a Commons Logging Log instance. The Log instance can either be injected or, if not set, the LogFactory 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.commons.logging.Log log
           
 
Fields inherited from class org.picocontainer.monitors.AbstractComponentMonitor
INSTANTIATED, INSTANTIATED2, INSTANTIATING, INSTANTIATION_FAILED, INVOCATION_FAILED, INVOKED, INVOKING, LIFECYCLE_INVOCATION_FAILED
 
Constructor Summary
CommonsLoggingComponentMonitor()
          Creates a CommonsLoggingComponentMonitor with no Log instance set.
CommonsLoggingComponentMonitor(java.lang.Class logClass)
          Creates a CommonsLoggingComponentMonitor with a given Log instance class.
CommonsLoggingComponentMonitor(java.lang.Class logClass, org.picocontainer.ComponentMonitor delegate)
          Creates a CommonsLoggingComponentMonitor with a given Log instance class.
CommonsLoggingComponentMonitor(org.apache.commons.logging.Log log)
          Creates a CommonsLoggingComponentMonitor with a given Log instance
CommonsLoggingComponentMonitor(org.apache.commons.logging.Log log, org.picocontainer.ComponentMonitor delegate)
          Creates a CommonsLoggingComponentMonitor with a given Log instance
CommonsLoggingComponentMonitor(java.lang.String logName)
          Creates a CommonsLoggingComponentMonitor with a given Log instance name.
CommonsLoggingComponentMonitor(java.lang.String logName, org.picocontainer.ComponentMonitor delegate)
          Creates a CommonsLoggingComponentMonitor with a given Log instance name.
 
Method Summary
protected  org.apache.commons.logging.Log getLog(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

log

private org.apache.commons.logging.Log log

delegate

private final org.picocontainer.ComponentMonitor delegate
Constructor Detail

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor()
Creates a CommonsLoggingComponentMonitor with no Log instance set. The LogFactory will be used to retrieve the Log instance at every invocation of the monitor.


CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(java.lang.Class logClass)
Creates a CommonsLoggingComponentMonitor with a given Log instance class. The class name is used to retrieve the Log instance.

Parameters:
logClass - the class of the Log

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(java.lang.String logName)
Creates a CommonsLoggingComponentMonitor with a given Log instance name. It uses the LogFactory to create the Log instance.

Parameters:
logName - the name of the Log

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(org.apache.commons.logging.Log log)
Creates a CommonsLoggingComponentMonitor with a given Log instance

Parameters:
log - the Log to write to

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(java.lang.Class logClass,
                                      org.picocontainer.ComponentMonitor delegate)
Creates a CommonsLoggingComponentMonitor with a given Log instance class. The class name is used to retrieve the Log instance.

Parameters:
logClass - the class of the Log

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(java.lang.String logName,
                                      org.picocontainer.ComponentMonitor delegate)
Creates a CommonsLoggingComponentMonitor with a given Log instance name. It uses the LogFactory to create the Log instance.

Parameters:
logName - the name of the Log

CommonsLoggingComponentMonitor

public CommonsLoggingComponentMonitor(org.apache.commons.logging.Log log,
                                      org.picocontainer.ComponentMonitor delegate)
Creates a CommonsLoggingComponentMonitor with a given Log instance

Parameters:
log - the Log to write to
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

getLog

protected org.apache.commons.logging.Log getLog(java.lang.reflect.Member member)