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 and 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

    Methods
    Modifier and Type | Method and 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 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, setLoggerName, setUseDynamicLogger`

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

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

- - ### 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 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`
      Throws:
        `Throwable`
      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.