View Javadoc

1   /*
2    * $Id: BankQuotesResponseAggregator.java 7976 2007-08-21 14:26:13Z 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.examples.loanbroker.routers;
12  
13  import org.mule.routing.AggregationException;
14  import org.mule.routing.inbound.EventGroup;
15  import org.mule.routing.response.ResponseCorrelationAggregator;
16  import org.mule.umo.UMOMessage;
17  import org.mule.umo.routing.RoutingException;
18  
19  /**
20   * <code>BankQuotesInboundAggregator</code> receives a number of quotes and selects the
21   * lowest
22   */
23  public class BankQuotesResponseAggregator extends ResponseCorrelationAggregator
24  {
25      /**
26       * This method is invoked if the shouldAggregate method is called and returns
27       * true. Once this method returns an aggregated message the event group is
28       * removed from the router
29       * 
30       * @param events the event group for this request
31       * @return an aggregated message
32       * @throws org.mule.umo.routing.RoutingException if the aggregation fails. in
33       *             this scenario the whole event group is removed and passed to the
34       *             exception handler for this componenet
35       */
36      protected UMOMessage aggregateEvents(EventGroup events) throws RoutingException
37      {
38          try
39          {
40              return BankQuotesAggregationLogic.aggregateEvents(events);
41          }
42          catch (Exception e)
43          {
44              throw new AggregationException(events, null, e);
45          }
46      }
47  }