1 /* 2 * $Id: BankQuotesInboundAggregator.java 20321 2010-11-24 15:21:24Z dfeist $ 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.MuleEvent; 14 import org.mule.routing.AbstractCorrelationAggregator; 15 import org.mule.routing.AggregationException; 16 import org.mule.routing.EventGroup; 17 18 /** 19 * <code>BankQuotesInboundAggregator</code> receives a number of quotes and selects the 20 * lowest 21 */ 22 public class BankQuotesInboundAggregator extends AbstractCorrelationAggregator 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 @Override 36 protected MuleEvent aggregateEvents(EventGroup events) throws AggregationException 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 }