|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.aop.interceptor.AbstractTraceInterceptor
public abstract class AbstractTraceInterceptor
Base MethodInterceptor
implementation for tracing.
By default, log messages are written to the log for the interceptor class,
not the class which is being intercepted. Setting the useDynamicLog
bean property to true
causes all log messages to be written to
the Log
for the target class being intercepted.
Subclasses must implement the invokeUnderTrace
method, which
is invoked by this class ONLY when a particularinvocation SHOULD be traced.
Subclasses should write to the Log
instance provided.
setUseDynamicLogger(boolean)
,
invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
,
Serialized FormField Summary | |
---|---|
protected Log |
defaultLogger
The default Log instance used to write trace messages. |
Constructor Summary | |
---|---|
AbstractTraceInterceptor()
|
Method Summary | |
---|---|
protected Log |
getLoggerForInvocation(MethodInvocation invocation)
Return the appropriate Log instance to use for the given
MethodInvocation . |
Object |
invoke(MethodInvocation invocation)
Determines whether or not logging is enabled for the particular MethodInvocation . |
protected abstract Object |
invokeUnderTrace(MethodInvocation invocation,
Log logger)
Subclasses must override this method to perform any tracing around the supplied MethodInvocation . |
void |
setUseDynamicLogger(boolean useDynamicLog)
Set whether to use a dynamic logger or a static logger. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient Log defaultLogger
Log
instance used to write trace messages.
This instance is mapped to the implementing Class
.
Constructor Detail |
---|
public AbstractTraceInterceptor()
Method Detail |
---|
public void setUseDynamicLogger(boolean useDynamicLog)
Used to determine which Log
instance should be used to write
log messages for a particular method invocation: a dynamic one for the
Class
getting called, or a static one for the Class
of the trace interceptor.
getLoggerForInvocation(org.aopalliance.intercept.MethodInvocation)
public Object invoke(MethodInvocation invocation) throws Throwable
MethodInvocation
.
If not, the method invocation proceeds as normal, otherwise the method invocation is passed
to the invokeUnderTrace
method for handling.
invoke
in interface MethodInterceptor
Throwable
invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
protected Log getLoggerForInvocation(MethodInvocation invocation)
Log
instance to use for the given
MethodInvocation
. If the useDynamicLogger
flag
is set, the Log
instance will be for the target class of the
MethodInvocation
, otherwise the Log
will be the
default static logger.
invocation
- the MethodInvocation
being traced
Log
instance to usesetUseDynamicLogger(boolean)
protected abstract Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable
MethodInvocation
. Subclasses are responsible for
ensuring that the MethodInvocation
actually executes by
calling MethodInvocation.proceed()
.
The passed-in Log
instance will have log level "trace"
enabled. Subclasses do not have to check for this again.
logger
- the Log
to write trace messages to
MethodInvocation.proceed()
Throwable
- if the call to MethodInvocation.proceed()
encountered any errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |