diff --git a/spring-integration-samples/loan-broker/pom.xml b/spring-integration-samples/loan-broker/pom.xml index f7bde072de..cfc449b703 100644 --- a/spring-integration-samples/loan-broker/pom.xml +++ b/spring-integration-samples/loan-broker/pom.xml @@ -10,6 +10,11 @@ org.springframework.integration 2.0.0.BUILD-SNAPSHOT + + org.springframework.integration + org.springframework.integration.ip + 2.0.0.BUILD-SNAPSHOT + org.springframework org.springframework.spring-library 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 new file mode 100644 index 0000000000..6cbc8a2ecb --- /dev/null +++ b/spring-integration-samples/loan-broker/src/main/java/org/springframework/integration/loanbroker/Transformer.java @@ -0,0 +1,29 @@ +/* + * 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. + * 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 org.springframework.integration.loanbroker.domain.LoanQuote; + +/** + * @author Gary Russell + * + */ +public class Transformer { + + public String transformShark(LoanQuote quote) { + return quote.getLender() + "," + quote.getRate(); + } +} diff --git a/spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml b/spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml new file mode 100644 index 0000000000..37b6873e1f --- /dev/null +++ b/spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubed-loan-broker.xml b/spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker.xml similarity index 100% rename from spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubed-loan-broker.xml rename to spring-integration-samples/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker.xml diff --git a/spring-integration-samples/loan-broker/src/main/resources/shark-detector-config.xml b/spring-integration-samples/loan-broker/src/main/resources/shark-detector-config.xml new file mode 100644 index 0000000000..5310dc9fdd --- /dev/null +++ b/spring-integration-samples/loan-broker/src/main/resources/shark-detector-config.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerDemo.java b/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerDemo.java index 23095921cb..39f6df0f0b 100644 --- a/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerDemo.java +++ b/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerDemo.java @@ -46,7 +46,7 @@ public class LoanBrokerDemo { public void runDemo() { ConfigurableApplicationContext ac = - new ClassPathXmlApplicationContext("bootstrap-config/stubed-loan-broker.xml"); + new ClassPathXmlApplicationContext("bootstrap-config/stubbed-loan-broker.xml"); LoanBrokerGateway broker = ac.getBean("loanBrokerGateway", LoanBrokerGateway.class); LoanRequest loanRequest = new LoanRequest(); diff --git a/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerSharkDetectorDemo.java b/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerSharkDetectorDemo.java new file mode 100644 index 0000000000..3080eb3e05 --- /dev/null +++ b/spring-integration-samples/loan-broker/src/test/java/org/springframework/integration/loanbroker/demo/LoanBrokerSharkDetectorDemo.java @@ -0,0 +1,58 @@ +/* + * 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. + * 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.junit.Test; +import org.springframework.context.ConfigurableApplicationContext; +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 Gary Russell + * + */ +public class LoanBrokerSharkDetectorDemo { + private static Logger logger = Logger.getLogger(LoanBrokerSharkDetectorDemo.class); + + @Test + public void testUdpMulticast() { + + ConfigurableApplicationContext ac = + new ClassPathXmlApplicationContext("bootstrap-config/stubbed-loan-broker-multicast.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 loanQuotes = broker.getAllLoanQuotes(loanRequest); + logger.info("\n********* All Quotes: "); + for (LoanQuote loanQuote : loanQuotes) { + logger.info(loanQuote); + } + + ac.close(); + } + +}