diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java index 8e4577f0f2..b6b85f62f0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java @@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; @@ -33,12 +32,9 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio *

* Activates when the application is a web application and no * {@link RepositoryRestMvcConfiguration} is found. - *

*

- * Once in effect, the auto-configuration allows to configure any property - * of {@link RepositoryRestConfiguration} using the {@code spring.data.rest} - * prefix. - *

+ * Once in effect, the auto-configuration allows to configure any property of + * {@link RepositoryRestConfiguration} using the {@code spring.data.rest} prefix. * * @author Rob Winch * @author Stephane Nicoll @@ -48,18 +44,17 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio @ConditionalOnWebApplication @ConditionalOnMissingBean(RepositoryRestMvcConfiguration.class) @ConditionalOnClass(RepositoryRestMvcConfiguration.class) -@Import(RepositoryRestMvcAutoConfiguration.RepositoryRestMvcBootConfiguration.class) public class RepositoryRestMvcAutoConfiguration { + static class RepositoryRestMvcBootConfiguration extends + RepositoryRestMvcConfiguration { - @Configuration - static class RepositoryRestMvcBootConfiguration extends RepositoryRestMvcConfiguration { - - @Override @Bean @ConfigurationProperties(prefix = "spring.data.rest") + @Override public RepositoryRestConfiguration config() { return super.config(); } + } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java index bbc40dbe4c..78a9e1a53e 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java @@ -20,7 +20,6 @@ import java.net.URI; import org.junit.After; import org.junit.Test; - import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; @@ -36,7 +35,8 @@ import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Tests for {@link RepositoryRestMvcAutoConfiguration}. @@ -64,7 +64,8 @@ public class RepositoryRestMvcAutoConfigurationTests { public void testWithCustomBaseUri() throws Exception { load(TestConfiguration.class, "spring.data.rest.baseUri:foo"); assertNotNull(this.context.getBean(RepositoryRestMvcConfiguration.class)); - RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class); + RepositoryRestConfiguration bean = this.context + .getBean(RepositoryRestConfiguration.class); assertEquals("Custom baseURI not set", URI.create("foo"), bean.getBaseUri()); } @@ -72,17 +73,17 @@ public class RepositoryRestMvcAutoConfigurationTests { public void backOffWithCustomConfiguration() { load(TestConfigurationWithRestMvcConfig.class, "spring.data.rest.baseUri:foo"); assertNotNull(this.context.getBean(RepositoryRestMvcConfiguration.class)); - RepositoryRestConfiguration bean = this.context.getBean(RepositoryRestConfiguration.class); - assertEquals("Custom base URI should not have been set", URI.create(""), bean.getBaseUri()); + RepositoryRestConfiguration bean = this.context + .getBean(RepositoryRestConfiguration.class); + assertEquals("Custom base URI should not have been set", URI.create(""), + bean.getBaseUri()); } - private void load(Class config, - String... environment) { + private void load(Class config, String... environment) { AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); applicationContext.setServletContext(new MockServletContext()); - applicationContext.register(config, - EmbeddedDataSourceConfiguration.class, + applicationContext.register(config, EmbeddedDataSourceConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, @@ -99,7 +100,7 @@ public class RepositoryRestMvcAutoConfigurationTests { } - @Import({TestConfiguration.class, RepositoryRestMvcConfiguration.class}) + @Import({ TestConfiguration.class, RepositoryRestMvcConfiguration.class }) protected static class TestConfigurationWithRestMvcConfig { } diff --git a/spring-boot-cli/src/test/resources/repro-samples/caching.groovy b/spring-boot-cli/samples/caching.groovy similarity index 100% rename from spring-boot-cli/src/test/resources/repro-samples/caching.groovy rename to spring-boot-cli/samples/caching.groovy diff --git a/spring-boot-cli/samples/jms.groovy b/spring-boot-cli/samples/jms.groovy index 09f5488e1e..c03672877f 100644 --- a/spring-boot-cli/samples/jms.groovy +++ b/spring-boot-cli/samples/jms.groovy @@ -28,4 +28,5 @@ class JmsExample implements CommandLineRunner { log.info "Received ${message}" latch.countDown() } -} \ No newline at end of file + +} diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingCompilerAutoConfiguration.java similarity index 90% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingAutoConfiguration.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingCompilerAutoConfiguration.java index dc0bced56a..48e7d08ea6 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/CachingCompilerAutoConfiguration.java @@ -19,7 +19,6 @@ package org.springframework.boot.cli.compiler.autoconfigure; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.customizers.ImportCustomizer; - import org.springframework.boot.cli.compiler.AstUtils; import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; import org.springframework.boot.cli.compiler.DependencyCustomizer; @@ -30,7 +29,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; * @author Stephane Nicoll * @since 1.2.0 */ -public class CachingAutoConfiguration extends CompilerAutoConfiguration { +public class CachingCompilerAutoConfiguration extends CompilerAutoConfiguration { @Override public boolean matches(ClassNode classNode) { @@ -41,13 +40,13 @@ public class CachingAutoConfiguration extends CompilerAutoConfiguration { public void applyDependencies(DependencyCustomizer dependencies) throws CompilationFailedException { dependencies.add("spring-context-support"); - } @Override public void applyImports(ImportCustomizer imports) throws CompilationFailedException { imports.addStarImports("org.springframework.cache", - "org.springframework.cache.annotation", "org.springframework.cache.concurrent"); + "org.springframework.cache.annotation", + "org.springframework.cache.concurrent"); } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java index 4c0b2c42b6..8fdb271470 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java @@ -22,7 +22,6 @@ import org.codehaus.groovy.control.customizers.ImportCustomizer; import org.springframework.boot.cli.compiler.AstUtils; import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; import org.springframework.boot.cli.compiler.DependencyCustomizer; -import org.springframework.boot.groovy.EnableJmsMessaging; /** * {@link CompilerAutoConfiguration} for Spring JMS. @@ -34,26 +33,25 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration { @Override public boolean matches(ClassNode classNode) { - return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms") || - AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging"); + return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJms") + || AstUtils.hasAtLeastOneAnnotation(classNode, "EnableJmsMessaging"); } @Override public void applyDependencies(DependencyCustomizer dependencies) throws CompilationFailedException { dependencies.add("spring-jms", "jms-api"); - } @Override + @SuppressWarnings("deprecation") public void applyImports(ImportCustomizer imports) throws CompilationFailedException { - imports.addStarImports("javax.jms", - "org.springframework.jms.annotation", - "org.springframework.jms.config", - "org.springframework.jms.core", + imports.addStarImports("javax.jms", "org.springframework.jms.annotation", + "org.springframework.jms.config", "org.springframework.jms.core", "org.springframework.jms.listener", - "org.springframework.jms.listener.adapter") - .addImports(EnableJmsMessaging.class.getCanonicalName()); + "org.springframework.jms.listener.adapter").addImports( + org.springframework.boot.groovy.EnableJmsMessaging.class + .getCanonicalName()); } } diff --git a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration index c291bf53ff..c3340efaeb 100644 --- a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration +++ b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration @@ -4,7 +4,7 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfigu org.springframework.boot.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.RabbitCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.ReactorCompilerAutoConfiguration -org.springframework.boot.cli.compiler.autoconfigure.CachingAutoConfiguration +org.springframework.boot.cli.compiler.autoconfigure.CachingCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.JdbcCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.JUnitCompilerAutoConfiguration @@ -17,4 +17,4 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringSocialFacebookCompiler org.springframework.boot.cli.compiler.autoconfigure.SpringSocialLinkedInCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringSocialTwitterCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringTestCompilerAutoConfiguration -org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration \ No newline at end of file +org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java index e73f4cdc3b..17e7f88cc5 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java @@ -27,6 +27,8 @@ import org.junit.Test; import org.springframework.boot.cli.command.grab.GrabCommand; import org.springframework.util.FileSystemUtils; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -68,8 +70,9 @@ public class GrabCommandIntegrationTests { this.cli.grab("duplicateGrabMetadata.groovy"); fail(); } - catch (Exception e) { - assertTrue(e.getMessage().contains("Duplicate @GrabMetadata annotation")); + catch (Exception ex) { + assertThat(ex.getMessage(), + containsString("Duplicate @GrabMetadata annotation")); } } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java index 59c16df65e..a653f61275 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java @@ -79,9 +79,4 @@ public class ReproIntegrationTests { assertThat(this.cli.getOutput(), containsString("Hello World")); } - @Test - public void caching() throws Exception { - this.cli.run("caching.groovy"); - assertThat(this.cli.getOutput(), containsString("Hello World")); - } } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java index fa813f698d..bc6bb0444e 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java @@ -24,7 +24,9 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -156,4 +158,10 @@ public class SampleIntegrationTests { assertEquals("Hello Normal Device!", this.cli.getHttpOutput()); } + @Test + public void caching() throws Exception { + this.cli.run("caching.groovy"); + assertThat(this.cli.getOutput(), containsString("Hello World")); + } + } diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 8923ac69f8..1753baeb2b 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1847,6 +1847,7 @@ resolved against their provided names. +[[boot-features-using-jms-template]] [[boot-features-using-jms-sending]] ==== Sending a message Spring's `JmsTemplate` is auto-configured and you can autowire it directly into your @@ -1876,6 +1877,8 @@ own beans: NOTE: {spring-javadoc}/jms/core/JmsMessagingTemplate.{dc-ext}[`JmsMessagingTemplate`] (new in Spring 4.1) can be injected in a similar manner. + + [[boot-features-using-jms-receiving]] ==== Receiving a message diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java index 16fbdd589a..fa8d6a61c5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java @@ -80,7 +80,7 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso if (!this.beans.containsKey(beanName)) { return null; } - final AtomicReference found = new AtomicReference(); + final AtomicReference found = new AtomicReference(null); MetaData meta = this.beans.get(beanName); final String factory = meta.getMethod(); Class type = this.beanFactory.getType(meta.getBean()); @@ -88,8 +88,8 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { - if (found.get() == null && method.getName().equals(factory)) { - found.set(method); + if (method.getName().equals(factory)) { + found.compareAndSet(null, method); } } });