org.springframework.integration.channel
Class ThreadLocalChannel

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.channel.AbstractMessageChannel
          extended by org.springframework.integration.channel.AbstractPollableChannel
              extended by org.springframework.integration.channel.ThreadLocalChannel
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, PollableChannel, NamedComponent, MessageChannel

public class ThreadLocalChannel
extends AbstractPollableChannel

A channel implementation that stores messages in a thread-bound queue. In other words, send() will put a message at the tail of the queue for the current thread, and receive() will retrieve a message from the head of the queue. Since, by definition, only one thread will interact with the queue at a time, the timeout values on send and receive have no effect. If there are no Messages in the queue, the receive operations will return a null value immediately, regardless of any timeout value.

Author:
Dave Syer, Mark Fisher

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
 
Constructor Summary
ThreadLocalChannel()
           
 
Method Summary
protected  Message<?> doReceive(long timeout)
          Subclasses must implement this method.
protected  boolean doSend(Message<?> message, long timeout)
          Subclasses must implement this method.
 
Methods inherited from class org.springframework.integration.channel.AbstractPollableChannel
receive, receive
 
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, getComponentType, getInterceptors, getSendErrorCount, getSendSuccessCount, send, send, setConversionService, setDatatypes, setInterceptors
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setChannelResolver, 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.core.MessageChannel
send, send
 

Constructor Detail

ThreadLocalChannel

public ThreadLocalChannel()
Method Detail

doSend

protected boolean doSend(Message<?> message,
                         long timeout)
Description copied from class: AbstractMessageChannel
Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is at capacity (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either the message is accepted or the blocking thread is interrupted.

Specified by:
doSend in class AbstractMessageChannel

doReceive

protected Message<?> doReceive(long timeout)
Description copied from class: AbstractPollableChannel
Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is empty (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either a message is available or the blocking thread is interrupted.

Specified by:
doReceive in class AbstractPollableChannel