public abstract class AbstractLoggingInterceptor extends TransformerObjectSupport implements EndpointInterceptor
EndpointInterceptor
instances that log a part of a
WebServiceMessage
. By default, both request and response messages are logged, but this behaviour can be
changed using the logRequest
and logResponse
properties.Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger
The default
Log instance used to write trace messages. |
Constructor and Description |
---|
AbstractLoggingInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
afterCompletion(MessageContext messageContext,
Object endpoint,
Exception ex)
Does nothing by default
|
protected abstract Source |
getSource(WebServiceMessage message)
Abstract template method that returns the
Source for the given WebServiceMessage . |
boolean |
handleFault(MessageContext messageContext,
Object endpoint)
Does nothing by default.
|
boolean |
handleRequest(MessageContext messageContext,
Object endpoint)
Logs the request message payload.
|
boolean |
handleResponse(MessageContext messageContext,
Object endpoint)
Logs the response message payload.
|
protected boolean |
isLogEnabled()
Determine whether the
logger field is enabled. |
protected void |
logMessage(String message)
Logs the given string message.
|
protected void |
logMessageSource(String logMessage,
Source source)
|
void |
setLoggerName(String loggerName)
Set the name of the logger to use.
|
void |
setLogRequest(boolean logRequest)
Indicates whether the request should be logged.
|
void |
setLogResponse(boolean logResponse)
Indicates whether the response should be logged.
|
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
protected transient org.apache.commons.logging.Log logger
Log
instance used to write trace messages. This instance is mapped to the implementing
Class
.public final void setLogRequest(boolean logRequest)
true
.public final void setLogResponse(boolean logResponse)
true
.public void setLoggerName(String loggerName)
This can be specified to not log into the category of a class but rather into a specific named category.
LogFactory.getLog(String)
,
org.apache.log4j.Logger#getLogger(String)
,
Logger
public final boolean handleRequest(MessageContext messageContext, Object endpoint) throws TransformerException
logRequest
is set to true
,
which is the default.handleRequest
in interface EndpointInterceptor
messageContext
- the message contextendpoint
- chosen endpoint to invoketrue
TransformerException
- when the payload cannot be transformed to a stringMessageContext.getRequest()
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception
logResponse
is set to true
,
which is the default.handleResponse
in interface EndpointInterceptor
messageContext
- the message contextendpoint
- chosen endpoint to invoketrue
TransformerException
- when the payload cannot be transformed to a stringException
- in case of errorsMessageContext.getRequest()
,
MessageContext.hasResponse()
,
MessageContext.getResponse()
public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception
handleFault
in interface EndpointInterceptor
messageContext
- contains both request and response messages, the response should contains a Faultendpoint
- chosen endpoint to invoketrue
to continue processing of the response interceptor chain; false
to indicate
blocking of the response handler chain.Exception
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex)
afterCompletion
in interface EndpointInterceptor
messageContext
- contains both request and response messages, the response should contains a Faultendpoint
- chosen endpoint to invokeex
- exception thrown on handler execution, if anyprotected boolean isLogEnabled()
logger
field is enabled.
Default is true
when the "debug" level is enabled. Subclasses can override this to change the level
under which logging occurs.
protected void logMessageSource(String logMessage, Source source) throws TransformerException
source
to the logger
, using the message as a prefix.
By default, this message creates a string representation of the given source, and delegates to logMessage(String)
.
logMessage
- the log messagesource
- the source to be loggedTransformerException
- in case of errorsprotected void logMessage(String message)
By default, this method uses a "debug" level of logging. Subclasses can override this method to change the level of logging used by the logger.
message
- the messageprotected abstract Source getSource(WebServiceMessage message)
Source
for the given WebServiceMessage
.message
- the message