Class AbstractLoggingInterceptor
java.lang.Object
org.springframework.xml.transform.TransformerObjectSupport
org.springframework.ws.server.endpoint.AbstractLoggingInterceptor
- All Implemented Interfaces:
EndpointInterceptor
- Direct Known Subclasses:
PayloadLoggingInterceptor,SoapEnvelopeLoggingInterceptor
public abstract class AbstractLoggingInterceptor
extends TransformerObjectSupport
implements EndpointInterceptor
Abstract base class for
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.- Since:
- 1.0.0
- Author:
- Arjen Poutsma
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.commons.logging.LogThe defaultLoginstance used to write trace messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterCompletion(MessageContext messageContext, Object endpoint, Exception ex) Does nothing by defaultprotected abstract SourcegetSource(WebServiceMessage message) Abstract template method that returns theSourcefor the givenWebServiceMessage.booleanhandleFault(MessageContext messageContext, Object endpoint) Does nothing by default.booleanhandleRequest(MessageContext messageContext, Object endpoint) Logs the request message payload.booleanhandleResponse(MessageContext messageContext, Object endpoint) Logs the response message payload.protected booleanDetermine whether theloggerfield is enabled.protected voidlogMessage(String message) Logs the given string message.protected voidlogMessageSource(String logMessage, Source source) voidsetLoggerName(String loggerName) Set the name of the logger to use.final voidsetLogRequest(boolean logRequest) Indicates whether the request should be logged.final voidsetLogResponse(boolean logResponse) Indicates whether the response should be logged.Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
-
Field Details
-
logger
protected transient org.apache.commons.logging.Log loggerThe defaultLoginstance used to write trace messages. This instance is mapped to the implementingClass.
-
-
Constructor Details
-
AbstractLoggingInterceptor
public AbstractLoggingInterceptor()
-
-
Method Details
-
setLogRequest
public final void setLogRequest(boolean logRequest) Indicates whether the request should be logged. Default istrue. -
setLogResponse
public final void setLogResponse(boolean logResponse) Indicates whether the response should be logged. Default istrue. -
setLoggerName
Set the name of the logger to use. The name will be passed to the underlying logger implementation through Commons Logging, getting interpreted as log category according to the logger's configuration.This can be specified to not log into the category of a class but rather into a specific named category.
- See Also:
-
LogFactory.getLog(String)org.apache.log4j.Logger#getLogger(String)Logger.getLogger(String)
-
handleRequest
public boolean handleRequest(MessageContext messageContext, Object endpoint) throws TransformerException Logs the request message payload. Logging only occurs iflogRequestis set totrue, which is the default.- Specified by:
handleRequestin interfaceEndpointInterceptor- Parameters:
messageContext- the message contextendpoint- chosen endpoint to invoke- Returns:
true- Throws:
TransformerException- when the payload cannot be transformed to a string- See Also:
-
handleResponse
Logs the response message payload. Logging only occurs iflogResponseis set totrue, which is the default.- Specified by:
handleResponsein interfaceEndpointInterceptor- Parameters:
messageContext- the message contextendpoint- chosen endpoint to invoke- Returns:
true- Throws:
TransformerException- when the payload cannot be transformed to a stringException- in case of errors- See Also:
-
handleFault
Does nothing by default. Faults are not logged.- Specified by:
handleFaultin interfaceEndpointInterceptor- Parameters:
messageContext- contains both request and response messages, the response should contains a Faultendpoint- chosen endpoint to invoke- Returns:
trueto continue processing of the response interceptor chain;falseto indicate blocking of the response handler chain.- Throws:
Exception
-
afterCompletion
Does nothing by default- Specified by:
afterCompletionin interfaceEndpointInterceptor- Parameters:
messageContext- contains both request and response messages, the response should contains a Faultendpoint- chosen endpoint to invokeex- exception thrown on handler execution, if any
-
isLogEnabled
protected boolean isLogEnabled()Determine whether theloggerfield is enabled.Default is
truewhen the "debug" level is enabled. Subclasses can override this to change the level under which logging occurs. -
logMessageSource
Logs the givensourceto thelogger, using the message as a prefix.By default, this message creates a string representation of the given source, and delegates to
logMessage(String).- Parameters:
logMessage- the log messagesource- the source to be logged- Throws:
TransformerException- in case of errors
-
logMessage
Logs the given 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.
- Parameters:
message- the message
-
getSource
Abstract template method that returns theSourcefor the givenWebServiceMessage.- Parameters:
message- the message- Returns:
- the source of the message
-