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
Simple AOP Alliance
MethodInterceptor
that can be introduced
in a chain to display verbose trace information about intercepted method
invocations, with method entry and method exit info.
Consider using CustomizableTraceInterceptor
for more
advanced needs.
- Since:
- 1.2
- Author:
- Dmitriy Kopylenko, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.aop.interceptor.AbstractTraceInterceptor
defaultLogger
-
Constructor Summary
ConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionprotected String
getInvocationDescription
(MethodInvocation invocation) Return a description for the given method invocation.protected Object
invokeUnderTrace
(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 Details
-
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:
-
-
Method Details
-
invokeUnderTrace
Description copied from class:AbstractTraceInterceptor
Subclasses must override this method to perform any tracing around the suppliedMethodInvocation
. Subclasses are responsible for ensuring that theMethodInvocation
actually executes by callingMethodInvocation.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 theisInterceptorEnabled
method to modify the default behavior, and may delegate towriteToLog
for actual messages to be written.- Specified by:
invokeUnderTrace
in classAbstractTraceInterceptor
logger
- theLog
to 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:
-
getInvocationDescription
Return a description for the given method invocation.- Parameters:
invocation
- the invocation to describe- Returns:
- the description
-