Package org.springframework.ws.server
Class MessageDispatcher
java.lang.Object
org.springframework.ws.server.MessageDispatcher
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.context.ApplicationContextAware
,WebServiceMessageReceiver
- Direct Known Subclasses:
SoapMessageDispatcher
public class MessageDispatcher
extends Object
implements WebServiceMessageReceiver, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware
Central dispatcher for use within Spring-WS, dispatching Web service messages to registered endpoints.
This dispatcher is quite similar to Spring MVCs DispatcherServlet
. Just like its counterpart, this dispatcher
is very flexible. This class is SOAP agnostic; in typical SOAP Web Services, the SoapMessageDispatcher
subclass is used.
- It can use any
EndpointMapping
implementation - whether standard, or provided as part of an application - to control the routing of request messages to endpoint objects. Endpoint mappings can be registered using theendpointMappings
property. - It can use any
EndpointAdapter
; this allows one to use any endpoint interface or form. Defaults to theMessageEndpointAdapter
andPayloadEndpointAdapter
, forMessageEndpoint
andPayloadEndpoint
, respectively, and theMessageMethodEndpointAdapter
andPayloadMethodEndpointAdapter
. Additional endpoint adapters can be added through theendpointAdapters
property. - Its exception resolution strategy can be specified via a
EndpointExceptionResolver
, for example mapping certain exceptions to SOAP Faults. Default is none. Additional exception resolvers can be added through theendpointExceptionResolvers
property.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
- See Also:
-
EndpointMapping
EndpointAdapter
EndpointExceptionResolver
DispatcherServlet
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Log category to use when no mapped endpoint is found for a request.protected static final org.apache.commons.logging.Log
Additional logger to use when no mapped endpoint is found for a request.protected final org.apache.commons.logging.Log
Logger available to subclasses.static final String
Log category to use for message tracing.protected static final org.apache.commons.logging.Log
Additional logger to use for received message tracing.protected static final org.apache.commons.logging.Log
Additional logger to use for sent message tracing. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
dispatch
(MessageContext messageContext) Dispatches the request in the given MessageContext according to the configuration.protected EndpointInvocationChain
getEndpoint
(MessageContext messageContext) Returns the endpoint for this request.protected EndpointAdapter
getEndpointAdapter
(Object endpoint) Returns theEndpointAdapter
for the given endpoint.Returns theEndpointAdapter
s to use by thisMessageDispatcher
.Returns theEndpointExceptionResolver
s to use by thisMessageDispatcher
.Returns theEndpointMapping
s to use by thisMessageDispatcher
.protected boolean
handleRequest
(EndpointInvocationChain mappedEndpoint, MessageContext messageContext) Callback for pre-processing of given invocation chain and message context.protected void
processEndpointException
(MessageContext messageContext, Object endpoint, Exception ex) Determine an errorSOAPMessage
response via the registeredEndpointExceptionResolvers
.void
receive
(MessageContext messageContext) Receives the given message context.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) final void
setBeanName
(String beanName) void
setEndpointAdapters
(List<EndpointAdapter> endpointAdapters) Sets theEndpointAdapter
s to use by thisMessageDispatcher
.void
setEndpointExceptionResolvers
(List<EndpointExceptionResolver> endpointExceptionResolvers) Sets theEndpointExceptionResolver
s to use by thisMessageDispatcher
.void
setEndpointMappings
(List<EndpointMapping> endpointMappings) Sets theEndpointMapping
s to use by thisMessageDispatcher
.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log loggerLogger available to subclasses. -
ENDPOINT_NOT_FOUND_LOG_CATEGORY
Log category to use when no mapped endpoint is found for a request.- See Also:
-
endpointNotFoundLogger
protected static final org.apache.commons.logging.Log endpointNotFoundLoggerAdditional logger to use when no mapped endpoint is found for a request. -
MESSAGE_TRACING_LOG_CATEGORY
Log category to use for message tracing.- See Also:
-
sentMessageTracingLogger
protected static final org.apache.commons.logging.Log sentMessageTracingLoggerAdditional logger to use for sent message tracing. -
receivedMessageTracingLogger
protected static final org.apache.commons.logging.Log receivedMessageTracingLoggerAdditional logger to use for received message tracing.
-
-
Constructor Details
-
MessageDispatcher
public MessageDispatcher()Initializes a new instance of theMessageDispatcher
.
-
-
Method Details
-
getEndpointAdapters
Returns theEndpointAdapter
s to use by thisMessageDispatcher
. -
setEndpointAdapters
Sets theEndpointAdapter
s to use by thisMessageDispatcher
. -
getEndpointExceptionResolvers
Returns theEndpointExceptionResolver
s to use by thisMessageDispatcher
. -
setEndpointExceptionResolvers
public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) Sets theEndpointExceptionResolver
s to use by thisMessageDispatcher
. -
getEndpointMappings
Returns theEndpointMapping
s to use by thisMessageDispatcher
. -
setEndpointMappings
Sets theEndpointMapping
s to use by thisMessageDispatcher
. -
setBeanName
- Specified by:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
receive
Description copied from interface:WebServiceMessageReceiver
Receives the given message context. The given message context can be used to create a response.- Specified by:
receive
in interfaceWebServiceMessageReceiver
- Parameters:
messageContext
- the message context to be received- Throws:
Exception
-
dispatch
Dispatches the request in the given MessageContext according to the configuration.- Parameters:
messageContext
- the message context- Throws:
NoEndpointFoundException
- thrown when an endpoint cannot be resolved for the incoming messageException
-
getEndpoint
Returns the endpoint for this request. All endpoint mappings are tried, in order.- Returns:
- the
EndpointInvocationChain
, ornull
if no endpoint could be found. - Throws:
Exception
-
getEndpointAdapter
Returns theEndpointAdapter
for the given endpoint.- Parameters:
endpoint
- the endpoint to find an adapter for- Returns:
- the adapter
-
handleRequest
protected boolean handleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext) Callback for pre-processing of given invocation chain and message context. Gets called before invocation ofhandleRequest
on the interceptors.Default implementation does nothing, and returns
true
.- Parameters:
mappedEndpoint
- the mappedEndpointInvocationChain
messageContext
- the message context- Returns:
true
if processing should continue;false
otherwise
-
processEndpointException
protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex) throws Exception Determine an errorSOAPMessage
response via the registeredEndpointExceptionResolvers
. Most likely, the response contains aSOAPFault
. If no suitable resolver was found, the exception is rethrown.- Parameters:
messageContext
- current SOAPMessage requestendpoint
- the executed endpoint, or null if none chosen at the time of the exceptionex
- the exception that got thrown during handler execution- Throws:
Exception
- if no suitable resolver is found
-