diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/BanksChannelSelector.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/BanksChannelSelector.java index 37e9245e38..807f0594d3 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/BanksChannelSelector.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/BanksChannelSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker; import java.util.Map; @@ -36,39 +37,42 @@ import org.springframework.integration.core.Message; * channels if customer's credit score (retrieved from message header 'CREDIT_SCORE') is above 780. * * @author Oleg Zhurakousky - * */ public class BanksChannelSelector { + private static Logger logger = Logger.getLogger(BanksChannelSelector.class); + private Map bankChannelPool; + private String routingExpression; + /** - * * @param bankChannelPool */ - public BanksChannelSelector(Map bankChannelPool){ + public BanksChannelSelector(Map bankChannelPool) { this.bankChannelPool = bankChannelPool; } - /** - * - * @param message - * @return - */ - @SuppressWarnings("unchecked") - public Set selectBankChannels(Message message) { - EvaluationContext context = new StandardEvaluationContext(message); - - context.setVariable("banks", bankChannelPool); - ExpressionParser parser = new SpelExpressionParser(); - Expression expression = parser.parseExpression(routingExpression); - Set bankChannels = (Set) expression.getValue(context); - logger.debug("Selected bank channels: " + bankChannels); - return bankChannels; - } + /** * @param routingExpression */ public void setRoutingExpression(String routingExpression) { this.routingExpression = routingExpression; } + + /** + * @param message + * @return + */ + @SuppressWarnings("unchecked") + public Set selectBankChannels(Message message) { + EvaluationContext context = new StandardEvaluationContext(message); + context.setVariable("banks", bankChannelPool); + ExpressionParser parser = new SpelExpressionParser(); + Expression expression = parser.parseExpression(routingExpression); + Set bankChannels = (Set) expression.getValue(context); + logger.debug("selected bank channels: " + bankChannels); + return bankChannels; + } + } 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 6620e8c081..de58909d48 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker; import java.util.ArrayList; @@ -24,22 +25,22 @@ 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 'header-enricher' and is based on the type of + * The value of '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 return - * all quotes. + *

+ * Will return the best {@link LoanQuote} if 'RESPONSE_TYPE' header value is 'BEST' else it will + * return all quotes. * * @author Oleg Zhurakousky - * */ public class LoanQuoteAggregator { + /** * @param messages * @return */ @SuppressWarnings({ "unused", "unchecked" }) private Object aggregateQuotes(List> messages) { - ArrayList payloads = new ArrayList(messages.size()); for (Message message : messages) { payloads.add(message.getPayload()); @@ -47,9 +48,11 @@ public class LoanQuoteAggregator { String responceType = (String) messages.get(0).getHeaders().get("RESPONSE_TYPE"); if (responceType.equals("ALL")) { return payloads; - } else { + } + else { Collections.sort(payloads); return payloads.get(0); } } + } diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/Transformer.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/Transformer.java index 6cbc8a2ecb..d64e609cc0 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/Transformer.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/Transformer.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker; import org.springframework.integration.loanbroker.domain.LoanQuote; /** * @author Gary Russell - * */ public class Transformer { diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Address.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Address.java index 0f70b52e0e..99cee8a21b 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Address.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Address.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,39 +13,49 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker.domain; /** * @author Oleg Zhurakousky - * */ public class Address { + private String street; private String zip; private String city; private String state; + public String getStreet() { return street; } + public void setStreet(String street) { this.street = street; } + public String getZip() { return zip; } + public void setZip(String zip) { this.zip = zip; } + public String getCity() { return city; } + public void setCity(String city) { this.city = city; } + public String getState() { return state; } + public void setState(String state) { this.state = state; } + } diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/CreditScore.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/CreditScore.java index 4875da975f..788d512610 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/CreditScore.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/CreditScore.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker.domain; + /** * @author Oleg Zhurakousky - * */ public class CreditScore { + private final int score; private String creditHistory; diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Customer.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Customer.java index 4b23fa9842..f72c899991 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Customer.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,35 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.loanbroker.domain; +package org.springframework.integration.loanbroker.domain; /** * @author Oleg Zhurakousky - * */ public class Customer { - private String fname; - private String lname; + private String firstName; + private String lastName; private Address address; - - public String getFname() { - return fname; + + public String getFirstName() { + return firstName; } - public void setFname(String fname) { - this.fname = fname; + + public void setFirstName(String firstName) { + this.firstName = firstName; } - public String getLname() { - return lname; + + public String getLastName() { + return lastName; } - public void setLname(String lname) { - this.lname = lname; + + public void setLastName(String lastName) { + this.lastName = lastName; } + public Address getAddress() { return address; } + public void setAddress(Address address) { this.address = address; } + } diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanQuote.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanQuote.java index 958d4edce6..782751c614 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanQuote.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanQuote.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.loanbroker.domain; import java.text.DecimalFormat; @@ -20,7 +21,6 @@ import java.util.Date; /** * @author Oleg Zhurakousky - * */ public class LoanQuote implements Comparable{ @@ -34,36 +34,47 @@ public class LoanQuote implements Comparable{ public String getLender() { return lender; } + public void setLender(String lender) { this.lender = lender; } + public Date getQuoteDate() { return quoteDate; } + public void setQuoteDate(Date quoteDate) { this.quoteDate = quoteDate; } + public Date getExpirationDate() { return expirationDate; } + public void setExpirationDate(Date expirationDate) { this.expirationDate = expirationDate; } + public double getLoanAmount() { return loanAmount; } + public void setLoanAmount(double loanAmount) { this.loanAmount = loanAmount; } + public int getLoanTerm() { return loanTerm; } + public void setLoanTerm(int loanTerm) { this.loanTerm = loanTerm; } + public float getRate() { return rate; } + public void setRate(float rate) { this.rate = rate; } @@ -81,11 +92,13 @@ public class LoanQuote implements Comparable{ } public int compareTo(LoanQuote loanQuote) { - if (loanQuote.rate > this.rate){ + if (loanQuote.rate > this.rate) { return 1; - } else if (loanQuote.rate < this.rate){ + } + else if (loanQuote.rate < this.rate) { return -1; } return 0; } + } diff --git a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanRequest.java b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanRequest.java index fda57d4e0a..65bd785fe5 100644 --- a/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanRequest.java +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/domain/LoanRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,27 +13,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.loanbroker.domain; +package org.springframework.integration.loanbroker.domain; /** * @author Oleg Zhurakousky - * */ public class LoanRequest { private Customer customer; private float loanAmount; + public Customer getCustomer() { return customer; } + public void setCustomer(Customer customer) { this.customer = customer; } + public float getLoanAmount() { return loanAmount; } + public void setLoanAmount(float loanAmount) { this.loanAmount = loanAmount; } + }