org.springframework.integration.router
Class AggregationBarrier

java.lang.Object
  extended by org.springframework.integration.router.AggregationBarrier
All Implemented Interfaces:
MessageBarrier

public class AggregationBarrier
extends java.lang.Object
implements MessageBarrier

MessageBarrier implementation for message aggregation. Delegates to a CompletionStrategy to determine when the group of messages is ready for aggregation.

Author:
Marius Bogoevici, Mark Fisher

Field Summary
private  boolean complete
           
private  CompletionStrategy completionStrategy
           
private  java.util.concurrent.locks.ReentrantLock lock
           
private  org.apache.commons.logging.Log logger
           
private  java.util.List<Message<?>> messages
           
private  long timestamp
           
 
Constructor Summary
AggregationBarrier(CompletionStrategy completionStrategy)
          Create an AggregationBarrier with the given CompletionStrategy.
 
Method Summary
 java.util.List<Message<?>> addAndRelease(Message<?> message)
          Adds a message to the aggregation group and releases if complete.
 java.util.List<Message<?>> getMessages()
           
 long getTimestamp()
          Returns the creation time of this barrier as the number of milliseconds since January 1, 1970.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final org.apache.commons.logging.Log logger

messages

private final java.util.List<Message<?>> messages

completionStrategy

private final CompletionStrategy completionStrategy

complete

private volatile boolean complete

lock

private final java.util.concurrent.locks.ReentrantLock lock

timestamp

private final long timestamp
Constructor Detail

AggregationBarrier

public AggregationBarrier(CompletionStrategy completionStrategy)
Create an AggregationBarrier with the given CompletionStrategy.

Method Detail

getTimestamp

public long getTimestamp()
Returns the creation time of this barrier as the number of milliseconds since January 1, 1970.

See Also:
System.currentTimeMillis()

addAndRelease

public java.util.List<Message<?>> addAndRelease(Message<?> message)
Adds a message to the aggregation group and releases if complete. Otherwise, the return value will be null.

Specified by:
addAndRelease in interface MessageBarrier

getMessages

public java.util.List<Message<?>> getMessages()