Class AbstractListAggregationStrategy<V>

  • All Implemented Interfaces:
    org.apache.camel.AggregationStrategy
    Direct Known Subclasses:
    GroupedBodyAggregationStrategy, GroupedExchangeAggregationStrategy, GroupedMessageAggregationStrategy

    public abstract class AbstractListAggregationStrategy<V>
    extends Object
    implements org.apache.camel.AggregationStrategy
    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.

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.camel.Exchange aggregate​(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
      This method will aggregate the old and new exchange and return the result.
      abstract V getValue​(org.apache.camel.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​(org.apache.camel.Exchange exchange)  
      • Methods inherited from interface org.apache.camel.AggregationStrategy

        aggregate, canPreComplete, onCompletion, onOptimisticLockFailure, preComplete, timeout
    • Constructor Detail

      • AbstractListAggregationStrategy

        public AbstractListAggregationStrategy()
    • Method Detail

      • getValue

        public abstract V getValue​(org.apache.camel.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​(org.apache.camel.Exchange exchange)
        Specified by:
        onCompletion in interface org.apache.camel.AggregationStrategy
      • aggregate

        public org.apache.camel.Exchange aggregate​(org.apache.camel.Exchange oldExchange,
                                                   org.apache.camel.Exchange newExchange)
        This method will aggregate the old and new exchange and return the result.
        Specified by:
        aggregate in interface org.apache.camel.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