Class SimpleTraceInterceptor
- java.lang.Object
- org.springframework.aop.interceptor.AbstractTraceInterceptor
- org.springframework.aop.interceptor.SimpleTraceInterceptor
- All Implemented Interfaces:
Serializable,Advice,Interceptor,MethodInterceptor
- Direct Known Subclasses:
DebugInterceptor
public class SimpleTraceInterceptor extends AbstractTraceInterceptor
Simple AOP AllianceMethodInterceptorthat can be introduced in a chain to display verbose trace information about intercepted method invocations, with method entry and method exit info.Consider using
CustomizableTraceInterceptorfor more advanced needs.- Since:
- 1.2
- Author:
- Dmitriy Kopylenko, Juergen Hoeller
- See Also:
CustomizableTraceInterceptor, Serialized Form
Field Summary
Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
defaultLogger
Constructor Summary
Constructors Constructor Description SimpleTraceInterceptor()Create a new SimpleTraceInterceptor with a static logger.SimpleTraceInterceptor(boolean useDynamicLogger)Create a new SimpleTraceInterceptor with dynamic or static logger, according to the given flag.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetInvocationDescription(MethodInvocation invocation)Return a description for the given method invocation.protected ObjectinvokeUnderTrace(MethodInvocation invocation, Log logger)Subclasses must override this method to perform any tracing around the suppliedMethodInvocation.Methods inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
getClassForLogging, getLoggerForInvocation, invoke, isInterceptorEnabled, isLogEnabled, setHideProxyClassNames, setLogExceptionStackTrace, setLoggerName, setUseDynamicLogger, writeToLog, writeToLog
Constructor Detail
SimpleTraceInterceptor
public SimpleTraceInterceptor()
Create a new SimpleTraceInterceptor with a static logger.
SimpleTraceInterceptor
public SimpleTraceInterceptor(boolean useDynamicLogger)
Create a new SimpleTraceInterceptor 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
invokeUnderTrace
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable
Description copied from class:AbstractTraceInterceptorSubclasses must override this method to perform any tracing around the suppliedMethodInvocation. Subclasses are responsible for ensuring that theMethodInvocationactually executes by callingMethodInvocation.proceed().By default, the passed-in
Loginstance will have log level "trace" enabled. Subclasses do not have to check for this again, unless they overwrite theisInterceptorEnabledmethod to modify the default behavior, and may delegate towriteToLogfor actual messages to be written.- Specified by:
invokeUnderTracein classAbstractTraceInterceptorlogger- theLogto write trace messages to- Returns:
- the result of the call to
MethodInvocation.proceed() - Throws:
Throwable- if the call toMethodInvocation.proceed()encountered any errors- See Also:
AbstractTraceInterceptor.isLogEnabled(org.apache.commons.logging.Log),AbstractTraceInterceptor.writeToLog(Log, String),AbstractTraceInterceptor.writeToLog(Log, String, Throwable)
getInvocationDescription
protected String getInvocationDescription(MethodInvocation invocation)
Return a description for the given method invocation.- Parameters:
invocation- the invocation to describe- Returns:
- the description