Package org.springframework.aop.interceptor

# 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 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:
  - `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

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 logging is enabled for the particular `MethodInvocation`.
`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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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:
  - `AbstractTraceInterceptor.setUseDynamicLogger(boolean)`

## Method Details

### invoke

@Nullable public Object invoke(MethodInvocation invocation) throws Throwable
Description copied from class: `AbstractTraceInterceptor`
Determines whether logging is enabled for the particular `MethodInvocation`. If not, the method invocation proceeds as normal, otherwise the method invocation is passed to the `invokeUnderTrace` method for handling.

Specified by:
  `invoke` in interface `MethodInterceptor`
Overrides:
  `invoke` in class `AbstractTraceInterceptor`
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 class `SimpleTraceInterceptor`
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.