org.apache.camel.processor.aggregate
Class AbstractListAggregationStrategy<V>

java.lang.Object
  extended by org.apache.camel.processor.aggregate.AbstractListAggregationStrategy<V>
All Implemented Interfaces:
AggregationStrategy, CompletionAwareAggregationStrategy
Direct Known Subclasses:
GroupedExchangeAggregationStrategy

public abstract class AbstractListAggregationStrategy<V>
extends Object
implements CompletionAwareAggregationStrategy

Aggregate all exchanges into a List of values defined by the getValue(Exchange) call. The combined Exchange will hold all the aggregated exchanges in a List as a exchange property with the key Exchange.GROUPED_EXCHANGE.

The method isStoreAsBodyOnCompletion() determines if the aggregated List should be stored on the Message.setBody(Object) or be kept as a property on the exchange.
The default behavior to store as message body, allows to more easily group together a list of values and have its result stored as a List on the completed Exchange.

Since:
2.11

Constructor Summary
AbstractListAggregationStrategy()
           
 
Method Summary
 Exchange aggregate(Exchange oldExchange, Exchange newExchange)
          This method will aggregate the old and new exchange and return the result.
abstract  V getValue(Exchange exchange)
          This method is implemented by the sub-class and is called to retrieve an instance of the value that will be aggregated and forwarded to the receiving end point.
 boolean isStoreAsBodyOnCompletion()
          Whether to store the completed aggregated List as message body, or to keep as property on the exchange.
 void onCompletion(Exchange exchange)
          The aggregated Exchange has completed Important: This method must not throw any exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractListAggregationStrategy

public AbstractListAggregationStrategy()
Method Detail

getValue

public abstract V getValue(Exchange exchange)
This method is implemented by the sub-class and is called to retrieve an instance of the value that will be aggregated and forwarded to the receiving end point.

If null is returned, then the value is not added to the List.

Parameters:
exchange - The exchange that is used to retrieve the value from
Returns:
An instance of V that is the associated value of the passed exchange

isStoreAsBodyOnCompletion

public boolean isStoreAsBodyOnCompletion()
Whether to store the completed aggregated List as message body, or to keep as property on the exchange.

The default behavior is true to store as message body.

Returns:
true to store as message body, false to keep as property on the exchange.

onCompletion

public void onCompletion(Exchange exchange)
Description copied from interface: CompletionAwareAggregationStrategy
The aggregated Exchange has completed Important: This method must not throw any exceptions.

Specified by:
onCompletion in interface CompletionAwareAggregationStrategy
Parameters:
exchange - the current aggregated exchange, or the original Exchange if no aggregation has been done before the completion occurred

aggregate

public Exchange aggregate(Exchange oldExchange,
                          Exchange newExchange)
This method will aggregate the old and new exchange and return the result.

Specified by:
aggregate in interface AggregationStrategy
Parameters:
oldExchange - The oldest exchange, can be null
newExchange - The newest exchange, can be null
Returns:
a composite exchange of the old and/or new exchanges


Apache Camel