INT-1028, Initial commit of Loan Broker RI

This commit is contained in:
Oleg Zhurakousky
2010-03-12 06:09:59 +00:00
parent 1291a586c2
commit f8e6e3157f
18 changed files with 845 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>loan-broker</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.springframework.ide.eclipse.core.springnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,96 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>loan.broker</groupId>
<artifactId>loan.broker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>org.springframework.integration</artifactId>
<version>2.0.0.BUILD-20100312044142</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.spring-library</artifactId>
<type>libd</type>
<version>3.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>com.springsource.org.junit</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>com.springsource.org.mockito</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
<version>1.2.15</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>EBR Spring Release Repository</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>EBR External Release Repository</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>org.springframework.maven.milestone</id>
<name>Maven Central Compatible Spring Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.milestone</id>
<name>EBR Spring Milestone Repository</name>
<url>http://repository.springsource.com/maven/bundles/milestone</url>
</repository>
<repository>
<id>org.springframework.maven.snapshot</id>
<name>Maven Central Compatible Spring Snapshot Repository</name>
<url>http://maven.springframework.org/snapshot</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.snapshot</id>
<name>EBR Spring Snapshot Repository</name>
<url>http://repository.springsource.com/maven/bundles/snapshot</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/release</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.external</id>
<name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/external</url>
</repository>
</repositories>
</project>

View File

@@ -0,0 +1,74 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.core.Message;
/**
* Will select channel names from the map of banks based on provided SpEL expression.<br>
* For example:<br><pre>
* headers['CREDIT_SCORE'].score > 780 ? #banks.?[value.equals('premier')].keySet()
* : #banks.?[value.equals('secondary')].keySet()
* </pre><br>
* The above SpEL expression upon evaluation will return the list of premier bank
* channels if customer's credit score is above 780.
*
* @author Oleg Zhurakousky
*
*/
public class BanksChannelSelector {
private static Logger logger = Logger.getLogger(BanksChannelSelector.class);
private Map<String, String> bankChannelPool;
private String routingExpression;
/**
*
* @param bankChannelPool
*/
public BanksChannelSelector(Map<String, String> bankChannelPool){
this.bankChannelPool = bankChannelPool;
}
/**
*
* @param message
* @return
*/
@SuppressWarnings("unchecked")
public Set<String> selectBankChannels(Message<?> message) {
EvaluationContext context = new StandardEvaluationContext(message);
context.setVariable("banks", bankChannelPool);
ExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression(routingExpression);
Set<String> bankChannels = (Set<String>) expression.getValue(context);
logger.debug("Selected bank channels: " + bankChannels);
return bankChannels;
}
/**
* @param routingExpression
*/
public void setRoutingExpression(String routingExpression) {
this.routingExpression = routingExpression;
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker;
import java.util.List;
import org.springframework.integration.loanbroker.domain.LoanQuote;
import org.springframework.integration.loanbroker.domain.LoanRequest;
/**
* POJI Gateway which connects method invocations to the request-channel
* completely isolating SI developer from SI API details.
*
* @author Oleg Zhurakousky
*
*/
public interface LoanBrokerGateway {
/**
* Will return the best {@link LoanQuote}
*
* @param loanRequest
* @return
*/
public LoanQuote getLoanQuote(LoanRequest loanRequest);
/**
* Will return all {@link LoanQuote}s
* @param loanRequest
* @return
*/
public List<LoanQuote> getAllLoanQuotes(LoanRequest loanRequest);
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.integration.core.Message;
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
* {@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.
*
* @author Oleg Zhurakousky
*
*/
public class LoanQuoteAggregator {
/**
* @param messages
* @return
*/
@SuppressWarnings({ "unused", "unchecked" })
private Object aggregateQuotes(List<Message<LoanQuote>> 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 {
Collections.sort(payloads);
return payloads.get(0);
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker.demo;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.loanbroker.LoanBrokerGateway;
import org.springframework.integration.loanbroker.domain.Customer;
import org.springframework.integration.loanbroker.domain.LoanQuote;
import org.springframework.integration.loanbroker.domain.LoanRequest;
/**
* @author Oleg Zhurakousky
*
*/
public class LoanBrokerDemo {
private static Logger logger = Logger.getLogger(LoanBrokerDemo.class);
/**
* @param args
*/
public static void main(String[] args) {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("loan-broker-config.xml");
LoanBrokerGateway broker = ac.getBean("loanBrokerGateway", LoanBrokerGateway.class);
LoanRequest loanRequest = new LoanRequest();
loanRequest.setCustomer(new Customer());
LoanQuote loan = broker.getLoanQuote(loanRequest);
logger.info("\n********* Best Quote: " + loan);
List<LoanQuote> loanQuotes = broker.getAllLoanQuotes(loanRequest);
logger.info("\n********* All Quotes: ");
for (LoanQuote loanQuote : loanQuotes) {
logger.info(loanQuote);
}
ac.close();
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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;
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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;
public CreditScore(int score){
this.score = score;
}
public String getCreditHistory() {
return creditHistory;
}
public void setCreditHistory(String creditHistory) {
this.creditHistory = creditHistory;
}
public int getScore() {
return score;
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 Customer {
private String fname;
private String lname;
private Address address;
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker.domain;
import java.text.DecimalFormat;
import java.util.Date;
/**
* @author Oleg Zhurakousky
*
*/
public class LoanQuote implements Comparable<LoanQuote>{
private String lender;
private Date quoteDate;
private Date expirationDate;
private double loanAmount;
private int loanTerm;
private float rate;
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;
}
public String toString(){
return "\n====== Loan Quote =====\n" +
"Lender: " + lender + "\n" +
"Loan amount: " + new DecimalFormat("$###,###.###").format(loanAmount) + "\n" +
"Quotation Date: " + quoteDate + "\n" +
"Expiration Date: " + expirationDate + "\n" +
"Term: " + loanTerm + " years" + "\n" +
"Rate: " + rate + "%\n" +
"=======================\n";
}
public int compareTo(LoanQuote loanQuote) {
if (loanQuote.rate > this.rate){
return 1;
} else if (loanQuote.rate < this.rate){
return -1;
}
return 0;
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 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;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker.stubs;
import java.util.Calendar;
import java.util.Random;
import org.springframework.integration.loanbroker.domain.LoanQuote;
import org.springframework.integration.loanbroker.domain.LoanRequest;
/**
* @author Oleg Zhurakousky
*
*/
public class BankStub {
/**
*
* @param loanRequest
* @return
*/
public LoanQuote quote(LoanRequest loanRequest){
Calendar calendar = Calendar.getInstance();
LoanQuote loanQuote = new LoanQuote();
Random random = new Random();
loanQuote.setQuoteDate(calendar.getTime());
calendar.add(Calendar.DAY_OF_YEAR, random.nextInt(25));
loanQuote.setExpirationDate(calendar.getTime());
loanQuote.setRate(random.nextFloat() + 5);
loanQuote.setLoanTerm(10 + random.nextInt(10));
loanQuote.setLoanAmount(250000 + random.nextInt(40000));
loanQuote.setLender("StubBank-" + random.nextInt(30));
return loanQuote;
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.loanbroker.stubs;
import java.util.Random;
import org.apache.log4j.Logger;
import org.springframework.integration.loanbroker.domain.CreditScore;
import org.springframework.integration.loanbroker.domain.LoanRequest;
/**
* @author Oleg Zhurakousky
*
*/
public class CreditBureauStub {
private static Logger logger = Logger.getLogger(CreditBureauStub.class);
/**
*
* @param loanRequest
* @return
*/
public CreditScore getCreditScore(LoanRequest loanRequest){
Random random = new Random();
int creditScore = 750 + random.nextInt(100);
logger.info("Credit Score: " + creditScore);
return new CreditScore(creditScore);
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:util="http://www.springframework.org/schema/util">
<util:map id="banks">
<entry key="abcBankChannel" value="premier" />
<entry key="efgBankChannel" value="premier" />
<entry key="hijBankChannel" value="secondary" />
<entry key="xyzBankChannel" value="secondary" />
<entry key="fooBankChannel" value="secondary" />
</util:map>
</beans>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:util="http://www.springframework.org/schema/util">
<import resource="classpath:bank-channel-mappings-config.xml" />
<import resource="classpath:stub-services-config.xml" />
<int:gateway id="loanBrokerGateway"
default-request-channel="loanBrokerPreProcessingChannel"
service-interface="org.springframework.integration.loanbroker.LoanBrokerGateway"/>
<int:chain input-channel="loanBrokerPreProcessingChannel" output-channel="banksDistributionChannel">
<int:header-enricher>
<int:header name="RESPONSE_TYPE"
expression="headers.history.iterator().next().attributes['method'].equals('getLoanQuote') ? 'BEST' : 'ALL'" />
</int:header-enricher>
<int:header-enricher>
<int:header name="CREDIT_SCORE" ref="creditBureau" method="getCreditScore"/>
</int:header-enricher>
<int:header-enricher>
<int:header name="BANKS" ref="bankSelector" method="selectBankChannels"/>
</int:header-enricher>
</int:chain>
<int:router id="bankRecipientListRouter" input-channel="banksDistributionChannel"
expression="headers['BANKS']"
apply-sequence="true"/>
<!-- Messages are sent to the banks via bank channels and will be recieved and processed by aggregator-->
<int:aggregator input-channel="quotesAggregationChannel" method="aggregateQuotes">
<bean class="org.springframework.integration.loanbroker.LoanQuoteAggregator"/>
</int:aggregator>
<bean id="bankSelector" class="org.springframework.integration.loanbroker.BanksChannelSelector">
<constructor-arg ref="banks"/>
<property name="routingExpression">
<value>
headers['CREDIT_SCORE'].score > 780 ? #banks.?[value.equals('premier')].keySet()
: #banks.?[value.equals('secondary')].keySet()
</value>
</property>
</bean>
</beans>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<!-- Loggers -->
<logger name="org.springframework">
<level value="warn" />
</logger>
<logger name="org.springframework.integration">
<level value="warn" />
</logger>
<logger name="org.springframework.integration.loanbroker">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"
xmlns:int="http://www.springframework.org/schema/integration">
<bean id="creditBureau" class="org.springframework.integration.loanbroker.stubs.CreditBureauStub" />
<bean id="bankStub" class="org.springframework.integration.loanbroker.stubs.BankStub"/>
<!-- Bank Endpoints (to be rewired to remoting adapters) -->
<int:service-activator input-channel="abcBankChannel" output-channel="quotesAggregationChannel" ref="bankStub"/>
<int:service-activator input-channel="efgBankChannel" output-channel="quotesAggregationChannel" ref="bankStub"/>
<int:service-activator input-channel="hijBankChannel" output-channel="quotesAggregationChannel" ref="bankStub"/>
<int:service-activator input-channel="xyzBankChannel" output-channel="quotesAggregationChannel" ref="bankStub"/>
<int:service-activator input-channel="fooBankChannel" output-channel="quotesAggregationChannel" ref="bankStub"/>
<!-- end Bank Endpoints -->
</beans>