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.example.loanbroker.routers;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.routing.AbstractCorrelationAggregator;
11  import org.mule.routing.AggregationException;
12  import org.mule.routing.EventGroup;
13  
14  /**
15   * <code>BankQuotesInboundAggregator</code> receives a number of quotes and selects the
16   * lowest
17   */
18  public class BankQuotesInboundAggregator extends AbstractCorrelationAggregator
19  {
20      /**
21       * This method is invoked if the shouldAggregate method is called and returns
22       * true. Once this method returns an aggregated message the event group is
23       * removed from the router
24       * 
25       * @param events the event group for this request
26       * @return an aggregated message
27       * @throws AggregationException if the aggregation fails. in this scenario the
28       *             whole event group is removed and passed to the exception handler
29       *             for this componenet
30       */
31      @Override
32      protected MuleEvent aggregateEvents(EventGroup events) throws AggregationException
33      {
34          try
35          {
36              return BankQuotesAggregationLogic.aggregateEvents(events);
37          }
38          catch (Exception e)
39          {
40              throw new AggregationException(events, null, e);
41          }
42      }
43  }