public class TracingMethodListener extends Object implements MethodExecutionListener
ResultSet, proxying result set needs to be enabled.| Modifier and Type | Class and Description |
|---|---|
static interface |
TracingMethodListener.TracingCondition
Functional interface to decide whether to perform tracing.
|
static interface |
TracingMethodListener.TracingMessageConsumer
Functional interface to consume log message.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
parameterDisplayLength |
protected TracingMethodListener.TracingCondition |
tracingCondition |
protected TracingMethodListener.TracingMessageConsumer |
tracingMessageConsumer |
DEFAULT| Constructor and Description |
|---|
TracingMethodListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterMethod(MethodExecutionContext executionContext) |
void |
beforeMethod(MethodExecutionContext executionContext) |
protected String |
constructMessage(long seq,
Throwable thrown,
long execTime,
String connectionId,
Class<?> targetClass,
Method method,
String args)
Construct a message to log.
|
protected String |
getArguments(Object[] args)
Convert method parameters to a string.
|
protected String |
getDisplayParameter(String parameter)
Construct parameter value to display.
|
protected String |
getParameterAsString(Object arg)
Convert single parameter to String.
|
protected String |
getSingleArgDisplayParameter(String parameter)
Construct display string for parameter.
|
protected String |
getSingleArgParameterAsString(Object arg)
Convert single parameter to String.
|
TracingMethodListener.TracingCondition |
getTracingCondition() |
TracingMethodListener.TracingMessageConsumer |
getTracingMessageConsumer() |
protected void |
logMessage(String message)
log message
Default implementation delegates to consumer that writes out to console.
|
void |
setParameterDisplayLength(int parameterDisplayLength) |
void |
setTracingCondition(TracingMethodListener.TracingCondition tracingCondition) |
void |
setTracingMessageConsumer(TracingMethodListener.TracingMessageConsumer tracingMessageConsumer) |
protected int parameterDisplayLength
protected TracingMethodListener.TracingCondition tracingCondition
protected TracingMethodListener.TracingMessageConsumer tracingMessageConsumer
public void beforeMethod(MethodExecutionContext executionContext)
beforeMethod in interface MethodExecutionListenerpublic void afterMethod(MethodExecutionContext executionContext)
afterMethod in interface MethodExecutionListenerprotected String getArguments(Object[] args)
args - argument for the invoked methodprotected String getSingleArgParameterAsString(Object arg)
arg - method parameterprotected String getSingleArgDisplayParameter(String parameter)
parameter - parameter value as stringprotected String getParameterAsString(Object arg)
arg - method parameterprotected String getDisplayParameter(String parameter)
parameter - parameter value as stringprotected String constructMessage(long seq, Throwable thrown, long execTime, String connectionId, Class<?> targetClass, Method method, String args)
seq - sequence numberthrown - thrown exceptionexecTime - time took to perform the methodconnectionId - connection idtargetClass - invoked classmethod - invoked methodargs - method arguments(parameters)protected void logMessage(String message)
message - message to logpublic void setParameterDisplayLength(int parameterDisplayLength)
public TracingMethodListener.TracingCondition getTracingCondition()
public void setTracingCondition(TracingMethodListener.TracingCondition tracingCondition)
public TracingMethodListener.TracingMessageConsumer getTracingMessageConsumer()
public void setTracingMessageConsumer(TracingMethodListener.TracingMessageConsumer tracingMessageConsumer)
Copyright © 2023. All rights reserved.