org.springframework.integration.dispatcher
Class DirectChannel

java.lang.Object
  extended by org.springframework.integration.channel.AbstractMessageChannel
      extended by org.springframework.integration.dispatcher.DirectChannel
All Implemented Interfaces:
org.springframework.beans.factory.BeanNameAware, MessageChannel, BlockingSource, BlockingTarget, Source, Subscribable, Target

public class DirectChannel
extends AbstractMessageChannel
implements Subscribable

A channel that invokes the subscribed handler(s) in a sender's thread (returning after at most one handles the message). If a Source is provided, then that source will likewise be polled within a receiver's thread.

Author:
Dave Syer, Mark Fisher

Field Summary
private  SimpleDispatcher dispatcher
           
private  java.util.concurrent.atomic.AtomicInteger handlerCount
           
private  Source<?> source
           
 
Constructor Summary
DirectChannel()
           
DirectChannel(Source<?> source)
           
 
Method Summary
 java.util.List<Message<?>> clear()
          Remove all Messages from this channel.
private static DispatcherPolicy defaultDispatcherPolicy()
           
protected  Message<?> doReceive(long timeout)
          Subclasses must implement this method.
protected  boolean doSend(Message<?> message, long timeout)
          Subclasses must implement this method.
 java.util.List<Message<?>> purge(MessageSelector selector)
          Remove any Messages that are not accepted by the provided selector.
 boolean subscribe(Target target)
          Register a Target as a subscriber to this source.
 boolean unsubscribe(Target target)
          Remove a Target from the subscribers of this source.
 
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, getDispatcherPolicy, getName, receive, receive, send, send, setBeanName, setInterceptors, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

private volatile Source<?> source

dispatcher

private final SimpleDispatcher dispatcher

handlerCount

private final java.util.concurrent.atomic.AtomicInteger handlerCount
Constructor Detail

DirectChannel

public DirectChannel()

DirectChannel

public DirectChannel(Source<?> source)
Method Detail

subscribe

public boolean subscribe(Target target)
Description copied from interface: Subscribable
Register a Target as a subscriber to this source.

Specified by:
subscribe in interface Subscribable

unsubscribe

public boolean unsubscribe(Target target)
Description copied from interface: Subscribable
Remove a Target from the subscribers of this source.

Specified by:
unsubscribe in interface Subscribable

doReceive

protected Message<?> doReceive(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 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 AbstractMessageChannel

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

clear

public java.util.List<Message<?>> clear()
Description copied from interface: MessageChannel
Remove all Messages from this channel.

Specified by:
clear in interface MessageChannel

purge

public java.util.List<Message<?>> purge(MessageSelector selector)
Description copied from interface: MessageChannel
Remove any Messages that are not accepted by the provided selector.

Specified by:
purge in interface MessageChannel

defaultDispatcherPolicy

private static DispatcherPolicy defaultDispatcherPolicy()