View Javadoc

1   /*
2    * $Id: BankQuotesInboundAggregator.java 11567 2008-04-11 13:08:05Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.MuleMessage;
14  import org.mule.routing.AggregationException;
15  import org.mule.routing.inbound.CorrelationAggregator;
16  import org.mule.routing.inbound.EventGroup;
17  
18  /**
19   * <code>BankQuotesInboundAggregator</code> receives a number of quotes and selects the
20   * lowest
21   */
22  public class BankQuotesInboundAggregator extends CorrelationAggregator
23  {
24      /**
25       * This method is invoked if the shouldAggregate method is called and returns
26       * true. Once this method returns an aggregated message the event group is
27       * removed from the router
28       * 
29       * @param events the event group for this request
30       * @return an aggregated message
31       * @throws AggregationException if the aggregation fails. in this scenario the
32       *             whole event group is removed and passed to the exception handler
33       *             for this componenet
34       */
35      protected MuleMessage aggregateEvents(EventGroup events) throws AggregationException
36      {
37          try
38          {
39              return BankQuotesAggregationLogic.aggregateEvents(events);
40          }
41          catch (Exception e)
42          {
43              throw new AggregationException(events, null, e);
44          }
45      }
46  
47  }