public class MessageDispatcher extends Object implements WebServiceMessageReceiver, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware
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.
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 the endpointMappings property.EndpointAdapter; this allows one to use any endpoint interface or form. Defaults to
the MessageEndpointAdapter and PayloadEndpointAdapter, for MessageEndpoint and
PayloadEndpoint, respectively, and the
MessageMethodEndpointAdapter and
PayloadMethodEndpointAdapter.
Additional endpoint adapters can be added through the endpointAdapters property.EndpointExceptionResolver, for example mapping certain exceptions to SOAP Faults. Default is none. Additional
exception resolvers can be added through the endpointExceptionResolvers
property.EndpointMapping,
EndpointAdapter,
EndpointExceptionResolver,
DispatcherServlet| Modifier and Type | Field and Description |
|---|---|
static String |
ENDPOINT_NOT_FOUND_LOG_CATEGORY
Log category to use when no mapped endpoint is found for a request.
|
protected static org.apache.commons.logging.Log |
endpointNotFoundLogger
Additional logger to use when no mapped endpoint is found for a request.
|
protected org.apache.commons.logging.Log |
logger
Logger available to subclasses.
|
static String |
MESSAGE_TRACING_LOG_CATEGORY
Log category to use for message tracing.
|
protected static org.apache.commons.logging.Log |
receivedMessageTracingLogger
Additional logger to use for received message tracing.
|
protected static org.apache.commons.logging.Log |
sentMessageTracingLogger
Additional logger to use for sent message tracing.
|
| Constructor and Description |
|---|
MessageDispatcher()
Initializes a new instance of the
MessageDispatcher. |
| Modifier and Type | Method and Description |
|---|---|
protected 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 the
EndpointAdapter for the given endpoint. |
List<EndpointAdapter> |
getEndpointAdapters()
Returns the
EndpointAdapters to use by this MessageDispatcher. |
List<EndpointExceptionResolver> |
getEndpointExceptionResolvers()
Returns the
EndpointExceptionResolvers to use by this MessageDispatcher. |
List<EndpointMapping> |
getEndpointMappings()
Returns the
EndpointMappings to use by this MessageDispatcher. |
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 error
SOAPMessage response via the registered EndpointExceptionResolvers. |
void |
receive(MessageContext messageContext)
Receives the given message context.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBeanName(String beanName) |
void |
setEndpointAdapters(List<EndpointAdapter> endpointAdapters)
Sets the
EndpointAdapters to use by this MessageDispatcher. |
void |
setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers)
Sets the
EndpointExceptionResolvers to use by this MessageDispatcher. |
void |
setEndpointMappings(List<EndpointMapping> endpointMappings)
Sets the
EndpointMappings to use by this MessageDispatcher. |
protected final org.apache.commons.logging.Log logger
public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY
protected static final org.apache.commons.logging.Log endpointNotFoundLogger
public static final String MESSAGE_TRACING_LOG_CATEGORY
protected static final org.apache.commons.logging.Log sentMessageTracingLogger
protected static final org.apache.commons.logging.Log receivedMessageTracingLogger
public MessageDispatcher()
MessageDispatcher.public List<EndpointAdapter> getEndpointAdapters()
EndpointAdapters to use by this MessageDispatcher.public void setEndpointAdapters(List<EndpointAdapter> endpointAdapters)
EndpointAdapters to use by this MessageDispatcher.public List<EndpointExceptionResolver> getEndpointExceptionResolvers()
EndpointExceptionResolvers to use by this MessageDispatcher.public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers)
EndpointExceptionResolvers to use by this MessageDispatcher.public List<EndpointMapping> getEndpointMappings()
EndpointMappings to use by this MessageDispatcher.public void setEndpointMappings(List<EndpointMapping> endpointMappings)
EndpointMappings to use by this MessageDispatcher.public final void setBeanName(String beanName)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic void receive(MessageContext messageContext) throws Exception
WebServiceMessageReceiverreceive in interface WebServiceMessageReceivermessageContext - the message context to be receivedExceptionprotected final void dispatch(MessageContext messageContext) throws Exception
messageContext - the message contextNoEndpointFoundException - thrown when an endpoint cannot be resolved for the incoming messageExceptionprotected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception
EndpointInvocationChain, or null if no endpoint could be found.Exceptionprotected EndpointAdapter getEndpointAdapter(Object endpoint)
EndpointAdapter for the given endpoint.endpoint - the endpoint to find an adapter forprotected boolean handleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext)
handleRequest on the interceptors.
Default implementation does nothing, and returns true.
mappedEndpoint - the mapped EndpointInvocationChainmessageContext - the message contexttrue if processing should continue; false otherwiseprotected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex) throws Exception
SOAPMessage response via the registered EndpointExceptionResolvers.
Most likely, the response contains a SOAPFault. If no suitable resolver was found, the exception is
rethrown.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 executionException - if no suitable resolver is foundCopyright © 2020 Pivotal Software. All rights reserved.