org.springframework.integration.gateway
Class MessagingGatewaySupport

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.gateway.MessagingGatewaySupport
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent, TrackableComponent
Direct Known Subclasses:
ChannelPublishingJmsMessageListener, HttpRequestHandlingController, HttpRequestHandlingMessagingGateway, RemotingInboundGatewaySupport, SimpleWebServiceInboundGateway, TcpInboundGateway

public abstract class MessagingGatewaySupport
extends AbstractEndpoint
implements TrackableComponent

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.


Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
MessagingGatewaySupport()
           
 
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.
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
protected  void onInit()
          Subclasses may implement this for initialization logic.
protected  java.lang.Object receive()
           
protected  void send(java.lang.Object object)
           
protected  java.lang.Object sendAndReceive(java.lang.Object object)
           
protected  Message<?> sendAndReceiveMessage(java.lang.Object object)
           
 void setExceptionMapper(InboundMessageMapper<java.lang.Throwable> exceptionMapper)
          Provide an InboundMessageMapper for creating a reply Message from an Exception that occurs downstream from this gateway.
 void setReplyChannel(MessageChannel replyChannel)
          Set the reply channel.
 void setReplyMapper(OutboundMessageMapper<?> replyMapper)
          Provide an OutboundMessageMapper for mapping to objects from any reply Messages received in receive or sendAndReceive operations.
 void setReplyTimeout(long replyTimeout)
          Set the timeout value for receiving reply messages.
 void setRequestChannel(MessageChannel requestChannel)
          Set the request channel.
 void setRequestMapper(InboundMessageMapper<?> requestMapper)
          Provide an InboundMessageMapper for creating request Messages from any object passed in a send or sendAndReceive operation.
 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.
 void setShouldTrack(boolean shouldTrack)
          Specify whether this gateway should be tracked in the Message History of Messages that originate from its send or sendAndReceive operations.
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, 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

MessagingGatewaySupport

public MessagingGatewaySupport()
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 one second.

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 one second.

Parameters:
replyTimeout - the timeout value in milliseconds

setRequestMapper

public void setRequestMapper(InboundMessageMapper<?> requestMapper)
Provide an InboundMessageMapper for creating request Messages from any object passed in a send or sendAndReceive operation.


setReplyMapper

public void setReplyMapper(OutboundMessageMapper<?> replyMapper)
Provide an OutboundMessageMapper for mapping to objects from any reply Messages received in receive or sendAndReceive operations.


setExceptionMapper

public void setExceptionMapper(InboundMessageMapper<java.lang.Throwable> exceptionMapper)
Provide an InboundMessageMapper for creating a reply Message from an Exception that occurs downstream from this gateway. If no exceptionMapper is provided, then the shouldThrowErrors property will dictate whether the error is rethrown or returned as an ErrorMessage.


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.


setShouldTrack

public void setShouldTrack(boolean shouldTrack)
Specify whether this gateway should be tracked in the Message History of Messages that originate from its send or sendAndReceive operations.

Specified by:
setShouldTrack in interface TrackableComponent

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class IntegrationObjectSupport

onInit

protected void onInit()
               throws java.lang.Exception
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport
Throws:
java.lang.Exception

send

protected void send(java.lang.Object object)

receive

protected java.lang.Object receive()

sendAndReceive

protected java.lang.Object sendAndReceive(java.lang.Object object)

sendAndReceiveMessage

protected Message<?> sendAndReceiveMessage(java.lang.Object object)

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