View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.routing;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.MuleEvent;
11  import org.mule.routing.correlation.CollectionCorrelatorCallback;
12  import org.mule.routing.correlation.EventCorrelatorCallback;
13  
14  /**
15   * <code>AbstractCorrelationAggregatingMessageProcessor</code> uses the CorrelationID and
16   * CorrelationGroupSize properties of the {@link org.mule.api.MuleMessage} to manage
17   * message groups.
18   */
19  public abstract class AbstractCorrelationAggregator extends AbstractAggregator
20  {
21  
22      @Override
23      protected EventCorrelatorCallback getCorrelatorCallback(MuleContext muleContext)
24      {
25          return new DelegateCorrelatorCallback(muleContext);
26      }
27  
28      protected abstract MuleEvent aggregateEvents(EventGroup events) throws AggregationException;
29  
30      private class DelegateCorrelatorCallback extends CollectionCorrelatorCallback
31      {
32          public DelegateCorrelatorCallback(MuleContext muleContext)
33          {
34              super(muleContext);
35          }
36  
37          @Override
38          public MuleEvent aggregateEvents(EventGroup events) throws AggregationException
39          {
40              return AbstractCorrelationAggregator.this.aggregateEvents(events);
41          }
42      }
43  
44  }