Spring Framework

org.springframework.aop.interceptor
Class SimpleTraceInterceptor

java.lang.Object
  extended by org.springframework.aop.interceptor.AbstractTraceInterceptor
      extended by org.springframework.aop.interceptor.SimpleTraceInterceptor
All Implemented Interfaces:
java.io.Serializable, org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
Direct Known Subclasses:
DebugInterceptor

public class SimpleTraceInterceptor
extends AbstractTraceInterceptor

Simple AOP Alliance MethodInterceptor that can be introduced in a chain to display verbose trace information about intercepted method invocations, with method entry and method exit info.

Consider using CustomizableTraceInterceptor for more advanced needs.

Since:
1.2
Author:
Dmitriy Kopylenko, Juergen Hoeller
See Also:
CustomizableTraceInterceptor, Serialized Form

Field Summary
 
Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
defaultLogger
 
Constructor Summary
SimpleTraceInterceptor()
          Create a new SimpleTraceInterceptor with a static logger.
SimpleTraceInterceptor(boolean useDynamicLogger)
          Create a new SimpleTraceInterceptor with dynamic or static logger, according to the given flag.
 
Method Summary
protected  java.lang.String getInvocationDescription(org.aopalliance.intercept.MethodInvocation invocation)
          Return a description for the given method invocation.
protected  java.lang.Object invokeUnderTrace(org.aopalliance.intercept.MethodInvocation invocation, org.apache.commons.logging.Log logger)
          Subclasses must override this method to perform any tracing around the supplied MethodInvocation.
 
Methods inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
getClassForLogging, getLoggerForInvocation, invoke, isInterceptorEnabled, isLogEnabled, setHideProxyClassNames, setLoggerName, setUseDynamicLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTraceInterceptor

public SimpleTraceInterceptor()
Create a new SimpleTraceInterceptor with a static logger.


SimpleTraceInterceptor

public SimpleTraceInterceptor(boolean useDynamicLogger)
Create a new SimpleTraceInterceptor with dynamic or static logger, according to the given flag.

Parameters:
useDynamicLogger - whether to use a dynamic logger or a static logger
See Also:
AbstractTraceInterceptor.setUseDynamicLogger(boolean)
Method Detail

invokeUnderTrace

protected java.lang.Object invokeUnderTrace(org.aopalliance.intercept.MethodInvocation invocation,
                                            org.apache.commons.logging.Log logger)
                                     throws java.lang.Throwable
Description copied from class: AbstractTraceInterceptor
Subclasses must override this method to perform any tracing around the supplied MethodInvocation. Subclasses are responsible for ensuring that the MethodInvocation actually executes by calling MethodInvocation.proceed().

By default, the passed-in Log instance will have log level "trace" enabled. Subclasses do not have to check for this again, unless they overwrite the isInterceptorEnabled method to modify the default behavior.

Specified by:
invokeUnderTrace in class AbstractTraceInterceptor
logger - the Log to write trace messages to
Returns:
the result of the call to MethodInvocation.proceed()
Throws:
java.lang.Throwable - if the call to MethodInvocation.proceed() encountered any errors
See Also:
AbstractTraceInterceptor.isInterceptorEnabled(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log), AbstractTraceInterceptor.isLogEnabled(org.apache.commons.logging.Log)

getInvocationDescription

protected java.lang.String getInvocationDescription(org.aopalliance.intercept.MethodInvocation invocation)
Return a description for the given method invocation.

Parameters:
invocation - the invocation to describe
Returns:
the description

Spring Framework