001    
002    /**
003     * Licensed to the Apache Software Foundation (ASF) under one or more
004     * contributor license agreements.  See the NOTICE file distributed with
005     * this work for additional information regarding copyright ownership.
006     * The ASF licenses this file to You under the Apache License, Version 2.0
007     * (the "License"); you may not use this file except in compliance with
008     * the License.  You may obtain a copy of the License at
009     *
010     *      http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    package org.apache.camel.processor.aggregate;
019    
020    import java.util.Collection;
021    import java.util.Iterator;
022    
023    import org.apache.camel.Exchange;
024    import org.apache.camel.Expression;
025    
026    /**
027     * A {@link Collection} which aggregates exchanges together,
028     * using a correlation {@link Expression} and a {@link AggregationStrategy}.
029     * <p/>
030     * The Default Implementation will group messages based on the correlation expression.
031     * Other implementations could for instance just add all exchanges as a batch.
032     *
033     * @version $Revision: 55919 $
034     */
035    public interface AggregationCollection extends Collection<Exchange> {
036    
037        /**
038         * Gets the correlation expression
039         */
040        Expression<Exchange> getCorrelationExpression();
041    
042        /**
043         * Sets the correlation expression to be used
044         */
045        void setCorrelationExpression(Expression<Exchange> correlationExpression);
046    
047        /**
048         * Gets the aggregation strategy
049         */
050        AggregationStrategy getAggregationStrategy();
051    
052        /**
053         * Sets the aggregation strategy to be used
054         */
055        void setAggregationStrategy(AggregationStrategy aggregationStrategy);
056    
057        /**
058         * Adds the given exchange to this collection
059         */
060        boolean add(Exchange exchange);
061    
062        /**
063         * Gets the iterator to iterate this collection.
064         */
065        Iterator<Exchange> iterator();
066    
067        /**
068         * Gets the size of this collection
069         */
070        int size();
071    
072        /**
073         * Clears this colleciton
074         */
075        void clear();
076    
077        /**
078         * A strategy method allowing derived classes such as {@link PredicateAggregationCollection}
079         * to check to see if the aggregation has completed
080         */
081        void onAggregation(Object correlationKey, Exchange newExchange);
082    
083    }