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
EndpointMappingimplementation - 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 theendpointMappingsproperty. - It can use any
EndpointAdapter; this allows one to use any endpoint interface or form. Defaults to theMessageEndpointAdapterandPayloadEndpointAdapter, forMessageEndpointandPayloadEndpoint, respectively, and theMessageMethodEndpointAdapterandPayloadMethodEndpointAdapter. Additional endpoint adapters can be added through theendpointAdaptersproperty. - 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 theendpointExceptionResolversproperty.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
- See Also:
-
EndpointMappingEndpointAdapterEndpointExceptionResolverDispatcherServlet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringLog category to use when no mapped endpoint is found for a request.protected static final org.apache.commons.logging.LogAdditional logger to use when no mapped endpoint is found for a request.protected final org.apache.commons.logging.LogLogger available to subclasses.static final StringLog category to use for message tracing.protected static final org.apache.commons.logging.LogAdditional logger to use for received message tracing.protected static final org.apache.commons.logging.LogAdditional logger to use for sent message tracing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voiddispatch(MessageContext messageContext) Dispatches the request in the given MessageContext according to the configuration.protected EndpointInvocationChaingetEndpoint(MessageContext messageContext) Returns the endpoint for this request.protected EndpointAdaptergetEndpointAdapter(Object endpoint) Returns theEndpointAdapterfor the given endpoint.Returns theEndpointAdapters to use by thisMessageDispatcher.Returns theEndpointExceptionResolvers to use by thisMessageDispatcher.Returns theEndpointMappings to use by thisMessageDispatcher.protected booleanhandleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext) Callback for pre-processing of given invocation chain and message context.protected voidprocessEndpointException(MessageContext messageContext, Object endpoint, Exception ex) Determine an errorSOAPMessageresponse via the registeredEndpointExceptionResolvers.voidreceive(MessageContext messageContext) Receives the given message context.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) final voidsetBeanName(String beanName) voidsetEndpointAdapters(List<EndpointAdapter> endpointAdapters) Sets theEndpointAdapters to use by thisMessageDispatcher.voidsetEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) Sets theEndpointExceptionResolvers to use by thisMessageDispatcher.voidsetEndpointMappings(List<EndpointMapping> endpointMappings) Sets theEndpointMappings 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 theEndpointAdapters to use by thisMessageDispatcher. -
setEndpointAdapters
Sets theEndpointAdapters to use by thisMessageDispatcher. -
getEndpointExceptionResolvers
Returns theEndpointExceptionResolvers to use by thisMessageDispatcher. -
setEndpointExceptionResolvers
public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers) Sets theEndpointExceptionResolvers to use by thisMessageDispatcher. -
getEndpointMappings
Returns theEndpointMappings to use by thisMessageDispatcher. -
setEndpointMappings
Sets theEndpointMappings to use by thisMessageDispatcher. -
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
receive
Description copied from interface:WebServiceMessageReceiverReceives the given message context. The given message context can be used to create a response.- Specified by:
receivein 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, ornullif no endpoint could be found. - Throws:
Exception
-
getEndpointAdapter
Returns theEndpointAdapterfor 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 ofhandleRequeston the interceptors.Default implementation does nothing, and returns
true.- Parameters:
mappedEndpoint- the mappedEndpointInvocationChainmessageContext- the message context- Returns:
trueif processing should continue;falseotherwise
-
processEndpointException
protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex) throws Exception Determine an errorSOAPMessageresponse 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
-