public class FlexibleAggregationStrategy<E> extends Object implements org.apache.camel.AggregationStrategy
AggregationStrategy
that is capable of performing the most typical aggregation duties,
with zero Java code.
It can perform the following logic:
Predicate
written in any language, such as XPath, OGNL, Groovy,
Simple, etc.Collection
type, e.g. in a HashSet, LinkedList, ArrayList,
etc.Modifier and Type | Class and Description |
---|---|
static interface |
FlexibleAggregationStrategy.CompletionAwareMixin |
static interface |
FlexibleAggregationStrategy.TimeoutAwareMixin |
Constructor and Description |
---|
FlexibleAggregationStrategy()
|
FlexibleAggregationStrategy(Class<E> type)
Initializes a new instance with the specified type as the
castAs type. |
Modifier and Type | Method and Description |
---|---|
FlexibleAggregationStrategy<E> |
accumulateInCollection(Class<? extends Collection> collectionType)
Accumulate the result of the pick expression in a collection of the designated type.
|
org.apache.camel.Exchange |
aggregate(org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange) |
FlexibleAggregationStrategy<E> |
castAs(Class<E> castAs)
Cast the result of the pick expression to this type.
|
FlexibleAggregationStrategy<E> |
completionAware(FlexibleAggregationStrategy.CompletionAwareMixin completionMixin)
Plugs in logic to execute when an aggregation batch completes.
|
FlexibleAggregationStrategy<E> |
condition(org.apache.camel.Predicate predicate)
Set a filter condition such as only results satisfying it will be aggregated.
|
FlexibleAggregationStrategy<E> |
ignoreInvalidCasts()
Ignores invalid casts instead of throwing an exception if the pick expression result cannot be casted to
the specified type.
|
void |
onCompletion(org.apache.camel.Exchange exchange) |
FlexibleAggregationStrategy<E> |
pick(org.apache.camel.Expression expression)
Set an expression to extract the element to be aggregated from the incoming
Exchange . |
FlexibleAggregationStrategy<E> |
storeInBody()
Store the result of this Aggregation Strategy (whether an atomic element or a Collection) in the body of the IN
message.
|
FlexibleAggregationStrategy<E> |
storeInHeader(String headerName)
Store the result of this Aggregation Strategy (whether an atomic element or a Collection) in an IN message header
with the designated name.
|
FlexibleAggregationStrategy<E> |
storeInProperty(String propertyName)
Store the result of this Aggregation Strategy (whether an atomic element or a Collection) in a property with the
designated name.
|
FlexibleAggregationStrategy<E> |
storeNulls()
Enables storing null values in the resulting collection.
|
void |
timeout(org.apache.camel.Exchange oldExchange,
int index,
int total,
long timeout) |
FlexibleAggregationStrategy<E> |
timeoutAware(FlexibleAggregationStrategy.TimeoutAwareMixin timeoutMixin)
Plugs in logic to execute when a timeout occurs.
|
public FlexibleAggregationStrategy<E> pick(org.apache.camel.Expression expression)
Exchange
. All results are
cast to the castAs
type (or the type specified in the constructor).
By default, it picks the full IN message body of the incoming exchange.expression
- The picking expression.public FlexibleAggregationStrategy<E> condition(org.apache.camel.Predicate predicate)
predicate
- The condition.public FlexibleAggregationStrategy<E> accumulateInCollection(Class<? extends Collection> collectionType)
storeNulls()
option is enabled.collectionType
- The type of the Collection to aggregate into.public FlexibleAggregationStrategy<E> storeInProperty(String propertyName)
propertyName
- The property name.public FlexibleAggregationStrategy<E> storeInHeader(String headerName)
headerName
- The header name.public FlexibleAggregationStrategy<E> storeInBody()
public FlexibleAggregationStrategy<E> castAs(Class<E> castAs)
castAs
- Type for the cast.public FlexibleAggregationStrategy<E> storeNulls()
public FlexibleAggregationStrategy<E> ignoreInvalidCasts()
public FlexibleAggregationStrategy<E> timeoutAware(FlexibleAggregationStrategy.TimeoutAwareMixin timeoutMixin)
timeoutMixin
- public FlexibleAggregationStrategy<E> completionAware(FlexibleAggregationStrategy.CompletionAwareMixin completionMixin)
completionMixin
- public org.apache.camel.Exchange aggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
aggregate
in interface org.apache.camel.AggregationStrategy
public void timeout(org.apache.camel.Exchange oldExchange, int index, int total, long timeout)
timeout
in interface org.apache.camel.AggregationStrategy
public void onCompletion(org.apache.camel.Exchange exchange)
onCompletion
in interface org.apache.camel.AggregationStrategy
Apache Camel