View Javadoc

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