org.springframework.integration.handler
Class AbstractMessageHandlerAdapter
java.lang.Object
org.springframework.integration.util.AbstractMethodInvokingAdapter
org.springframework.integration.handler.AbstractMessageHandlerAdapter
- All Implemented Interfaces:
- org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, ChannelRegistryAware, MessageHandler, MethodInvoker
- Direct Known Subclasses:
- DefaultMessageHandlerAdapter, MethodInvokingTarget, RouterMessageHandlerAdapter, SplitterMessageHandlerAdapter
public abstract class AbstractMessageHandlerAdapter
- extends AbstractMethodInvokingAdapter
- implements MessageHandler, ChannelRegistryAware
An implementation of the MessageHandler
interface that invokes the specified method and target object. Either
a Method
reference or a 'methodName' may be provided, but both are not necessary. In fact, while preference
is given to a Method
reference if available, an Exception will be thrown if a non-matching 'methodName' has
also been provided. Therefore, to avoid such ambiguity, it is recommended to provide just one or the other.
This handler also accepts an implementation of the MessageMapper
strategy interface which it uses for
converting from the Message
being handled to an Object prior to invoking the method. Likewise, if the method
has a non-null return value, a reply message will be generated by the configured implementation of the
MessageCreator
strategy interface. In both cases, the default implementations will simply consider the
message's payload.
- Author:
- Mark Fisher
Fields inherited from interface org.springframework.core.Ordered |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Methods inherited from class org.springframework.integration.util.AbstractMethodInvokingAdapter |
afterPropertiesSet, getMethod, getMethodName, getObject, getOrder, initialize, invokeMethod, isInitialized, setMethod, setMethodName, setObject, setOrder |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OUTPUT_CHANNEL_NAME_KEY
public static final java.lang.String OUTPUT_CHANNEL_NAME_KEY
- See Also:
- Constant Field Values
methodExpectsMessage
private volatile boolean methodExpectsMessage
messageMapper
private volatile MessageMapper messageMapper
messageCreator
private volatile MessageCreator messageCreator
channelRegistry
private volatile ChannelRegistry channelRegistry
AbstractMessageHandlerAdapter
public AbstractMessageHandlerAdapter()
setMethodExpectsMessage
public void setMethodExpectsMessage(boolean methodExpectsMessage)
setMessageMapper
public void setMessageMapper(MessageMapper messageMapper)
setMessageCreator
public void setMessageCreator(MessageCreator messageCreator)
setChannelRegistry
public void setChannelRegistry(ChannelRegistry channelRegistry)
- Specified by:
setChannelRegistry
in interface ChannelRegistryAware
getChannelRegistry
protected ChannelRegistry getChannelRegistry()
handle
public Message<?> handle(Message<?> message)
- Specified by:
handle
in interface MessageHandler
createReplyMessage
protected Message<?> createReplyMessage(java.lang.Object returnValue,
Message<?> originalMessage)
handleReturnValue
protected abstract Message<?> handleReturnValue(java.lang.Object returnValue,
Message<?> originalMessage)
- Subclasses must implement this method to handle the return value.