From 628a8c79aa4ba4b9dbf049dde7ec91eea7533300 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 29 Apr 2013 08:35:01 +0100 Subject: [PATCH] [bs-19] Medley of changes supporting integration apps * Use file adapters in sample instead of internal flow * Add Exception to signature of CommandLineRunner for implementation convenience * Updates for Security snapshots --- spring-bootstrap-cli/samples/app.groovy | 10 +-- spring-bootstrap-cli/samples/worker.groovy | 20 ----- .../bootstrap/cli/CleanCommand.java | 19 ++++- ...ingBootstrapCompilerAutoConfiguration.java | 2 +- ...gIntegrationCompilerAutoConfiguration.java | 1 + spring-bootstrap-cli/src/main/scripts/spring | 2 +- .../src/test/resources/log4j.properties | 2 + .../pom.xml | 2 +- .../HelloWorldService.java | 2 +- .../IntegrationBootstrapApplication.java | 2 +- .../sample/consumer/SampleEndpoint.java | 25 +++++++ .../ServiceProperties.java | 2 +- .../sample/service/SampleEndpoint.java | 22 ------ .../main/resources/integration-context.xml | 13 +++- .../src/main/resources/logback.xml | 29 ++++++++ .../IntegrationBootstrapApplicationTests.java | 74 +++++++++++++++++++ .../sample/producer/ProducerApplication.java | 28 +++++++ .../IntegrationBootstrapApplicationTests.java | 60 --------------- .../service/SecurityAutoConfiguration.java | 4 +- .../bootstrap/CommandLineRunner.java | 2 +- .../bootstrap/SpringApplication.java | 6 +- 21 files changed, 206 insertions(+), 121 deletions(-) delete mode 100644 spring-bootstrap-cli/samples/worker.groovy rename spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/{service => consumer}/HelloWorldService.java (85%) rename spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/{service => consumer}/IntegrationBootstrapApplication.java (93%) create mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/SampleEndpoint.java rename spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/{service => consumer}/ServiceProperties.java (94%) delete mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/SampleEndpoint.java create mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/logback.xml create mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplicationTests.java create mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/producer/ProducerApplication.java delete mode 100644 spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplicationTests.java diff --git a/spring-bootstrap-cli/samples/app.groovy b/spring-bootstrap-cli/samples/app.groovy index 2e66b62f00..a9b02bc70b 100644 --- a/spring-bootstrap-cli/samples/app.groovy +++ b/spring-bootstrap-cli/samples/app.groovy @@ -4,10 +4,10 @@ package org.test class Example implements CommandLineRunner { @Autowired - private MyService myService; + private MyService myService - public void run(String... args) { - print "Hello " + this.myService.sayWorld(); + void run(String... args) { + print "Hello " + this.myService.sayWorld() } } @@ -15,8 +15,8 @@ class Example implements CommandLineRunner { @Service class MyService { - public String sayWorld() { - return "World!"; + String sayWorld() { + return "World!" } } diff --git a/spring-bootstrap-cli/samples/worker.groovy b/spring-bootstrap-cli/samples/worker.groovy deleted file mode 100644 index c96696f593..0000000000 --- a/spring-bootstrap-cli/samples/worker.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.test - -@Grab("org.springframework.bootstrap:spring-bootstrap-service:0.0.1-SNAPSHOT") -@Grab("org.springframework.integration:spring-integration-dsl-groovy-amqp:1.0.0.M1") - -@Component -@EnableIntegrationPatterns -class SpringIntegrationExample implements CommandLineRunner { - - @Bean - MessageFlow flow(ApplicationContext context) { - def builder = new IntegrationBuilder(context) - builder.messageFlow { transform {"Hello, $it!"} } - } - - @Override - void run(String... args) { - print flow().sendAndReceive("World") - } -} diff --git a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/CleanCommand.java b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/CleanCommand.java index 4204043be1..a5461b9812 100644 --- a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/CleanCommand.java +++ b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/CleanCommand.java @@ -40,6 +40,10 @@ public class CleanCommand extends OptionParsingCommand { private OptionSpec allOption; + private OptionSpec ivyOption; + + private OptionSpec mvnOption; + public CleanCommand() { super("clean", "Clean up groovy grapes (useful if snapshots are needed and you need an update)"); @@ -54,13 +58,24 @@ public class CleanCommand extends OptionParsingCommand { protected OptionParser createOptionParser() { OptionParser parser = new OptionParser(); this.allOption = parser.accepts("all", "Clean all files (not just snapshots)"); + this.ivyOption = parser.accepts("ivy", + "Clean just ivy (grapes) cache. Default is on unless --maven is used."); + this.mvnOption = parser.accepts("maven", + "Clean just maven cache. Default is off."); return parser; } @Override protected void run(OptionSet options) throws Exception { - clean(options, getGrapesHome(options), Layout.IVY); - clean(options, getMavenHome(options), Layout.MAVEN); + if (!options.has(this.ivyOption)) { + clean(options, getGrapesHome(options), Layout.IVY); + } + if (options.has(this.mvnOption)) { + if (options.has(this.ivyOption)) { + clean(options, getGrapesHome(options), Layout.IVY); + } + clean(options, getMavenHome(options), Layout.MAVEN); + } } private void clean(OptionSet options, File root, Layout layout) { diff --git a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringBootstrapCompilerAutoConfiguration.java b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringBootstrapCompilerAutoConfiguration.java index 880bbb01b6..44c629a89f 100644 --- a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringBootstrapCompilerAutoConfiguration.java +++ b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringBootstrapCompilerAutoConfiguration.java @@ -60,7 +60,7 @@ public class SpringBootstrapCompilerAutoConfiguration extends CompilerAutoConfig @Override public void applyImports(ImportCustomizer imports) { imports.addImports("javax.sql.DataSource", "javax.annotation.PostConstruct", - "javax.annotation.PreDestroy", + "javax.annotation.PreDestroy", "groovy.util.logging.Log", "org.springframework.stereotype.Controller", "org.springframework.stereotype.Service", "org.springframework.stereotype.Component", diff --git a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java index 9940c5d13b..8b12cc5cf1 100644 --- a/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java +++ b/spring-bootstrap-cli/src/main/java/org/springframework/bootstrap/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java @@ -58,6 +58,7 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf @Override public void applyImports(ImportCustomizer imports) { imports.addImports("org.springframework.integration.Message", + "org.springframework.integration.support.MessageBuilder", "org.springframework.integration.MessageChannel", "org.springframework.integration.MessageHeaders", "org.springframework.integration.annotation.MessageEndpoint", diff --git a/spring-bootstrap-cli/src/main/scripts/spring b/spring-bootstrap-cli/src/main/scripts/spring index 65300773be..2b4095dee6 100755 --- a/spring-bootstrap-cli/src/main/scripts/spring +++ b/spring-bootstrap-cli/src/main/scripts/spring @@ -57,7 +57,7 @@ if [ -f build.gradle ]; then fi mkdir -p "${TARGETDIR%/}" -CLASSPATH="${SPRING_BIN}":"${TARGETDIR}" +CLASSPATH="${CLASSPATH}":"${SPRING_BIN}":"${TARGETDIR}" for f in "${SPRING_HOME}"/lib/*.jar; do CLASSPATH="${CLASSPATH}":$f diff --git a/spring-bootstrap-cli/src/test/resources/log4j.properties b/spring-bootstrap-cli/src/test/resources/log4j.properties index 23e8a102da..8e17be9f96 100644 --- a/spring-bootstrap-cli/src/test/resources/log4j.properties +++ b/spring-bootstrap-cli/src/test/resources/log4j.properties @@ -5,3 +5,5 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n log4j.category.org.springframework.bootstrap=DEBUG +#log4j.category.org.springframework.integration.dsl=DEBUG +#log4j.category.org.springframework.amqp=DEBUG diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/pom.xml b/spring-bootstrap-samples/spring-bootstrap-integration-sample/pom.xml index 98adc7973f..b77d23a207 100644 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/pom.xml +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/pom.xml @@ -25,7 +25,7 @@ org.springframework.integration - spring-integration-stream + spring-integration-file ${dependency.spring.integration.version} diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/HelloWorldService.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/HelloWorldService.java similarity index 85% rename from spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/HelloWorldService.java rename to spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/HelloWorldService.java index 6835eca0cc..d7d9fe186b 100644 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/HelloWorldService.java +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/HelloWorldService.java @@ -1,4 +1,4 @@ -package org.springframework.bootstrap.sample.service; +package org.springframework.bootstrap.sample.consumer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplication.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplication.java similarity index 93% rename from spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplication.java rename to spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplication.java index b5dbc1e7e6..dab26d6631 100644 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplication.java +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplication.java @@ -1,4 +1,4 @@ -package org.springframework.bootstrap.sample.service; +package org.springframework.bootstrap.sample.consumer; import org.springframework.bootstrap.SpringApplication; import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration; diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/SampleEndpoint.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/SampleEndpoint.java new file mode 100644 index 0000000000..78138a0c0c --- /dev/null +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/SampleEndpoint.java @@ -0,0 +1,25 @@ +package org.springframework.bootstrap.sample.consumer; + +import java.io.File; +import java.io.FileInputStream; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.integration.annotation.MessageEndpoint; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.util.StreamUtils; + +@MessageEndpoint +public class SampleEndpoint { + + @Autowired + private HelloWorldService helloWorldService; + + @ServiceActivator + public String hello(File input) throws Exception { + FileInputStream in = new FileInputStream(input); + String name = new String(StreamUtils.copyToByteArray(in)); + in.close(); + return this.helloWorldService.getHelloMessage(name); + } + +} diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/ServiceProperties.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/ServiceProperties.java similarity index 94% rename from spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/ServiceProperties.java rename to spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/ServiceProperties.java index 68ae4f5193..ba9ad43c12 100644 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/ServiceProperties.java +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/consumer/ServiceProperties.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.bootstrap.sample.service; +package org.springframework.bootstrap.sample.consumer; import org.springframework.bootstrap.context.annotation.ConfigurationProperties; diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/SampleEndpoint.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/SampleEndpoint.java deleted file mode 100644 index 3bec2bfd80..0000000000 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/java/org/springframework/bootstrap/sample/service/SampleEndpoint.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.springframework.bootstrap.sample.service; - -import java.util.Collections; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.ServiceActivator; - -@MessageEndpoint -public class SampleEndpoint { - - @Autowired - private HelloWorldService helloWorldService; - - @ServiceActivator - public Map hello(String input) { - return Collections.singletonMap("message", - this.helloWorldService.getHelloMessage(input)); - } - -} diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/integration-context.xml b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/integration-context.xml index 112c2efce4..6b8f92e816 100644 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/integration-context.xml +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/integration-context.xml @@ -2,10 +2,19 @@ - - + + + + + + + + + diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/logback.xml b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/logback.xml new file mode 100644 index 0000000000..6d14d3439a --- /dev/null +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/main/resources/logback.xml @@ -0,0 +1,29 @@ + + + + + + + ${LOG_PATTERN} + + + + + ${LOG_PATTERN} + + ${LOG_FILE} + + ${LOG_FILE}.%i + + + 10MB + + + + + + + + diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplicationTests.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplicationTests.java new file mode 100644 index 0000000000..5e0878dd8a --- /dev/null +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/consumer/IntegrationBootstrapApplicationTests.java @@ -0,0 +1,74 @@ +package org.springframework.bootstrap.sample.consumer; + +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.bootstrap.SpringApplication; +import org.springframework.bootstrap.sample.consumer.IntegrationBootstrapApplication; +import org.springframework.bootstrap.sample.producer.ProducerApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.ResourcePatternUtils; +import org.springframework.util.StreamUtils; + +import static org.junit.Assert.assertTrue; + +/** + * Basic integration tests for service demo application. + * + * @author Dave Syer + * + */ +public class IntegrationBootstrapApplicationTests { + + private static ConfigurableApplicationContext context; + + @BeforeClass + public static void start() throws Exception { + context = (ConfigurableApplicationContext) SpringApplication + .run(IntegrationBootstrapApplication.class); + } + + @AfterClass + public static void stop() { + if (context != null) { + context.close(); + } + } + + @Test + public void testVanillaExchange() throws Exception { + SpringApplication.run(ProducerApplication.class, "World"); + String output = getOutput(); + assertTrue("Wrong output: " + output, output.contains("Hello World")); + } + + private String getOutput() throws Exception { + Future future = Executors.newSingleThreadExecutor().submit( + new Callable() { + @Override + public String call() throws Exception { + Resource[] resources = new Resource[0]; + while (resources.length == 0) { + Thread.sleep(200); + resources = ResourcePatternUtils.getResourcePatternResolver( + new DefaultResourceLoader()).getResources( + "file:target/output/**"); + } + StringBuilder builder = new StringBuilder(); + for (Resource resource : resources) { + builder.append(new String(StreamUtils + .copyToByteArray(resource.getInputStream()))); + } + return builder.toString(); + } + }); + return future.get(10, TimeUnit.SECONDS); + } +} diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/producer/ProducerApplication.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/producer/ProducerApplication.java new file mode 100644 index 0000000000..c715340e18 --- /dev/null +++ b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/producer/ProducerApplication.java @@ -0,0 +1,28 @@ +package org.springframework.bootstrap.sample.producer; + +import java.io.File; +import java.io.FileOutputStream; + +import org.springframework.bootstrap.CommandLineRunner; +import org.springframework.bootstrap.SpringApplication; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ProducerApplication implements CommandLineRunner { + + @Override + public void run(String... args) throws Exception { + new File("target/input").mkdirs(); + FileOutputStream stream = new FileOutputStream("target/input/data"+System.currentTimeMillis()+".txt"); + for (String arg : args) { + stream.write(arg.getBytes()); + } + stream.flush(); + stream.close(); + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(ProducerApplication.class, args); + } + +} diff --git a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplicationTests.java b/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplicationTests.java deleted file mode 100644 index f266978257..0000000000 --- a/spring-bootstrap-samples/spring-bootstrap-integration-sample/src/test/java/org/springframework/bootstrap/sample/service/IntegrationBootstrapApplicationTests.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.springframework.bootstrap.sample.service; - -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.bootstrap.SpringApplication; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.integration.Message; -import org.springframework.integration.core.MessagingTemplate; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.support.channel.BeanFactoryChannelResolver; - -import static org.junit.Assert.assertEquals; - -/** - * Basic integration tests for service demo application. - * - * @author Dave Syer - * - */ -public class IntegrationBootstrapApplicationTests { - - private static ConfigurableApplicationContext context; - - @BeforeClass - public static void start() throws Exception { - Future future = Executors - .newSingleThreadExecutor().submit( - new Callable() { - @Override - public ConfigurableApplicationContext call() throws Exception { - return (ConfigurableApplicationContext) SpringApplication - .run(IntegrationBootstrapApplication.class); - } - }); - context = future.get(10, TimeUnit.SECONDS); - } - - @AfterClass - public static void stop() { - if (context != null) { - context.close(); - } - } - - @Test - public void testVanillaExchange() throws Exception { - MessagingTemplate template = new MessagingTemplate(); - template.setChannelResolver(new BeanFactoryChannelResolver(context)); - Message result = template.sendAndReceive("input", - MessageBuilder.withPayload("Phil").build()); - assertEquals("{message=Hello Phil}", result.getPayload().toString()); - } - -} diff --git a/spring-bootstrap-service/src/main/java/org/springframework/bootstrap/autoconfigure/service/SecurityAutoConfiguration.java b/spring-bootstrap-service/src/main/java/org/springframework/bootstrap/autoconfigure/service/SecurityAutoConfiguration.java index 23965af983..18d07bce1f 100644 --- a/spring-bootstrap-service/src/main/java/org/springframework/bootstrap/autoconfigure/service/SecurityAutoConfiguration.java +++ b/spring-bootstrap-service/src/main/java/org/springframework/bootstrap/autoconfigure/service/SecurityAutoConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.AuthenticationBuilder; import org.springframework.security.config.annotation.web.EnableWebSecurity; import org.springframework.security.config.annotation.web.ExpressionUrlAuthorizations; -import org.springframework.security.config.annotation.web.HttpConfiguration; +import org.springframework.security.config.annotation.web.HttpConfigurator; import org.springframework.security.config.annotation.web.SpringSecurityFilterChainBuilder.IgnoredRequestRegistry; import org.springframework.security.config.annotation.web.WebSecurityConfiguration; import org.springframework.security.config.annotation.web.WebSecurityConfigurerAdapter; @@ -64,7 +64,7 @@ public class SecurityAutoConfiguration { } @Override - protected void configure(HttpConfiguration http) throws Exception { + protected void configure(HttpConfigurator http) throws Exception { http.antMatcher("/**").httpBasic().and().anonymous().disable(); if (this.security.isRequireSsl()) { http.requiresChannel().antMatchers("/**").requiresSecure(); diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/CommandLineRunner.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/CommandLineRunner.java index 867a098504..ab23023384 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/CommandLineRunner.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/CommandLineRunner.java @@ -33,6 +33,6 @@ public interface CommandLineRunner { * Callback used to run the bean. * @param args incoming main method arguments */ - void run(String... args); + void run(String... args) throws Exception; } diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java index f6c7e96595..5c0f1ee147 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/SpringApplication.java @@ -423,7 +423,11 @@ public class SpringApplication { .getBeansOfType(CommandLineRunner.class).values()); AnnotationAwareOrderComparator.sort(runners); for (CommandLineRunner runner : runners) { - runner.run(args); + try { + runner.run(args); + } catch (Exception e) { + throw new IllegalStateException("Failed to execute CommandLineRunner", e); + } } }