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