org.springframework.integration.handler
Class MethodInvokingTarget

java.lang.Object
  extended by org.springframework.integration.handler.AbstractMessageHandler
      extended by org.springframework.integration.handler.MethodInvokingTarget
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, MessageHandler, MessageTarget

public class MethodInvokingTarget
extends AbstractMessageHandler
implements MessageTarget

A messaging target that invokes the specified method on the provided object.

Author:
Mark Fisher

Field Summary
 
Fields inherited from class org.springframework.integration.handler.AbstractMessageHandler
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
MethodInvokingTarget()
           
 
Method Summary
protected  Message<?> createReplyMessage(java.lang.Object result, Message<?> requestMessage)
          Subclasses must implement this method to generate the reply Message when the return value is not a Message instance.
private  void failIfNotNull(java.lang.Object result, Message<?> requestMessage)
           
protected  Message<?> postProcessReplyMessage(Message<?> replyMessage, Message<?> requestMessage)
          Subclasses must implement this method to process a return value that is already a Message instance.
 boolean send(Message<?> message)
          Send a Message to this target.
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
afterPropertiesSet, getOrder, handle, setMethod, setMethodName, setObject, setOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInvokingTarget

public MethodInvokingTarget()
Method Detail

send

public boolean send(Message<?> message)
Description copied from interface: MessageTarget
Send a Message to this target. May throw a RuntimeException for non-recoverable errors. Otherwise, if the Message cannot be sent for a non-fatal reason such as timeout, then this method will return 'false', and if the Message is sent successfully, it will return 'true'.

Specified by:
send in interface MessageTarget
Parameters:
message - the Message to send
Returns:
whether the Message has been sent successfully

createReplyMessage

protected Message<?> createReplyMessage(java.lang.Object result,
                                        Message<?> requestMessage)
Description copied from class: AbstractMessageHandler
Subclasses must implement this method to generate the reply Message when the return value is not a Message instance.

Specified by:
createReplyMessage in class AbstractMessageHandler
Parameters:
result - the return value from an adapter method, or the Message payload if not acting as an adapter
requestMessage - the original request Message
Returns:
the Message to be sent to the reply MessageTarget

postProcessReplyMessage

protected Message<?> postProcessReplyMessage(Message<?> replyMessage,
                                             Message<?> requestMessage)
Description copied from class: AbstractMessageHandler
Subclasses must implement this method to process a return value that is already a Message instance.

Specified by:
postProcessReplyMessage in class AbstractMessageHandler
Parameters:
replyMessage - the Message returned from an adapter method
requestMessage - the original request Message
Returns:
the Message to be sent to the reply MessageTarget

failIfNotNull

private void failIfNotNull(java.lang.Object result,
                           Message<?> requestMessage)