org.springframework.aop.interceptor

Class JamonPerformanceMonitorInterceptor

  • All Implemented Interfaces:
    java.io.Serializable, Advice, Interceptor, MethodInterceptor


    public class JamonPerformanceMonitorInterceptor
    extends AbstractMonitoringInterceptor
    Performance monitor interceptor that uses JAMon library to perform the performance measurement on the intercepted method and output the stats. In addition, it tracks/counts exceptions thrown by the intercepted method. The stack traces can be viewed in the JAMon web application.

    This code is inspired by Thierry Templier's blog.

    Since:
    1.1.3
    Author:
    Dmitriy Kopylenko, Juergen Hoeller, Rob Harrop, Steve Souza
    See Also:
    MonitorFactory, PerformanceMonitorInterceptor, Serialized Form
    • Constructor Detail

      • JamonPerformanceMonitorInterceptor

        public JamonPerformanceMonitorInterceptor()
        Create a new JamonPerformanceMonitorInterceptor with a static logger.
      • JamonPerformanceMonitorInterceptor

        public JamonPerformanceMonitorInterceptor(boolean useDynamicLogger)
        Create a new JamonPerformanceMonitorInterceptor 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)
      • JamonPerformanceMonitorInterceptor

        public JamonPerformanceMonitorInterceptor(boolean useDynamicLogger,
                                                  boolean trackAllInvocations)
        Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.
        Parameters:
        useDynamicLogger - whether to use a dynamic logger or a static logger
        trackAllInvocations - whether to track all invocations that go through this interceptor, or just invocations with trace logging enabled
        See Also:
        AbstractTraceInterceptor.setUseDynamicLogger(boolean)
    • Method Detail

      • setTrackAllInvocations

        public void setTrackAllInvocations(boolean trackAllInvocations)
        Set whether to track all invocations that go through this interceptor, or just invocations with trace logging enabled.

        Default is "false": Only invocations with trace logging enabled will be monitored. Specify "true" to let JAMon track all invocations, gathering statistics even when trace logging is disabled.

      • invokeUnderTrace

        protected java.lang.Object invokeUnderTrace(MethodInvocation invocation,
                                                    Log logger)
                                             throws java.lang.Throwable
        Wraps the invocation with a JAMon Monitor and writes the current performance statistics to the log (if enabled).
        Specified by:
        invokeUnderTrace in class AbstractTraceInterceptor
        logger - the Log to write trace messages to
        Returns:
        the result of the call to MethodInvocation.proceed()
        Throws:
        java.lang.Throwable - if the call to MethodInvocation.proceed() encountered any errors
        See Also:
        MonitorFactory.start(java.lang.String), Monitor.stop()
      • trackException

        protected void trackException(com.jamonapi.MonKey key,
                                      java.lang.Throwable ex)
        Count the thrown exception and put the stack trace in the details portion of the key. This will allow the stack trace to be viewed in the JAMon web application.