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
AOP Alliance
MethodInterceptor
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
or CustomizableTraceInterceptor
for pure tracing purposes.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
defaultLogger
-
Constructor Summary
ConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionlong
getCount()
Return the number of times this interceptor has been invoked.protected String
getInvocationDescription
(MethodInvocation invocation) Return a description for the given method invocation.invoke
(MethodInvocation invocation) Determines whether logging is enabled for the particularMethodInvocation
.void
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 Details
-
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:
-
-
Method Details
-
invoke
Description copied from class:AbstractTraceInterceptor
Determines whether 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:
-
getInvocationDescription
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.
-