org.springframework.integration.channel
Class NullChannel

java.lang.Object
  extended by org.springframework.integration.channel.NullChannel
All Implemented Interfaces:
MessageChannel, BlockingSource, BlockingTarget, MessageSource, MessageTarget

public class NullChannel
extends java.lang.Object
implements MessageChannel

A channel implementation that essentially behaves like "/dev/null". All receive() calls will return null, and all send() calls will return true although no action is performed. Note however that the invocations are logged at debug-level.

Author:
Mark Fisher

Field Summary
private  org.apache.commons.logging.Log logger
           
 
Constructor Summary
NullChannel()
           
 
Method Summary
 java.util.List<Message<?>> clear()
          Remove all Messages from this channel.
 java.lang.String getName()
          Always returns null.
 java.util.List<Message<?>> purge(MessageSelector selector)
          Remove any Messages that are not accepted by the provided selector.
 Message receive()
          Receive a message, blocking indefinitely if necessary.
 Message receive(long timeout)
          Receive a message, blocking until either a message is available or the specified timeout period elapses.
 boolean send(Message<?> message)
          Send a message, blocking indefinitely if necessary.
 boolean send(Message<?> message, long timeout)
          Send a message, blocking until either the message is accepted or the specified timeout period elapses.
 void setName(java.lang.String name)
          The channel name cannot be set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.apache.commons.logging.Log logger
Constructor Detail

NullChannel

public NullChannel()
Method Detail

clear

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

Specified by:
clear in interface MessageChannel

getName

public java.lang.String getName()
Always returns null.

Specified by:
getName 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

setName

public void setName(java.lang.String name)
The channel name cannot be set. It is always null.

Specified by:
setName in interface MessageChannel

receive

public Message receive()
Description copied from interface: BlockingSource
Receive a message, blocking indefinitely if necessary.

Specified by:
receive in interface BlockingSource
Specified by:
receive in interface MessageSource
Returns:
the next available Message or null if interrupted

receive

public Message receive(long timeout)
Description copied from interface: BlockingSource
Receive a message, blocking until either a message is available or the specified timeout period elapses.

Specified by:
receive in interface BlockingSource
Parameters:
timeout - the timeout in milliseconds
Returns:
the next available Message or null if the specified timeout period elapses or the message reception is interrupted

send

public boolean send(Message<?> message)
Description copied from interface: BlockingTarget
Send a message, blocking indefinitely if necessary.

Specified by:
send in interface BlockingTarget
Specified by:
send in interface MessageTarget
Parameters:
message - the Message to send
Returns:
true if the message is sent successfully, false if interrupted

send

public boolean send(Message<?> message,
                    long timeout)
Description copied from interface: BlockingTarget
Send a message, blocking until either the message is accepted or the specified timeout period elapses.

Specified by:
send in interface BlockingTarget
Parameters:
message - the Message to send
timeout - the timeout in milliseconds
Returns:
true if the message is sent successfully, false if the specified timeout period elapses or the send is interrupted