diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/LoanQuoteAggregator.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/LoanQuoteAggregator.java index de58909d48..a5dc2eb99a 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/LoanQuoteAggregator.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/LoanQuoteAggregator.java @@ -25,7 +25,7 @@ import org.springframework.integration.loanbroker.domain.LoanQuote; /** * Will aggregate {@link LoanQuote}s based on the value of the 'RESPONSE_TYPE' message header. - * The value of 'RESPONSE_TYPE' header is set by the 'gateway' and is based on the type of + * The value of the 'RESPONSE_TYPE' header is set by the 'gateway' and is based on the type of * {@link LoanBrokerGateway} method that was invoked by the client. *

* Will return the best {@link LoanQuote} if 'RESPONSE_TYPE' header value is 'BEST' else it will @@ -35,24 +35,19 @@ import org.springframework.integration.loanbroker.domain.LoanQuote; */ public class LoanQuoteAggregator { - /** - * @param messages - * @return - */ - @SuppressWarnings({ "unused", "unchecked" }) - private Object aggregateQuotes(List> messages) { - ArrayList payloads = new ArrayList(messages.size()); - for (Message message : messages) { + public Object aggregateQuotes(List> messages) { + ArrayList payloads = new ArrayList(messages.size()); + for (Message message : messages) { payloads.add(message.getPayload()); } - String responceType = (String) messages.get(0).getHeaders().get("RESPONSE_TYPE"); - if (responceType.equals("ALL")) { - return payloads; - } - else { + String responseType = messages.get(0).getHeaders().get("RESPONSE_TYPE", String.class); + if ("BEST".equals(responseType)) { Collections.sort(payloads); return payloads.get(0); } + else { + return payloads; + } } } diff --git a/spring-integration-samples/loan-broker/src/main/resources/loan-broker-config.xml b/spring-integration-samples/loan-broker/src/main/resources/loan-broker-config.xml index a1b8bd9c23..451b9f729a 100644 --- a/spring-integration-samples/loan-broker/src/main/resources/loan-broker-config.xml +++ b/spring-integration-samples/loan-broker/src/main/resources/loan-broker-config.xml @@ -16,9 +16,6 @@

- -
- @@ -26,8 +23,8 @@