public class MessageDispatcher extends Object implements WebServiceMessageReceiver, BeanNameAware, 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
EndpointAdapter s to use by this MessageDispatcher . |
List<EndpointExceptionResolver> |
getEndpointExceptionResolvers()
Returns the
EndpointExceptionResolver s to use by this MessageDispatcher . |
List<EndpointMapping> |
getEndpointMappings()
Returns the
EndpointMapping s 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(ApplicationContext applicationContext) |
void |
setBeanName(String beanName) |
void |
setEndpointAdapters(List<EndpointAdapter> endpointAdapters)
Sets the
EndpointAdapter s to use by this MessageDispatcher . |
void |
setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers)
Sets the
EndpointExceptionResolver s to use by this MessageDispatcher . |
void |
setEndpointMappings(List<EndpointMapping> endpointMappings)
Sets the
EndpointMapping s 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()
EndpointAdapter
s to use by this MessageDispatcher
.public void setEndpointAdapters(List<EndpointAdapter> endpointAdapters)
EndpointAdapter
s to use by this MessageDispatcher
.public List<EndpointExceptionResolver> getEndpointExceptionResolvers()
EndpointExceptionResolver
s to use by this MessageDispatcher
.public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers)
EndpointExceptionResolver
s to use by this MessageDispatcher
.public List<EndpointMapping> getEndpointMappings()
EndpointMapping
s to use by this MessageDispatcher
.public void setEndpointMappings(List<EndpointMapping> endpointMappings)
EndpointMapping
s to use by this MessageDispatcher
.public final void setBeanName(String beanName)
setBeanName
in interface BeanNameAware
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void receive(MessageContext messageContext) throws Exception
WebServiceMessageReceiver
receive
in interface WebServiceMessageReceiver
messageContext
- the message context to be receivedException
protected final void dispatch(MessageContext messageContext) throws Exception
messageContext
- the message contextNoEndpointFoundException
- thrown when an endpoint cannot be resolved for the incoming messageException
protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception
EndpointInvocationChain
, or null
if no endpoint could be found.Exception
protected 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 EndpointInvocationChain
messageContext
- 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 found