org.springframework.integration.gateway
Class AbstractMessagingGateway

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.gateway.AbstractMessagingGateway
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, MessagingGateway
Direct Known Subclasses:
SimpleMessagingGateway

public abstract class AbstractMessagingGateway
extends AbstractEndpoint
implements MessagingGateway

A convenient base class for connecting application code to MessageChannels for sending, receiving, or request-reply operations. Exposes setters for configuring request and reply MessageChannels as well as the timeout values for sending and receiving Messages.

Author:
Mark Fisher

Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractMessagingGateway()
           
 
Method Summary
protected  void doStart()
          Subclasses must implement this method with the start behavior.
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected abstract  java.lang.Object fromMessage(Message<?> message)
          Subclasses must implement this to map from a Message to an Object.
protected  void onInit()
           
 java.lang.Object receive()
           
 void send(java.lang.Object object)
           
 java.lang.Object sendAndReceive(java.lang.Object object)
           
 Message<?> sendAndReceiveMessage(java.lang.Object object)
           
 void setReplyChannel(MessageChannel replyChannel)
          Set the reply channel.
 void setReplyTimeout(long replyTimeout)
          Set the timeout value for receiving reply messages.
 void setRequestChannel(MessageChannel requestChannel)
          Set the request channel.
 void setRequestTimeout(long requestTimeout)
          Set the timeout value for sending request messages.
 void setShouldThrowErrors(boolean shouldThrowErrors)
          Specify whether the Throwable payload of a received ErrorMessage should be extracted and thrown from a send-and-receive operation.
protected abstract  Message<?> toMessage(java.lang.Object object)
          Subclasses must implement this to map from an Object to a Message.
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
afterPropertiesSet, isRunning, setAutoStartup, setTaskScheduler, start, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
getBeanFactory, getBeanName, getChannelResolver, getTaskScheduler, setBeanFactory, setBeanName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMessagingGateway

public AbstractMessagingGateway()
Method Detail

setRequestChannel

public void setRequestChannel(MessageChannel requestChannel)
Set the request channel.

Parameters:
requestChannel - the channel to which request messages will be sent

setReplyChannel

public void setReplyChannel(MessageChannel replyChannel)
Set the reply channel. If no reply channel is provided, this template will always use an anonymous, temporary channel for handling replies.

Parameters:
replyChannel - the channel from which reply messages will be received

setRequestTimeout

public void setRequestTimeout(long requestTimeout)
Set the timeout value for sending request messages. If not explicitly configured, the default is an indefinite timeout.

Parameters:
requestTimeout - the timeout value in milliseconds

setReplyTimeout

public void setReplyTimeout(long replyTimeout)
Set the timeout value for receiving reply messages. If not explicitly configured, the default is an indefinite timeout.

Parameters:
replyTimeout - the timeout value in milliseconds

setShouldThrowErrors

public void setShouldThrowErrors(boolean shouldThrowErrors)
Specify whether the Throwable payload of a received ErrorMessage should be extracted and thrown from a send-and-receive operation. Otherwise, the ErrorMessage would be returned just like any other reply Message. The default is true.


onInit

protected void onInit()
               throws java.lang.Exception
Overrides:
onInit in class AbstractEndpoint
Throws:
java.lang.Exception

send

public void send(java.lang.Object object)
Specified by:
send in interface MessagingGateway

receive

public java.lang.Object receive()
Specified by:
receive in interface MessagingGateway

sendAndReceive

public java.lang.Object sendAndReceive(java.lang.Object object)
Specified by:
sendAndReceive in interface MessagingGateway

sendAndReceiveMessage

public Message<?> sendAndReceiveMessage(java.lang.Object object)
Specified by:
sendAndReceiveMessage in interface MessagingGateway

doStart

protected void doStart()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStart in class AbstractEndpoint

doStop

protected void doStop()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStop in class AbstractEndpoint

toMessage

protected abstract Message<?> toMessage(java.lang.Object object)
Subclasses must implement this to map from an Object to a Message.


fromMessage

protected abstract java.lang.Object fromMessage(Message<?> message)
Subclasses must implement this to map from a Message to an Object.