diff --git a/applications/loan-broker/src/main/java/org/springframework/integration/samples/loanbroker/domain/LoanQuote.java b/applications/loan-broker/src/main/java/org/springframework/integration/samples/loanbroker/domain/LoanQuote.java index e76af5f2..38b4749b 100644 --- a/applications/loan-broker/src/main/java/org/springframework/integration/samples/loanbroker/domain/LoanQuote.java +++ b/applications/loan-broker/src/main/java/org/springframework/integration/samples/loanbroker/domain/LoanQuote.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 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. @@ -20,6 +20,7 @@ import java.util.Date; /** * @author Oleg Zhurakousky + * @author Gary Russell */ public class LoanQuote implements Comparable{ @@ -78,8 +79,9 @@ public class LoanQuote implements Comparable{ this.rate = rate; } + @Override public int compareTo(LoanQuote other) { - if (this.rate > other.rate) { + if (this.rate > other.rate) { //NOSONAR return 1; } else if (this.rate < other.rate) { @@ -88,8 +90,9 @@ public class LoanQuote implements Comparable{ return 0; } + @Override public String toString() { - return this.lender + ":\t" + this.rate; + return this.lender + ":\t" + this.rate; } } diff --git a/applications/loanshark/src/main/java/org/springframework/integration/samples/loanbroker/loanshark/biz/Accumulator.java b/applications/loanshark/src/main/java/org/springframework/integration/samples/loanbroker/loanshark/biz/Accumulator.java index e2473717..941c9d9f 100644 --- a/applications/loanshark/src/main/java/org/springframework/integration/samples/loanbroker/loanshark/biz/Accumulator.java +++ b/applications/loanshark/src/main/java/org/springframework/integration/samples/loanbroker/loanshark/biz/Accumulator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 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. @@ -38,7 +38,7 @@ public class Accumulator { if (shark == null) { shark = new LoanShark(); shark.setName(quote.getSharkName()); - shark.setCounter(new Long(0)); + shark.setCounter(Long.valueOf(0)); shark.setAverageRate(0.0d); shark.persist(); } @@ -46,5 +46,5 @@ public class Accumulator { shark.setCounter(shark.getCounter().longValue() + 1); shark.setAverageRate((current + quote.getSharkRate()) / shark.getCounter()); } - + } diff --git a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/Main.java b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/Main.java index b909f4f6..83d89738 100644 --- a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/Main.java +++ b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/Main.java @@ -22,6 +22,7 @@ import java.util.Scanner; import org.apache.log4j.Logger; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.samples.enricher.domain.User; import org.springframework.integration.samples.enricher.service.UserService; diff --git a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/User.java b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/domain/User.java similarity index 54% rename from basic/enricher/src/main/java/org/springframework/integration/samples/enricher/User.java rename to basic/enricher/src/main/java/org/springframework/integration/samples/enricher/domain/User.java index eb6defa9..cd0d388a 100644 --- a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/User.java +++ b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/domain/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2015 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 @@ -10,31 +10,34 @@ * 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.samples.enricher; +package org.springframework.integration.samples.enricher.domain; public class User { - private String username; - private String password; - private String email; - public User(String username, String password, String email) { - super(); - this.username = username; - this.password = password; - this.email = email; - } + private String username; - public String getUsername() { - return this.username; - } + private String password; - public String getPassword() { - return this.password; - } + private String email; - public String getEmail() { - return this.email; - } + public User(String username, String password, String email) { + super(); + this.username = username; + this.password = password; + this.email = email; + } + + public String getUsername() { + return this.username; + } + + public String getPassword() { + return this.password; + } + + public String getEmail() { + return this.email; + } public void setUsername(String username) { this.username = username; @@ -51,12 +54,8 @@ public class User { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("User [username=") - .append(this.username) - .append(", password=") - .append(this.password) - .append(", email=") - .append(this.email).append("]"); + builder.append("User [username=").append(this.username).append(", password=").append(this.password) + .append(", email=").append(this.email).append("]"); return builder.toString(); } diff --git a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/UserService.java b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/UserService.java index 3b2cdcac..f90cbb00 100644 --- a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/UserService.java +++ b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/UserService.java @@ -17,7 +17,7 @@ package org.springframework.integration.samples.enricher.service; import java.util.Map; -import org.springframework.integration.samples.enricher.User; +import org.springframework.integration.samples.enricher.domain.User; /** * Provides user services. diff --git a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/impl/SystemService.java b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/impl/SystemService.java index 42140320..2d42f2bc 100644 --- a/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/impl/SystemService.java +++ b/basic/enricher/src/main/java/org/springframework/integration/samples/enricher/service/impl/SystemService.java @@ -16,7 +16,8 @@ package org.springframework.integration.samples.enricher.service.impl; import org.apache.log4j.Logger; -import org.springframework.integration.samples.enricher.User; + +import org.springframework.integration.samples.enricher.domain.User; /** * Simple Service class for retrieving user information. diff --git a/basic/enricher/src/test/java/org/springframework/integration/samples/enricher/service/UserServiceTest.java b/basic/enricher/src/test/java/org/springframework/integration/samples/enricher/service/UserServiceTest.java index 1c11cafb..4a362520 100644 --- a/basic/enricher/src/test/java/org/springframework/integration/samples/enricher/service/UserServiceTest.java +++ b/basic/enricher/src/test/java/org/springframework/integration/samples/enricher/service/UserServiceTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.integration.samples.enricher.User; +import org.springframework.integration.samples.enricher.domain.User; /** diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Main.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Main.java index 2da9961d..22cea2a4 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Main.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Main.java @@ -24,6 +24,8 @@ import java.util.Scanner; import org.apache.log4j.Logger; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.samples.jdbc.domain.Gender; +import org.springframework.integration.samples.jdbc.domain.Person; import org.springframework.integration.samples.jdbc.service.PersonService; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Gender.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Gender.java similarity index 95% rename from basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Gender.java rename to basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Gender.java index 24a2f65a..dbcd3099 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Gender.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Gender.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.jdbc; +package org.springframework.integration.samples.jdbc.domain; import java.util.EnumSet; import java.util.HashMap; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Person.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Person.java similarity index 96% rename from basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Person.java rename to basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Person.java index b6781e36..6ba4fc3f 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/Person.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/Person.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.jdbc; +package org.springframework.integration.samples.jdbc.domain; import java.util.Date; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/PersonMapper.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/PersonMapper.java similarity index 95% rename from basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/PersonMapper.java rename to basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/PersonMapper.java index 06530d5b..b74b407f 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/PersonMapper.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/PersonMapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.jdbc; +package org.springframework.integration.samples.jdbc.domain; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/User.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/User.java similarity index 94% rename from basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/User.java rename to basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/User.java index 2fcbd1f5..ef655d9d 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/User.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/User.java @@ -10,7 +10,7 @@ * 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.samples.jdbc; +package org.springframework.integration.samples.jdbc.domain; public class User { private String username; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/UserMapper.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/UserMapper.java similarity index 93% rename from basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/UserMapper.java rename to basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/UserMapper.java index ce87ceb3..4d132ecd 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/UserMapper.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/domain/UserMapper.java @@ -10,7 +10,7 @@ * 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.samples.jdbc; +package org.springframework.integration.samples.jdbc.domain; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/service/PersonService.java b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/service/PersonService.java index 59e228f9..738298b7 100644 --- a/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/service/PersonService.java +++ b/basic/jdbc/src/main/java/org/springframework/integration/samples/jdbc/service/PersonService.java @@ -18,7 +18,7 @@ package org.springframework.integration.samples.jdbc.service; import java.util.List; -import org.springframework.integration.samples.jdbc.Person; +import org.springframework.integration.samples.jdbc.domain.Person; /** * The Service used to create Person instance in database diff --git a/basic/jdbc/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/basic/jdbc/src/main/resources/META-INF/spring/integration/spring-integration-context.xml index 675bfd7c..cb7b0e5c 100644 --- a/basic/jdbc/src/main/resources/META-INF/spring/integration/spring-integration-context.xml +++ b/basic/jdbc/src/main/resources/META-INF/spring/integration/spring-integration-context.xml @@ -46,7 +46,7 @@ - + result = weatherAndTraffic.getByZip(zip); - System.out.println(result.get(0) + "\r\n" + result.get(1) + "\r\n"); + String line = console.readLine(); + if (line != null) { + String zip = line.trim(); + WeatherAndTraffic weatherAndTraffic = context.getBean("wat", WeatherAndTraffic.class); + List result = weatherAndTraffic.getByZip(zip); + System.out.println(result.get(0) + "\r\n" + result.get(1) + "\r\n"); + } + else { + System.out.println("Console closed"); + } context.close(); System.exit(0); } diff --git a/build.gradle b/build.gradle index b1717c3c..358969d3 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,14 @@ buildscript { allprojects { group = 'org.springframework.integration.samples' + + repositories { + // mavenLocal() + maven { url 'http://repo.spring.io/libs-snapshot' } + maven { url 'http://repo.spring.io/libs-milestone' } + // maven { url 'http://repo.spring.io/libs-staging-local' } + } + } subprojects { subproject -> @@ -138,16 +146,14 @@ subprojects { subproject -> } } - repositories { -// mavenLocal() - maven { url 'http://repo.spring.io/libs-snapshot' } - maven { url 'http://repo.spring.io/libs-milestone' } -// maven { url 'http://repo.spring.io/libs-staging-local' } - } - if (!(subproject.name in ['advanced', 'applications', 'basic', 'intermediate', 'cafe'])) { apply plugin: 'java' + apply plugin: 'jacoco' + + jacoco { + toolVersion = "0.7.2.201409121644" + } sourceCompatibility = 1.6 @@ -224,9 +230,21 @@ subprojects { subproject -> ext.xLintArg = '-Xlint:all,-options' [compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg] + jacocoTestReport { + reports { + xml.enabled false + csv.enabled false + html.destination "${buildDir}/reports/jacoco/html" + } + } + test { // suppress all console output during testing unless running `gradle -i` logging.captureStandardOutput(LogLevel.INFO) + jacoco { + append = false + destinationFile = file("$buildDir/jacoco.exec") + } } task checkTestConfigs << { @@ -249,6 +267,7 @@ subprojects { subproject -> } test.dependsOn checkTestConfigs + build.dependsOn jacocoTestReport } task cleanTarget(type: Delete) { @@ -1139,6 +1158,20 @@ project('stomp-chat') { } } +apply plugin: 'sonar-runner' + +sonarRunner { + sonarProperties { + property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec" + property "sonar.links.homepage", linkHomepage + property "sonar.links.ci", linkCi + property "sonar.links.issue", linkIssue + property "sonar.links.scm", linkScmUrl + property "sonar.links.scm_dev", linkScmDevConnection + property "sonar.java.coveragePlugin", "jacoco" + } +} + task wrapper(type: Wrapper) { description = 'Generates gradlew[.bat] scripts' gradleVersion = '2.3' diff --git a/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java b/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java index c365215a..76bc2054 100644 --- a/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java +++ b/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java @@ -19,11 +19,11 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; +import org.springframework.jmx.export.annotation.ManagedOperation; +import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.ChannelInterceptorAdapter; -import org.springframework.jmx.export.annotation.ManagedOperation; -import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.util.StopWatch; /** @@ -37,9 +37,9 @@ import org.springframework.util.StopWatch; @ManagedResource public class PayloadAwareTimingInterceptor extends ChannelInterceptorAdapter { - private ThreadLocal stopWatchHolder = new ThreadLocal(); + private final ThreadLocal stopWatchHolder = new ThreadLocal(); - private Map, Stats> statsMap = new ConcurrentHashMap, PayloadAwareTimingInterceptor.Stats>(); + private final Map, Stats> statsMap = new ConcurrentHashMap, PayloadAwareTimingInterceptor.Stats>(); /** * @@ -68,12 +68,12 @@ public class PayloadAwareTimingInterceptor extends ChannelInterceptorAdapter { StopWatchHolder holder = this.stopWatchHolder.get(); if (holder != null) { holder.getStopWatch().stop(); + Stats stats = this.statsMap.get(holder.getType()); + if (stats == null) { + stats = this.statsMap.get(Object.class); + } + stats.add(holder.getStopWatch().getLastTaskTimeMillis()); } - Stats stats = this.statsMap.get(holder.getType()); - if (stats == null) { - stats = this.statsMap.get(Object.class); - } - stats.add(holder.getStopWatch().getLastTaskTimeMillis()); } @ManagedOperation diff --git a/intermediate/rest-http/src/main/java/org/springframework/integration/samples/rest/service/EmployeeSearchService.java b/intermediate/rest-http/src/main/java/org/springframework/integration/samples/rest/service/EmployeeSearchService.java index d618135b..e5a30abb 100644 --- a/intermediate/rest-http/src/main/java/org/springframework/integration/samples/rest/service/EmployeeSearchService.java +++ b/intermediate/rest-http/src/main/java/org/springframework/integration/samples/rest/service/EmployeeSearchService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 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. @@ -19,17 +19,19 @@ import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; + +import org.springframework.integration.samples.rest.domain.Employee; +import org.springframework.integration.samples.rest.domain.EmployeeList; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.GenericMessage; -import org.springframework.integration.samples.rest.domain.Employee; -import org.springframework.integration.samples.rest.domain.EmployeeList; import org.springframework.security.access.annotation.Secured; import org.springframework.stereotype.Service; /** * EmployeeSearchService.java: This is the default employee search service * @author Vigil Bose + * @author Gary Russell */ @Service("employeeSearchService") public class EmployeeSearchService { @@ -46,41 +48,46 @@ public class EmployeeSearchService { */ @Secured("ROLE_REST_HTTP_USER") public Message getEmployee(Message inMessage){ - + EmployeeList employeeList = new EmployeeList(); Map responseHeaderMap = new HashMap(); - + try{ MessageHeaders headers = inMessage.getHeaders(); String id = (String)headers.get("employeeId"); boolean isFound; - if (id.equals("1")){ + if (id.equals("1")) { employeeList.getEmployee().add(new Employee(1, "John", "Doe")); isFound = true; - }else if (id.equals("2")){ + } + else if (id.equals("2")) { employeeList.getEmployee().add(new Employee(2, "Jane", "Doe")); isFound = true; - }else if (id.equals("0")){ - employeeList.getEmployee().add(new Employee(1, "John", "Doe")); - employeeList.getEmployee().add(new Employee(2, "Jane", "Doe")); - isFound = true; - }else{ - isFound = false; - } - if (isFound){ - setReturnStatusAndMessage("0", "Success", employeeList, responseHeaderMap); - }else{ - setReturnStatusAndMessage("2", "Employee Not Found", employeeList, responseHeaderMap); } - - }catch (Throwable e){ + else if (id.equals("0")) { + employeeList.getEmployee().add(new Employee(1, "John", "Doe")); + employeeList.getEmployee().add(new Employee(2, "Jane", "Doe")); + isFound = true; + } + else { + isFound = false; + } + if (isFound) { + setReturnStatusAndMessage("0", "Success", employeeList, responseHeaderMap); + } + else { + setReturnStatusAndMessage("2", "Employee Not Found", employeeList, responseHeaderMap); + } + + } + catch (Exception e) { setReturnStatusAndMessage("1", "System Error", employeeList, responseHeaderMap); - logger.error("System error occured :"+e); + logger.error("System error occured :" + e); } Message message = new GenericMessage(employeeList, responseHeaderMap); - return message; + return message; } - + /** * The API setReturnStatusAndMessage() sets the return status and return message * in the return message payload and its header. @@ -89,16 +96,17 @@ public class EmployeeSearchService { * @param employeeList * @param responseHeaderMap */ - private void setReturnStatusAndMessage(String status, - String message, - EmployeeList employeeList, + private void setReturnStatusAndMessage(String status, + String message, + EmployeeList employeeList, Map responseHeaderMap){ - + employeeList.setReturnStatus(status); employeeList.setReturnStatusMsg(message); responseHeaderMap.put("Return-Status", status); responseHeaderMap.put("Return-Status-Msg", message); } + } diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchA.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchA.java index 0264b738..536d4c22 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchA.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchA.java @@ -17,6 +17,8 @@ package org.springframework.integration.samples.splitteraggregator; import org.apache.log4j.Logger; +import org.springframework.integration.samples.splitteraggregator.support.CriteriaA; + /** * One type of search. * diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchB.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchB.java index 7c7fc934..30b3bfb0 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchB.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchB.java @@ -17,6 +17,8 @@ package org.springframework.integration.samples.splitteraggregator; import org.apache.log4j.Logger; +import org.springframework.integration.samples.splitteraggregator.support.CriteriaB; + /** * Another type of search. * diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestSplitter.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestSplitter.java index 90d3d134..8b15c6f3 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestSplitter.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestSplitter.java @@ -17,6 +17,9 @@ package org.springframework.integration.samples.splitteraggregator; import java.util.Collection; +import org.springframework.integration.samples.splitteraggregator.support.AbstractCriteria; +import org.springframework.integration.samples.splitteraggregator.support.CompositeCriteria; + /** * Given CompositeCriteria, return a collection of the individual criterion. * diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestor.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestor.java index 380e28ed..6e9703f6 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestor.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/SearchRequestor.java @@ -15,6 +15,8 @@ */ package org.springframework.integration.samples.splitteraggregator; +import org.springframework.integration.samples.splitteraggregator.support.CompositeCriteria; + /** * A service interface responsible for performing a search and returning a * result synchronously. diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/AbstractCriteria.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/AbstractCriteria.java similarity index 98% rename from intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/AbstractCriteria.java rename to intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/AbstractCriteria.java index fa322068..5f3d19ba 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/AbstractCriteria.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/AbstractCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.splitteraggregator; +package org.springframework.integration.samples.splitteraggregator.support; /** * A class that represents all criteria. diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CompositeCriteria.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CompositeCriteria.java similarity index 98% rename from intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CompositeCriteria.java rename to intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CompositeCriteria.java index 2e07e4d7..179e0e6a 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CompositeCriteria.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CompositeCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.splitteraggregator; +package org.springframework.integration.samples.splitteraggregator.support; import java.util.ArrayList; import java.util.Collection; diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaA.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaA.java similarity index 98% rename from intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaA.java rename to intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaA.java index 6823abbb..9dcf4a8a 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaA.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaA.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.splitteraggregator; +package org.springframework.integration.samples.splitteraggregator.support; /** * One type of criteria. diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaB.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaB.java similarity index 98% rename from intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaB.java rename to intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaB.java index 919032ca..cce90156 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/CriteriaB.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/CriteriaB.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.samples.splitteraggregator; +package org.springframework.integration.samples.splitteraggregator.support; /** * Another type of criteria. diff --git a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/TestUtils.java b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/TestUtils.java index 92cad645..456b58fa 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/TestUtils.java +++ b/intermediate/splitter-aggregator-reaper/src/main/java/org/springframework/integration/samples/splitteraggregator/support/TestUtils.java @@ -15,11 +15,6 @@ */ package org.springframework.integration.samples.splitteraggregator.support; -import org.springframework.integration.samples.splitteraggregator.CompositeCriteria; -import org.springframework.integration.samples.splitteraggregator.CriteriaA; -import org.springframework.integration.samples.splitteraggregator.CriteriaB; - - /** * @author Gunnar Hillert * @since 1.0 diff --git a/intermediate/splitter-aggregator-reaper/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/intermediate/splitter-aggregator-reaper/src/main/resources/META-INF/spring/integration/spring-integration-context.xml index 2ec88b76..23552cc2 100644 --- a/intermediate/splitter-aggregator-reaper/src/main/resources/META-INF/spring/integration/spring-integration-context.xml +++ b/intermediate/splitter-aggregator-reaper/src/main/resources/META-INF/spring/integration/spring-integration-context.xml @@ -26,10 +26,10 @@ diff --git a/intermediate/stored-procedures-derby/src/main/java/org/springframework/integration/samples/storedprocedure/jdbc/storedproc/derby/DerbyStoredProcedures.java b/intermediate/stored-procedures-derby/src/main/java/org/springframework/integration/samples/storedprocedure/jdbc/storedproc/derby/DerbyStoredProcedures.java index 93734cf3..8d6e2796 100644 --- a/intermediate/stored-procedures-derby/src/main/java/org/springframework/integration/samples/storedprocedure/jdbc/storedproc/derby/DerbyStoredProcedures.java +++ b/intermediate/stored-procedures-derby/src/main/java/org/springframework/integration/samples/storedprocedure/jdbc/storedproc/derby/DerbyStoredProcedures.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2015 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. @@ -26,6 +26,7 @@ import org.springframework.jdbc.support.JdbcUtils; /** * * @author Gunnar Hillert + * @author Gary Russell * @since 2.1 * */ @@ -49,7 +50,8 @@ public final class DerbyStoredProcedures { resultset.next(); coffeeDescription[0] = resultset.getString("COFFEE_DESCRIPTION"); - } finally { + } + finally { JdbcUtils.closeStatement(statement); JdbcUtils.closeConnection(connection); } @@ -62,10 +64,16 @@ public final class DerbyStoredProcedures { Connection connection = null; PreparedStatement statement = null; - connection = DriverManager.getConnection("jdbc:default:connection"); - String sql = "SELECT * FROM COFFEE_BEVERAGES"; - statement = connection.prepareStatement(sql); - coffeeBeverages[0] = statement.executeQuery(); + try { + connection = DriverManager.getConnection("jdbc:default:connection"); + String sql = "SELECT * FROM COFFEE_BEVERAGES"; + statement = connection.prepareStatement(sql);//NOSONAR see below + coffeeBeverages[0] = statement.executeQuery(); + } + finally { +// JdbcUtils.closeStatement(statement); // cannot close due to result set being returned + JdbcUtils.closeConnection(connection); + } } }