Spring Web Services Framework

org.springframework.ws.server
Class MessageDispatcher

java.lang.Object
  extended by org.springframework.ws.server.MessageDispatcher
All Implemented Interfaces:
BeanNameAware, ApplicationContextAware, WebServiceMessageReceiver
Direct Known Subclasses:
SoapMessageDispatcher

public class MessageDispatcher
extends Object
implements WebServiceMessageReceiver, BeanNameAware, 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.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
EndpointMapping, EndpointAdapter, EndpointExceptionResolver, DispatcherServlet

Field Summary
static String ENDPOINT_NOT_FOUND_LOG_CATEGORY
          Log category to use when no mapped endpoint is found for a request.
protected static Log endpointNotFoundLogger
          Additional logger to use when no mapped endpoint is found for a request.
protected  Log logger
          Logger available to subclasses.
static String MESSAGE_TRACING_LOG_CATEGORY
          Log category to use for message tracing.
protected static Log receivedMessageTracingLogger
          Additional logger to use for received message tracing.
protected static Log sentMessageTracingLogger
          Additional logger to use for sent message tracing.
 
Constructor Summary
MessageDispatcher()
          Initializes a new instance of the MessageDispatcher.
 
Method Summary
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 getEndpointAdapters()
          Returns the EndpointAdapters to use by this MessageDispatcher.
 List getEndpointExceptionResolvers()
          Returns the EndpointExceptionResolvers to use by this MessageDispatcher.
 List 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(ApplicationContext applicationContext)
           
 void setBeanName(String beanName)
           
 void setEndpointAdapters(List endpointAdapters)
          Sets the EndpointAdapters to use by this MessageDispatcher.
 void setEndpointExceptionResolvers(List endpointExceptionResolvers)
          Sets the EndpointExceptionResolvers to use by this MessageDispatcher.
 void setEndpointMappings(List endpointMappings)
          Sets the EndpointMappings to use by this MessageDispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses.


ENDPOINT_NOT_FOUND_LOG_CATEGORY

public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY
Log category to use when no mapped endpoint is found for a request.

See Also:
Constant Field Values

endpointNotFoundLogger

protected static final Log endpointNotFoundLogger
Additional logger to use when no mapped endpoint is found for a request.


MESSAGE_TRACING_LOG_CATEGORY

public static final String MESSAGE_TRACING_LOG_CATEGORY
Log category to use for message tracing.

See Also:
Constant Field Values

sentMessageTracingLogger

protected static final Log sentMessageTracingLogger
Additional logger to use for sent message tracing.


receivedMessageTracingLogger

protected static final Log receivedMessageTracingLogger
Additional logger to use for received message tracing.

Constructor Detail

MessageDispatcher

public MessageDispatcher()
Initializes a new instance of the MessageDispatcher.

Method Detail

getEndpointAdapters

public List getEndpointAdapters()
Returns the EndpointAdapters to use by this MessageDispatcher.


setEndpointAdapters

public void setEndpointAdapters(List endpointAdapters)
Sets the EndpointAdapters to use by this MessageDispatcher.


getEndpointExceptionResolvers

public List getEndpointExceptionResolvers()
Returns the EndpointExceptionResolvers to use by this MessageDispatcher.


setEndpointExceptionResolvers

public void setEndpointExceptionResolvers(List endpointExceptionResolvers)
Sets the EndpointExceptionResolvers to use by this MessageDispatcher.


getEndpointMappings

public List getEndpointMappings()
Returns the EndpointMappings to use by this MessageDispatcher.


setEndpointMappings

public void setEndpointMappings(List endpointMappings)
Sets the EndpointMappings to use by this MessageDispatcher.


setBeanName

public final void setBeanName(String beanName)
Specified by:
setBeanName in interface BeanNameAware

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

receive

public void receive(MessageContext messageContext)
             throws Exception
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 interface WebServiceMessageReceiver
Parameters:
messageContext - the message context to be received
Throws:
Exception

dispatch

protected final void dispatch(MessageContext messageContext)
                       throws Exception
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 message
Exception

getEndpoint

protected EndpointInvocationChain getEndpoint(MessageContext messageContext)
                                       throws Exception
Returns the endpoint for this request. All endpoint mappings are tried, in order.

Returns:
the EndpointInvocationChain, or null if no endpoint could be found.
Throws:
Exception

getEndpointAdapter

protected EndpointAdapter getEndpointAdapter(Object endpoint)
Returns the EndpointAdapter 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 of handleRequest on the interceptors.

Default implementation does nothing, and returns true.

Parameters:
mappedEndpoint - the mapped EndpointInvocationChain
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 error SOAPMessage response via the registered EndpointExceptionResolvers. Most likely, the response contains a SOAPFault. If no suitable resolver was found, the exception is rethrown.

Parameters:
messageContext - current SOAPMessage request
endpoint - the executed endpoint, or null if none chosen at the time of the exception
ex - the exception that got thrown during handler execution
Throws:
Exception - if no suitable resolver is found

Spring Web Services Framework

Copyright © 2005-2010 The Spring Web Services Framework. All Rights Reserved.