View Javadoc

1   /*
2    * $Id: BankQuotesResponseAggregator.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.example.loanbroker.routers;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.MuleEvent;
15  import org.mule.routing.AbstractAggregator;
16  import org.mule.routing.AggregationException;
17  import org.mule.routing.EventGroup;
18  import org.mule.routing.correlation.CollectionCorrelatorCallback;
19  import org.mule.routing.correlation.EventCorrelatorCallback;
20  
21  /**
22   * <code>BankQuotesInboundAggregator</code> receives a number of quotes and selects the
23   * lowest
24   */
25  public class BankQuotesResponseAggregator extends AbstractAggregator
26  {
27      @Override
28      protected EventCorrelatorCallback getCorrelatorCallback(MuleContext muleContext)
29      {
30          return new CollectionCorrelatorCallback(muleContext,persistentStores,storePrefix)
31          {
32              @Override
33              public MuleEvent aggregateEvents(EventGroup events) throws AggregationException
34              {
35                  try
36                  {
37                      return BankQuotesAggregationLogic.aggregateEvents(events);
38                  }
39                  catch (Exception e)
40                  {
41                      throw new AggregationException(events, null, e);
42                  }
43              }
44          };
45      }
46  }