From cf23b519d296a588610681e6a4be8eb042039107 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 24 Feb 2014 13:43:54 -0800 Subject: [PATCH] Polish --- docs/howto.md | 6 +-- .../EndpointAutoConfiguration.java | 2 +- .../endpoint/RequestMappingEndpoint.java | 20 +++++---- .../mvc/ShutdownMvcEndpointTests.java | 4 +- .../batch/BatchAutoConfiguration.java | 10 ++--- .../batch/JobLauncherCommandLineRunner.java | 2 +- .../jdbc/DataSourceAutoConfiguration.java | 21 +++++----- .../thymeleaf/ThymeleafAutoConfiguration.java | 14 +++---- .../DispatcherServletAutoConfiguration.java | 2 +- .../autoconfigure/web/ServerProperties.java | 2 +- .../JobLauncherCommandLineRunnerTests.java | 4 +- .../ThymeleafAutoConfigurationTests.java | 2 +- ...spatcherServletAutoConfigurationTests.java | 4 +- ...ervletContainerAutoConfigurationTests.java | 2 +- .../web/MultipartAutoConfigurationTests.java | 2 +- ...igurationSampleTomcatApplicationTests.java | 3 +- .../boot/SpringApplication.java | 42 +++++++++---------- .../boot/SpringApplicationRunListener.java | 8 ++-- .../bind/PropertiesConfigurationFactory.java | 6 +-- .../boot/logging/AbstractLoggingSystem.java | 2 +- .../boot/logging/logback/base.xml | 2 +- .../boot/logging/logback/basic-logback.xml | 2 +- .../boot/logging/logback/logback.xml | 8 ++-- .../springframework/boot/AdhocTestSuite.java | 2 +- .../LoggingApplicationListenerTests.java | 12 +++--- 25 files changed, 97 insertions(+), 87 deletions(-) diff --git a/docs/howto.md b/docs/howto.md index 211bbde1ad4..374d586d529 100644 --- a/docs/howto.md +++ b/docs/howto.md @@ -866,7 +866,7 @@ database is in a server. JPA has features for DDL generation, and these can be set up to run on startup against the database. This is controlled through two -external properties: +external properties: * `spring.jpa.generate-ddl` (boolean) switches the feature on and off and is vendor independent @@ -902,7 +902,7 @@ enables it by default and loads SQL from the standard locations addition Spring Boot will load a file `schema-${platform}.sql` where `platform` is the vendor name of the database (`hsqldb`, `h2, `oracle`, `mysql`, `postgresql` etc.). Spring Boot enables the -failfast feature of the Spring JDBC initializer by default, so if +failfast feature of the Spring JDBC initializer by default, so if the scripts cause exceptions the application will fail. To disable the failfast you can set @@ -945,7 +945,7 @@ startup (see [JobLauncherCommandLineRunner](https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java) for details). You can narrow down to a specific job or jobs by specifying `spring.batch.job.names` (comma separated job name -patterns). +patterns). If the application context includes a `JobRegistry` then the jobs in `spring.batch.job.names` are looked up in the regsitry diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java index 2f07cdc7aa9..cb56202b5d9 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java index 188a3963559..333a57eb0e3 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -31,6 +31,8 @@ import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping; import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping; /** + * {@link Endpoint} to expose Spring MVC mappings. + * * @author Dave Syer */ public class RequestMappingEndpoint extends AbstractEndpoint> @@ -118,10 +120,10 @@ public class RequestMappingEndpoint extends AbstractEndpoint Map result) { for (AbstractUrlHandlerMapping mapping : handlerMappings) { Map handlers = mapping.getHandlerMap(); - for (String key : handlers.keySet()) { - Object handler = handlers.get(key); - result.put(key, - Collections.singletonMap("type", handler.getClass().getName())); + for (Map.Entry entry : handlers.entrySet()) { + Class handlerClass = entry.getValue().getClass(); + result.put(entry.getKey(), + Collections.singletonMap("type", handlerClass.getName())); } } } @@ -131,9 +133,11 @@ public class RequestMappingEndpoint extends AbstractEndpoint Map result) { for (AbstractHandlerMethodMapping mapping : methodMappings) { Map methods = mapping.getHandlerMethods(); - for (Object key : methods.keySet()) { - result.put(key.toString(), - Collections.singletonMap("method", methods.get(key).toString())); + for (Map.Entry entry : methods.entrySet()) { + result.put( + String.valueOf(entry.getKey()), + Collections.singletonMap("method", + String.valueOf(entry.getValue()))); } } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java index 8eb4aba91a0..7648591303f 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -29,6 +29,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** + * Tests for {@link ShutdownMvcEndpoint}. + * * @author Dave Syer */ public class ShutdownMvcEndpointTests { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index 2844fe4b0a6..63c8f3d8f9e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -46,12 +46,12 @@ import org.springframework.util.StringUtils; /** * {@link EnableAutoConfiguration Auto-configuration} for Spring Batch. By default a * Runner will be created and all jobs in the context will be executed on startup. - * - * Disable this behaviour with spring.batch.job.enabled=false). - * + *

+ * Disable this behavior with {@literal spring.batch.job.enabled=false}). + *

* Alternatively, discrete Job names to execute on startup can be supplied by the User - * with a comma-delimited list: spring.batch.job.names=job1,job2. In this - * case the Runner will first find jobs registered as Beans, then those in the existing + * with a comma-delimited list: {@literal spring.batch.job.names=job1,job2}. In this case + * the Runner will first find jobs registered as Beans, then those in the existing * JobRegistry. * * @author Dave Syer diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java index c25d41c2d58..06818f50a8f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index 88e8129bd44..30c9f609e48 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java @@ -64,7 +64,7 @@ import org.springframework.util.StringUtils; * @author Phillip Webb */ @Configuration -@ConditionalOnClass(EmbeddedDatabaseType.class /* Spring JDBC */) +@ConditionalOnClass(EmbeddedDatabaseType.class) public class DataSourceAutoConfiguration implements EnvironmentAware { private static Log logger = LogFactory.getLog(DataSourceAutoConfiguration.class); @@ -77,26 +77,27 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { @Autowired private ApplicationContext applicationContext; - private RelaxedPropertyResolver environment; + private RelaxedPropertyResolver datasourceProperties; @Override public void setEnvironment(Environment environment) { - this.environment = new RelaxedPropertyResolver(environment, CONFIGURATION_PREFIX - + "."); + this.datasourceProperties = new RelaxedPropertyResolver(environment, + CONFIGURATION_PREFIX + "."); } @PostConstruct protected void initialize() throws Exception { - if (this.dataSource == null - || !this.environment.getProperty("initialize", Boolean.class, true)) { + boolean initialize = this.datasourceProperties.getProperty("initialize", + Boolean.class, true); + if (this.dataSource == null || !initialize) { logger.debug("No DataSource found so not initializing"); return; } - String schema = this.environment.getProperty("schema"); + String schema = this.datasourceProperties.getProperty("schema"); if (schema == null) { schema = "classpath*:schema-" - + this.environment.getProperty("platform", "all") + + this.datasourceProperties.getProperty("platform", "all") + ".sql,classpath*:schema.sql,classpath*:data.sql"; } @@ -106,8 +107,8 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { .getResources(schemaLocation))); } - boolean continueOnError = this.environment.getProperty("continueOnError", - Boolean.class, false); + boolean continueOnError = this.datasourceProperties.getProperty( + "continueOnError", Boolean.class, false); boolean exists = false; ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); for (Resource resource : resources) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index d7a0fc5c4fe..bc5dbd49755 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -39,6 +39,7 @@ import org.springframework.core.env.Environment; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; +import org.springframework.util.Assert; import org.thymeleaf.dialect.IDialect; import org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect; import org.thymeleaf.spring4.SpringTemplateEngine; @@ -78,14 +79,13 @@ public class ThymeleafAutoConfiguration { @PostConstruct public void checkTemplateLocationExists() { - if (this.environment - .getProperty("checkTemplateLocation", Boolean.class, true)) { + Boolean checkTemplateLocation = this.environment.getProperty( + "checkTemplateLocation", Boolean.class, true); + if (checkTemplateLocation) { Resource resource = this.resourceLoader.getResource(this.environment .getProperty("prefix", DEFAULT_PREFIX)); - if (!resource.exists()) { - throw new IllegalStateException("Cannot find template location: " - + resource + " (are you really using Thymeleaf?)"); - } + Assert.state(resource.exists(), "Cannot find template location: " + + resource + " (are you really using Thymeleaf?)"); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration.java index 8aedea7f04e..d0b5d5d9ce6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 7d6be5c8742..d76c459cb08 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java index bbc7fd195d7..b78602a87fe 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -47,6 +47,8 @@ import org.springframework.transaction.PlatformTransactionManager; import static org.junit.Assert.assertEquals; /** + * Tests for {@link JobLauncherCommandLineRunner}. + * * @author Dave Syer */ public class JobLauncherCommandLineRunnerTests { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java index 373635f999d..070585275b0 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java index acc4486af6d..baf1a47c6f6 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -27,6 +27,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /** + * Tests for {@link DispatcherServletAutoConfiguration}. + * * @author Dave Syer */ public class DispatcherServletAutoConfigurationTests { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfigurationTests.java index dc42423a71a..95235db16a7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java index 92bdef57f56..27b904971da 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java b/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java index 01ae786470b..0074ce60337 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -44,6 +44,7 @@ import org.springframework.web.client.RestTemplate; import sample.tomcat.service.HelloWorldService; import sample.tomcat.web.SampleController; + import static org.junit.Assert.assertEquals; /** diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 0eae74c6028..74903458bd9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -261,9 +261,9 @@ public class SpringApplication { System.setProperty("java.awt.headless", Boolean.toString(this.headless)); - Collection participants = createRunParticipants(args); - for (SpringApplicationRunListener participant : participants) { - participant.started(); + Collection runListeners = getRunListeners(args); + for (SpringApplicationRunListener runListener : runListeners) { + runListener.started(); } try { @@ -271,8 +271,8 @@ public class SpringApplication { ConfigurableEnvironment environment = getOrCreateEnvironment(); addPropertySources(environment, args); setupProfiles(environment); - for (SpringApplicationRunListener participant : participants) { - participant.environmentPrepared(environment); + for (SpringApplicationRunListener runListener : runListeners) { + runListener.environmentPrepared(environment); } if (this.showBanner) { @@ -287,8 +287,8 @@ public class SpringApplication { context.setEnvironment(environment); postProcessApplicationContext(context); applyInitializers(context); - for (SpringApplicationRunListener participant : participants) { - participant.contextPrepared(context); + for (SpringApplicationRunListener runListener : runListeners) { + runListener.contextPrepared(context); } if (this.logStartupInfo) { logStartupInfo(context.getParent() == null); @@ -298,15 +298,15 @@ public class SpringApplication { Set sources = getSources(); Assert.notEmpty(sources, "Sources must not be empty"); load(context, sources.toArray(new Object[sources.size()])); - for (SpringApplicationRunListener participant : participants) { - participant.contextLoaded(context); + for (SpringApplicationRunListener runListener : runListeners) { + runListener.contextLoaded(context); } // Refresh the context refresh(context); afterRefresh(context, args); - for (SpringApplicationRunListener participant : participants) { - participant.finished(context, null); + for (SpringApplicationRunListener runListener : runListeners) { + runListener.finished(context, null); } stopWatch.stop(); @@ -317,8 +317,8 @@ public class SpringApplication { return context; } catch (Exception ex) { - for (SpringApplicationRunListener participant : participants) { - finishWithException(participant, context, ex); + for (SpringApplicationRunListener runListener : runListeners) { + finishWithException(runListener, context, ex); } if (context != null) { context.close(); @@ -330,13 +330,11 @@ public class SpringApplication { } } - private Collection createRunParticipants( - String[] args) { - List participants = new ArrayList(); - participants.addAll(getSpringFactoriesInstances( - SpringApplicationRunListener.class, new Class[] { - SpringApplication.class, String[].class }, this, args)); - return participants; + private Collection getRunListeners(String[] args) { + List listeners = new ArrayList(); + listeners.addAll(getSpringFactoriesInstances(SpringApplicationRunListener.class, + new Class[] { SpringApplication.class, String[].class }, this, args)); + return listeners; } private Collection getSpringFactoriesInstances(Class type) { @@ -625,10 +623,10 @@ public class SpringApplication { runCommandLineRunners(context, args); } - private void finishWithException(SpringApplicationRunListener participant, + private void finishWithException(SpringApplicationRunListener runListener, ConfigurableApplicationContext context, Exception exception) { try { - participant.finished(context, exception); + runListener.finished(context, exception); } catch (Exception ex) { if (this.log.isDebugEnabled()) { diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index a08eb6a7e74..b73b07c8c56 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java @@ -22,10 +22,10 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.io.support.SpringFactoriesLoader; /** - * Strategy class to allow dynamic participation when the {@link SpringApplication} - * {@code run} method is called. Participants are loaded via the - * {@link SpringFactoriesLoader} and should declare a public constructor that accepts a - * {@link SpringApplication} instance and a {@code String[]} of arguments. A new + * Listener for the {@link SpringApplication} {@code run} method. + * {@link SpringApplicationRunListener}s are loaded via the {@link SpringFactoriesLoader} + * and should declare a public constructor that accepts a {@link SpringApplication} + * instance and a {@code String[]} of arguments. A new * {@link SpringApplicationRunListener} instance will be created for each run. * * @author Phillip Webb diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java index 69bd62b8336..682b257867a 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -253,12 +253,12 @@ public class PropertiesConfigurationFactory implements FactoryBean, if (this.target != null) { PropertyDescriptor[] descriptors = BeanUtils .getPropertyDescriptors(this.target.getClass()); - String prefix = this.targetName != null ? this.targetName + "." : ""; + String prefix = (this.targetName != null ? this.targetName + "." : ""); String[] suffixes = new String[] { ".*", "_*" }; for (PropertyDescriptor descriptor : descriptors) { String name = descriptor.getName(); if (!name.equals("class")) { - for(String relaxedName : new RelaxedNames(prefix + name)) { + for (String relaxedName : new RelaxedNames(prefix + name)) { names.add(relaxedName); patterns.add(relaxedName); for (String suffix : suffixes) { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index ef3270b9894..4104cbc8c31 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml index 0a9d78e9c1c..a0375a21f2d 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml @@ -1,7 +1,7 @@ - + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-logback.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-logback.xml index 0ce671c213e..5be82ccb4cd 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-logback.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-logback.xml @@ -28,4 +28,4 @@ - \ No newline at end of file + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml index 173cd7038dd..3eb676013ff 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml @@ -2,17 +2,17 @@ - + diff --git a/spring-boot/src/test/java/org/springframework/boot/AdhocTestSuite.java b/spring-boot/src/test/java/org/springframework/boot/AdhocTestSuite.java index 31004c3ce6f..4889794ba20 100644 --- a/spring-boot/src/test/java/org/springframework/boot/AdhocTestSuite.java +++ b/spring-boot/src/test/java/org/springframework/boot/AdhocTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java index 43f1babb820..db0cb428664 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java @@ -86,7 +86,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testBaseConfigLocation() { + public void baseConfigLocation() { this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); this.logger.info("Hello world"); @@ -97,7 +97,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testOverrideConfigLocation() { + public void overrideConfigLocation() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml"); this.initializer.initialize(this.context.getEnvironment(), @@ -110,7 +110,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testOverrideConfigDoesNotExist() throws Exception { + public void overrideConfigDoesNotExist() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: doesnotexist.xml"); this.initializer.initialize(this.context.getEnvironment(), @@ -119,7 +119,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testAddLogFileProperty() { + public void addLogFileProperty() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.file: target/foo.log"); @@ -132,7 +132,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testAddLogFilePropertyWithDefault() { + public void addLogFilePropertyWithDefault() { assertFalse(new File("target/foo.log").exists()); EnvironmentTestUtils.addEnvironment(this.context, "logging.file: target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), @@ -143,7 +143,7 @@ public class LoggingApplicationListenerTests { } @Test - public void testAddLogPathProperty() { + public void addLogPathProperty() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.path: target/foo/");