Class DebugInterceptor
- java.lang.Object
- org.springframework.aop.interceptor.AbstractTraceInterceptor
- org.springframework.aop.interceptor.SimpleTraceInterceptor
- org.springframework.aop.interceptor.DebugInterceptor
- All Implemented Interfaces:
Serializable,Advice,Interceptor,MethodInterceptor
public class DebugInterceptor extends SimpleTraceInterceptor
AOP AllianceMethodInterceptorthat can be introduced in a chain to display verbose information about intercepted invocations to the logger.Logs full invocation details on method entry and method exit, including invocation arguments and invocation count. This is only intended for debugging purposes; use
SimpleTraceInterceptororCustomizableTraceInterceptorfor pure tracing purposes.- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
SimpleTraceInterceptor,CustomizableTraceInterceptor, Serialized Form
Field Summary
Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
defaultLogger
Constructor Summary
Constructors Constructor Description DebugInterceptor()Create a new DebugInterceptor with a static logger.DebugInterceptor(boolean useDynamicLogger)Create a new DebugInterceptor with dynamic or static logger, according to the given flag.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Return the number of times this interceptor has been invoked.protected StringgetInvocationDescription(MethodInvocation invocation)Return a description for the given method invocation.Objectinvoke(MethodInvocation invocation)Determines whether or not logging is enabled for the particularMethodInvocation.voidresetCount()Reset the invocation count to zero.Methods inherited from class org.springframework.aop.interceptor.SimpleTraceInterceptor
invokeUnderTrace
Methods inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
getClassForLogging, getLoggerForInvocation, isInterceptorEnabled, isLogEnabled, setHideProxyClassNames, setLogExceptionStackTrace, setLoggerName, setUseDynamicLogger, writeToLog, writeToLog
Constructor Detail
DebugInterceptor
public DebugInterceptor()
Create a new DebugInterceptor with a static logger.
DebugInterceptor
public DebugInterceptor(boolean useDynamicLogger)
Create a new DebugInterceptor 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
invoke
public Object invoke(MethodInvocation invocation) throws Throwable
Description copied from class:AbstractTraceInterceptorDetermines whether or not logging is enabled for the particularMethodInvocation. If not, the method invocation proceeds as normal, otherwise the method invocation is passed to theinvokeUnderTracemethod for handling.- Specified by:
invokein interfaceMethodInterceptor- Overrides:
invokein classAbstractTraceInterceptor- Parameters:
invocation- the method invocation joinpoint- Returns:
- the result of the call to
Joinpoint.proceed(); might be intercepted by the interceptor - Throws:
Throwable- if the interceptors or the target object throws an exception- See Also:
AbstractTraceInterceptor.invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
getInvocationDescription
protected String getInvocationDescription(MethodInvocation invocation)
Description copied from class:SimpleTraceInterceptorReturn a description for the given method invocation.- Overrides:
getInvocationDescriptionin classSimpleTraceInterceptor- Parameters:
invocation- the invocation to describe- Returns:
- the description
getCount
public long getCount()
Return the number of times this interceptor has been invoked.
resetCount
public void resetCount()
Reset the invocation count to zero.