org.springframework.aop.interceptor

## Class PerformanceMonitorInterceptor

- java.lang.Object
- - org.springframework.aop.interceptor.AbstractTraceInterceptor
  - - org.springframework.aop.interceptor.AbstractMonitoringInterceptor
    - - org.springframework.aop.interceptor.PerformanceMonitorInterceptor

- All Implemented Interfaces:
    Serializable, Advice, Interceptor, MethodInterceptor

      public class PerformanceMonitorInterceptor
      extends AbstractMonitoringInterceptor

  Simple AOP Alliance `MethodInterceptor` for performance monitoring. This interceptor has no effect on the intercepted method call.

  Uses a `StopWatch` for the actual performance measuring.

  Author:
    Rod Johnson, Dmitriy Kopylenko, Rob Harrop
  See Also:
    `StopWatch`, `JamonPerformanceMonitorInterceptor`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor

      `defaultLogger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PerformanceMonitorInterceptor()` Create a new PerformanceMonitorInterceptor with a static logger.
    `PerformanceMonitorInterceptor(boolean useDynamicLogger)` Create a new PerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `invokeUnderTrace(MethodInvocation invocation, Log logger)` Subclasses must override this method to perform any tracing around the supplied `MethodInvocation`.

    - ### Methods inherited from class org.springframework.aop.interceptor.AbstractMonitoringInterceptor

      `createInvocationTraceName, getPrefix, getSuffix, setLogTargetClassInvocation, setPrefix, setSuffix`

    - ### Methods inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor

      `getClassForLogging, getLoggerForInvocation, invoke, 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 Detail

    - #### PerformanceMonitorInterceptor

          public PerformanceMonitorInterceptor()

      Create a new PerformanceMonitorInterceptor with a static logger.

    - #### PerformanceMonitorInterceptor

          public PerformanceMonitorInterceptor(boolean useDynamicLogger)

      Create a new PerformanceMonitorInterceptor with a 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

    - #### invokeUnderTrace

          protected Object invokeUnderTrace(MethodInvocation invocation,
                                            Log logger)
                                     throws Throwable

      Description copied from class: `AbstractTraceInterceptor`
      Subclasses must override this method to perform any tracing around the supplied `MethodInvocation`. Subclasses are responsible for ensuring that the `MethodInvocation` actually executes by calling `MethodInvocation.proceed()`.

      By default, the passed-in `Log` instance will have log level "trace" enabled. Subclasses do not have to check for this again, unless they overwrite the `isInterceptorEnabled` method to modify the default behavior, and may delegate to `writeToLog` for actual messages to be written.

      Specified by:
        `invokeUnderTrace` in class `AbstractTraceInterceptor`
        `logger` - the `Log` to write trace messages to
      Returns:
        the result of the call to `MethodInvocation.proceed()`
      Throws:
        `Throwable` - if the call to `MethodInvocation.proceed()` encountered any errors
      See Also:
        `AbstractTraceInterceptor.isLogEnabled(org.apache.commons.logging.Log)`, `AbstractTraceInterceptor.writeToLog(Log, String)`, `AbstractTraceInterceptor.writeToLog(Log, String, Throwable)`