Spring Web Services Framework

org.springframework.ws.server.endpoint.mapping
Class AbstractMapBasedEndpointMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping
          extended by org.springframework.ws.server.endpoint.mapping.AbstractMapBasedEndpointMapping
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, EndpointMapping
Direct Known Subclasses:
AbstractQNameEndpointMapping, SoapActionEndpointMapping, UriEndpointMapping, XPathPayloadEndpointMapping

public abstract class AbstractMapBasedEndpointMapping
extends AbstractEndpointMapping

Abstract base class for endpoint mapping that are based on a Map. Provides mappings of application context beans as well as a settable map.

Subclasses determine the exact nature of the key in the enpoint map; this can be a qualified name, a SOAP Header, the result of a XPath validation. The values are always endpoint objects, or bean names of endpoint objects.

Since:
1.0.0
Author:
Arjen Poutsma

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractMapBasedEndpointMapping()
           
 
Method Summary
protected  Object getEndpointInternal(MessageContext messageContext)
          Lookup an endpoint for the given message.
protected abstract  String getLookupKeyForMessage(MessageContext messageContext)
          Returns the the endpoint key for the given message context.
protected  void initApplicationContext()
          Registers annd checks the set endpoints.
protected  Object lookupEndpoint(String key)
          Looks up an endpoint instance for the given keys.
protected  void registerEndpoint(String key, Object endpoint)
          Register the given endpoint instance under the registration key.
 void setEndpointMap(Map<String,Object> endpointMap)
          Sets a Map with keys and endpoint beans as values.
 void setLazyInitEndpoints(boolean lazyInitEndpoints)
          Set whether to lazily initialize endpoints.
 void setMappings(Properties mappings)
          Maps keys to endpoint bean names.
 void setRegisterBeanNames(boolean registerBeanNames)
          Set whether to register bean names found in the application context.
protected abstract  boolean validateLookupKey(String key)
          Validates the given endpoint key.
 
Methods inherited from class org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping
createEndpointInvocationChain, getDefaultEndpoint, getEndpoint, getInterceptors, getOrder, initInterceptors, resolveStringEndpoint, setDefaultEndpoint, setInterceptors, setOrder
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMapBasedEndpointMapping

public AbstractMapBasedEndpointMapping()
Method Detail

setLazyInitEndpoints

public void setLazyInitEndpoints(boolean lazyInitEndpoints)
Set whether to lazily initialize endpoints. Only applicable to singleton endpoints, as prototypes are always lazily initialized. Default is false, as eager initialization allows for more efficiency through referencing the controller objects directly.

If you want to allow your endpoints to be lazily initialized, make them "lazy-init" and set this flag to true. Just making them "lazy-init" will not work, as they are initialized through the references from the endpoint mapping in this case.


setRegisterBeanNames

public final void setRegisterBeanNames(boolean registerBeanNames)
Set whether to register bean names found in the application context. Setting this to true will register all beans found in the application context under their name. Default is false.


setEndpointMap

public final void setEndpointMap(Map<String,Object> endpointMap)
Sets a Map with keys and endpoint beans as values. The nature of the keys in the given map depends on the exact subclass used. They can be qualified names, for instance, or mime headers.

Throws:
IllegalArgumentException - if the endpoint is invalid

setMappings

public void setMappings(Properties mappings)
Maps keys to endpoint bean names. The nature of the property names depends on the exact subclass used. They can be qualified names, for instance, or mime headers.


validateLookupKey

protected abstract boolean validateLookupKey(String key)
Validates the given endpoint key. Should return true is the given string is valid.


getLookupKeyForMessage

protected abstract String getLookupKeyForMessage(MessageContext messageContext)
                                          throws Exception
Returns the the endpoint key for the given message context. Returns null if a key cannot be found.

Returns:
the registration key; or null
Throws:
Exception

getEndpointInternal

protected final Object getEndpointInternal(MessageContext messageContext)
                                    throws Exception
Lookup an endpoint for the given message. The extraction of the endpoint key is delegated to the concrete subclass.

Specified by:
getEndpointInternal in class AbstractEndpointMapping
Returns:
the looked up endpoint, or null
Throws:
Exception - if there is an error

lookupEndpoint

protected Object lookupEndpoint(String key)
Looks up an endpoint instance for the given keys. All keys are tried in order.

Parameters:
key - key the beans are mapped to
Returns:
the associated endpoint instance, or null if not found

registerEndpoint

protected void registerEndpoint(String key,
                                Object endpoint)
                         throws BeansException
Register the given endpoint instance under the registration key.

Parameters:
key - the string representation of the registration key
endpoint - the endpoint instance
Throws:
BeansException - if the endpoint could not be registered

initApplicationContext

protected final void initApplicationContext()
                                     throws BeansException
Registers annd checks the set endpoints. Checks the beans set through setEndpointMap and setMappings, and registers the bean names found in the application context, if registerBeanNames is set to true.

Overrides:
initApplicationContext in class AbstractEndpointMapping
Throws:
ApplicationContextException - if either of the endpoints defined via setEndpointMap or setMappings is invalid
BeansException
See Also:
setEndpointMap(java.util.Map), setMappings(java.util.Properties), setRegisterBeanNames(boolean)

Spring Web Services Framework

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