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 AllianceMethodInterceptor
that 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
SimpleTraceInterceptor
orCustomizableTraceInterceptor
for 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 long
getCount()
Return the number of times this interceptor has been invoked.protected String
getInvocationDescription(MethodInvocation invocation)
Return a description for the given method invocation.Object
invoke(MethodInvocation invocation)
Determines whether or not logging is enabled for the particularMethodInvocation
.void
resetCount()
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:AbstractTraceInterceptor
Determines whether or not logging is enabled for the particularMethodInvocation
. If not, the method invocation proceeds as normal, otherwise the method invocation is passed to theinvokeUnderTrace
method for handling.- Specified by:
invoke
in interfaceMethodInterceptor
- Overrides:
invoke
in 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:SimpleTraceInterceptor
Return a description for the given method invocation.- Overrides:
getInvocationDescription
in 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.