Spring Integration

org.springframework.integration.router
Class AbstractMappingMessageRouter

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.router.AbstractMessageRouter
              extended by org.springframework.integration.router.AbstractMappingMessageRouter
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, NamedComponent, Orderable, MessageHandler, TrackableComponent, MappingMessageRouterManagement
Direct Known Subclasses:
ErrorMessageExceptionTypeRouter, ExpressionEvaluatingRouter, HeaderValueRouter, MethodInvokingRouter, PayloadTypeRouter, XPathRouter

public abstract class AbstractMappingMessageRouter
extends AbstractMessageRouter
implements MappingMessageRouterManagement

Base class for all Message Routers that support mapping from arbitrary String values to Message Channel names.

Since:
2.1
Author:
Mark Fisher, Oleg Zhurakousky, Gunnar Hillert, Gary Russell

Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractMappingMessageRouter()
           
 
Method Summary
protected  java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
          Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.
protected abstract  java.util.List<java.lang.Object> getChannelKeys(Message<?> message)
          Subclasses must implement this method to return the channel keys.
protected  java.util.Map<java.lang.String,java.lang.String> getChannelMappings()
          Returns an unmodifiable version of the channel mappings.
 void onInit()
          Subclasses may implement this for initialization logic.
 void removeChannelMapping(java.lang.String key)
          Remove a channel mapping for the given key if present.
 void setChannelMapping(java.lang.String key, java.lang.String channelName)
          Add a channel mapping from the provided key to channel name.
 void setChannelMappings(java.util.Map<java.lang.String,java.lang.String> channelMappings)
          Provide mappings from channel keys to channel names.
 void setChannelResolver(ChannelResolver channelResolver)
          Specify the ChannelResolver strategy to use.
 void setPrefix(java.lang.String prefix)
          Specify a prefix to be added to each channel name prior to resolution.
 void setResolutionRequired(boolean resolutionRequired)
          Specify whether this router should ignore any failure to resolve a channel name to an actual MessageChannel instance when delegating to the ChannelResolver strategy.
 void setSuffix(java.lang.String suffix)
          Specify a suffix to be added to each channel name prior to resolution.
 
Methods inherited from class org.springframework.integration.router.AbstractMessageRouter
getComponentType, getMessagingTemplate, getRequiredConversionService, handleMessageInternal, setApplySequence, setDefaultOutputChannel, setIgnoreSendFailures, setTimeout
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, setOrder, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Constructor Detail

AbstractMappingMessageRouter

public AbstractMappingMessageRouter()
Method Detail

setChannelMappings

public void setChannelMappings(java.util.Map<java.lang.String,java.lang.String> channelMappings)
Provide mappings from channel keys to channel names. Channel names will be resolved by the ChannelResolver.


setChannelResolver

public void setChannelResolver(ChannelResolver channelResolver)
Specify the ChannelResolver strategy to use. The default is a BeanFactoryChannelResolver. This is considered an infrastructural configuration option and as of 2.1 has been deprecated as a configuration-driven attribute.


setPrefix

public void setPrefix(java.lang.String prefix)
Specify a prefix to be added to each channel name prior to resolution.


setSuffix

public void setSuffix(java.lang.String suffix)
Specify a suffix to be added to each channel name prior to resolution.


setResolutionRequired

public void setResolutionRequired(boolean resolutionRequired)
Specify whether this router should ignore any failure to resolve a channel name to an actual MessageChannel instance when delegating to the ChannelResolver strategy.


getChannelMappings

protected java.util.Map<java.lang.String,java.lang.String> getChannelMappings()
Returns an unmodifiable version of the channel mappings. This is intended for use by subclasses only.


setChannelMapping

@ManagedOperation
public void setChannelMapping(java.lang.String key,
                                               java.lang.String channelName)
Add a channel mapping from the provided key to channel name.

Specified by:
setChannelMapping in interface MappingMessageRouterManagement

removeChannelMapping

@ManagedOperation
public void removeChannelMapping(java.lang.String key)
Remove a channel mapping for the given key if present.

Specified by:
removeChannelMapping in interface MappingMessageRouterManagement

onInit

public void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport

getChannelKeys

protected abstract java.util.List<java.lang.Object> getChannelKeys(Message<?> message)
Subclasses must implement this method to return the channel keys. A "key" might be present in this router's "channelMappings", or it could be the channel's name or even the Message Channel instance itself.


determineTargetChannels

protected java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
Description copied from class: AbstractMessageRouter
Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.

Specified by:
determineTargetChannels in class AbstractMessageRouter

Spring Integration