public class JamonPerformanceMonitorInterceptor extends AbstractMonitoringInterceptor
This code is inspired by Thierry Templier's blog.
MonitorFactory
,
PerformanceMonitorInterceptor
,
Serialized FormdefaultLogger
Constructor and Description |
---|
JamonPerformanceMonitorInterceptor()
Create a new JamonPerformanceMonitorInterceptor with a static logger.
|
JamonPerformanceMonitorInterceptor(boolean useDynamicLogger)
Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger,
according to the given flag.
|
JamonPerformanceMonitorInterceptor(boolean useDynamicLogger,
boolean trackAllInvocations)
Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger,
according to the given flag.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
invokeUnderTrace(MethodInvocation invocation,
Log logger)
Wraps the invocation with a JAMon Monitor and writes the current
performance statistics to the log (if enabled).
|
protected boolean |
isInterceptorEnabled(MethodInvocation invocation,
Log logger)
Always applies the interceptor if the "trackAllInvocations" flag has been set;
else just kicks in if the log is enabled.
|
void |
setTrackAllInvocations(boolean trackAllInvocations)
Set whether to track all invocations that go through this interceptor,
or just invocations with trace logging enabled.
|
protected void |
trackException(com.jamonapi.MonKey key,
Throwable ex)
Count the thrown exception and put the stack trace in the details portion of the key.
|
createInvocationTraceName, getPrefix, getSuffix, setLogTargetClassInvocation, setPrefix, setSuffix
getClassForLogging, getLoggerForInvocation, invoke, isLogEnabled, setHideProxyClassNames, setLogExceptionStackTrace, setLoggerName, setUseDynamicLogger, writeToLog, writeToLog
public JamonPerformanceMonitorInterceptor()
public JamonPerformanceMonitorInterceptor(boolean useDynamicLogger)
useDynamicLogger
- whether to use a dynamic logger or a static loggerAbstractTraceInterceptor.setUseDynamicLogger(boolean)
public JamonPerformanceMonitorInterceptor(boolean useDynamicLogger, boolean trackAllInvocations)
useDynamicLogger
- whether to use a dynamic logger or a static loggertrackAllInvocations
- whether to track all invocations that go through
this interceptor, or just invocations with trace logging enabledAbstractTraceInterceptor.setUseDynamicLogger(boolean)
public void setTrackAllInvocations(boolean trackAllInvocations)
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.
protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger)
isInterceptorEnabled
in class AbstractTraceInterceptor
invocation
- the MethodInvocation
being tracedlogger
- the Log
instance to checksetTrackAllInvocations(boolean)
,
AbstractTraceInterceptor.isLogEnabled(org.apache.commons.logging.Log)
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable
invokeUnderTrace
in class AbstractTraceInterceptor
logger
- the Log
to write trace messages toMethodInvocation.proceed()
Throwable
- if the call to MethodInvocation.proceed()
encountered any errorsMonitorFactory.start(java.lang.String)
,
Monitor.stop()
protected void trackException(com.jamonapi.MonKey key, Throwable ex)