This commit is contained in:
Phillip Webb
2013-05-31 12:26:30 -07:00
parent 969c7d6fa1
commit 7e3c158f3a
175 changed files with 1040 additions and 286 deletions

View File

@@ -38,12 +38,12 @@ abstract class Banner {
* @param printStream the output print stream
*/
public static void write(PrintStream printStream) {
System.out.println();
printStream.println();
for (String line : BANNER) {
printStream.println(line);
}
System.out.println();
System.out.println();
printStream.println();
printStream.println();
}
}

View File

@@ -13,14 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap;
/**
* @author Dave Syer
* Interface used to generate an 'exit code' from a running command line
* {@link SpringApplication}.
*
* @author Dave Syer
* @see SpringApplication#exit(org.springframework.context.ApplicationContext,
* ExitCodeGenerator...)
*/
public interface ExitCodeGenerator {
/**
* Returns the exit code that should be returned from the application.
* @return the exit code.
*/
int getExitCode();
}

View File

@@ -42,15 +42,15 @@ public class BatchAutoConfiguration {
}
@Bean
@ConditionalOnMissingBean({ CommandLineRunner.class })
@ConditionalOnBean({ JobLauncher.class })
@ConditionalOnMissingBean(CommandLineRunner.class)
@ConditionalOnBean(JobLauncher.class)
public JobLauncherCommandLineRunner jobLauncherCommandLineRunner() {
return new JobLauncherCommandLineRunner();
}
@Bean
@ConditionalOnMissingBean({ ExitCodeGenerator.class })
@ConditionalOnBean({ JobLauncher.class })
@ConditionalOnMissingBean(ExitCodeGenerator.class)
@ConditionalOnBean(JobLauncher.class)
public ExitCodeGenerator jobExecutionExitCodeGenerator() {
return new JobExecutionExitCodeGenerator();
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import javax.annotation.PostConstruct;
@@ -30,7 +31,6 @@ import org.springframework.stereotype.Component;
* Initialize the Spring Batch schema (ignoring errors, so should be idempotent).
*
* @author Dave Syer
*
*/
@Component
public class BatchDatabaseInitializer {
@@ -57,4 +57,4 @@ public class BatchDatabaseInitializer {
populator.setContinueOnError(true);
DatabasePopulatorUtils.execute(populator, this.dataSource);
}
}
}

View File

@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import org.springframework.batch.core.JobExecution;
import org.springframework.context.ApplicationEvent;
/**
* @author Dave Syer
* Spring {@link ApplicationEvent} encapsulating a {@link JobExecution}.
*
* @author Dave Syer
*/
public class JobExecutionEvent extends ApplicationEvent {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import java.util.ArrayList;
@@ -23,8 +24,9 @@ import org.springframework.bootstrap.ExitCodeGenerator;
import org.springframework.context.ApplicationListener;
/**
* @author Dave Syer
* {@link ExitCodeGenerator} for {@link JobExecutionEvent}s.
*
* @author Dave Syer
*/
public class JobExecutionExitCodeGenerator implements
ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import java.util.Arrays;
@@ -35,6 +36,11 @@ import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
/**
* {@link CommandLineRunner} to {@link JobLauncher launch} Spring Batch jobs.
*
* @author Dave Syer
*/
@Component
public class JobLauncherCommandLineRunner implements CommandLineRunner,
ApplicationEventPublisherAware {
@@ -72,4 +78,4 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
}
}
}
}
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import org.springframework.beans.factory.BeanCreationException;
@@ -24,7 +25,6 @@ import org.springframework.util.StringUtils;
* Base class for configuration of a database pool.
*
* @author Dave Syer
*
*/
public class AbstractDataSourceConfiguration {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import java.sql.SQLException;
@@ -32,17 +33,18 @@ import org.springframework.dao.DataAccessResourceFailureException;
* recommended in high volume environments (the Tomcat DataSource is more reliable).
*
* @author Dave Syer
*
*/
@Configuration
public class BasicDataSourceConfiguration extends AbstractDataSourceConfiguration {
private static Log logger = LogFactory.getLog(BasicDataSourceConfiguration.class);
private BasicDataSource pool;
@Bean
public DataSource dataSource() {
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, but the Tomcat DataSource is more reliable.");
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
+ "but the Tomcat DataSource is more reliable.");
this.pool = new BasicDataSource();
this.pool.setDriverClassName(getDriverClassName());
this.pool.setUrl(getUrl());

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import java.util.ArrayList;
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.bootstrap.context.annotation.ConditionLogUtils;
import org.springframework.bootstrap.context.annotation.ConditionalOnClass;
import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean;
import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition;
@@ -50,14 +52,17 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* @author Dave Syer
* {@link EnableAutoConfiguration Auto-configuration} for {@link DataSource}.
*
* @author Dave Syer
*/
@Configuration
@ConditionalOnClass(EmbeddedDatabaseType.class /* Spring JDBC */)
// @ConditionalOnMissingBean(DataSource.class)
public class DataSourceAutoConfiguration {
// FIXME see above
private static Log logger = LogFactory.getLog(DataSourceAutoConfiguration.class);
@Autowired(required = false)

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import javax.sql.DataSource;
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.bootstrap.context.annotation.ConditionalOnBean;
import org.springframework.bootstrap.context.annotation.ConditionalOnClass;
import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean;
import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
@@ -29,8 +31,10 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
/**
* @author Dave Syer
* {@link EnableAutoConfiguration Auto-configuration} for
* {@link DataSourceTransactionManager}.
*
* @author Dave Syer
*/
@Configuration
@ConditionalOnClass({ JdbcTemplate.class, PlatformTransactionManager.class })

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import javax.annotation.PreDestroy;
@@ -26,7 +27,6 @@ import org.springframework.context.annotation.Configuration;
* and tends not to deadlock in high volume environments.
*
* @author Dave Syer
*
*/
@Configuration
public class TomcatDataSourceConfiguration extends AbstractDataSourceConfiguration {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.orm.jpa;
import java.io.IOException;
@@ -46,12 +47,10 @@ import org.springframework.util.StringUtils;
/**
* Helper to detect a component scan declared in the enclosing context (normally on a
* <code>@Configuration</code> class). Once the component scan is detected, the base
* packages are stored for retrieval later by the {@link JpaRepositoriesAutoConfiguration}
* .
* {@code @Configuration} class). Once the component scan is detected, the base packages
* are stored for retrieval later by the {@link JpaRepositoriesAutoConfiguration} .
*
* @author Dave Syer
*
*/
class JpaComponentScanDetector implements ImportBeanDefinitionRegistrar, BeanFactoryAware {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.web;
import javax.servlet.Servlet;
@@ -36,7 +37,6 @@ import org.springframework.core.type.AnnotationMetadata;
*
* @author Phillip Webb
* @author Dave Syer
*
*/
public class EmbeddedContainerConfiguration implements ImportSelector {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.web;
import org.apache.catalina.valves.AccessLogValve;
@@ -31,8 +32,11 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
/**
* @author Dave Syer
* {@link EmbeddedServletContainerCustomizer} that configures the
* {@link ConfigurableEmbeddedServletContainerFactory} from a {@link ServerProperties}
* bean.
*
* @author Dave Syer
*/
@Configuration
@EnableConfigurationProperties

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.bind;
import java.beans.PropertyEditor;
@@ -21,8 +22,9 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* @author Dave Syer
* {@link PropertyEditor} for {@link InetAddress} objects.
*
* @author Dave Syer
*/
public class InetAddressEditor extends PropertyEditorSupport implements PropertyEditor {

View File

@@ -37,7 +37,7 @@ import org.springframework.beans.factory.FactoryBean;
* one: two
* three: four
*
* <pre>
* </pre>
*
* plus (later in the list)
*
@@ -47,7 +47,7 @@ import org.springframework.beans.factory.FactoryBean;
* one: 2
* five: six
*
* <pre>
* </pre>
*
* results in an effecive input of
*
@@ -58,13 +58,12 @@ import org.springframework.beans.factory.FactoryBean;
* three: four
* five: six
*
* <pre>
* </pre>
*
* Note that the value of "foo" in the first document is not simply replaced with the value in the second, but its nested values are merged.
* Note that the value of "foo" in the first document is not simply replaced with the
* value in the second, but its nested values are merged.
*
* @author Dave Syer
* @since 3.2
*
*/
public class YamlMapFactoryBean extends YamlProcessor implements
FactoryBean<Map<String, Object>> {

View File

@@ -35,7 +35,6 @@ import org.yaml.snakeyaml.Yaml;
* Base class for Yaml factories.
*
* @author Dave Syer
* @since 3.2
*/
public class YamlProcessor {

View File

@@ -65,8 +65,6 @@ import org.springframework.beans.factory.FactoryBean;
* </pre>
*
* @author Dave Syer
* @since 3.2
*
*/
public class YamlPropertiesFactoryBean extends YamlProcessor implements
FactoryBean<Properties> {

View File

@@ -38,7 +38,9 @@ import org.springframework.util.MultiValueMap;
abstract class AbstractOnBeanCondition implements Condition {
protected Log logger = LogFactory.getLog(getClass());
private List<String> beanClasses;
private List<String> beanNames;
protected abstract Class<?> annotationClass();
@@ -90,32 +92,26 @@ abstract class AbstractOnBeanCondition implements Condition {
boolean result = evaluate(beanClassesFound, beanNamesFound);
if (this.logger.isDebugEnabled()) {
if (!this.beanClasses.isEmpty()) {
this.logger.debug(checking + "Looking for beans with class: "
+ this.beanClasses);
if (beanClassesFound.isEmpty()) {
this.logger.debug(checking + "Found no beans");
} else {
this.logger.debug(checking + "Found beans with classes: "
+ beanClassesFound);
}
}
if (!this.beanNames.isEmpty()) {
this.logger.debug(checking + "Looking for beans with names: "
+ this.beanNames);
if (beanNamesFound.isEmpty()) {
this.logger.debug(checking + "Found no beans");
} else {
this.logger.debug(checking + "Found beans with names: "
+ beanNamesFound);
}
}
logFoundResults(checking, "class", this.beanClasses, beanClassesFound);
logFoundResults(checking, "name", this.beanNames, beanClassesFound);
this.logger.debug(checking + "Match result is: " + result);
}
return result;
}
private void logFoundResults(String prefix, String type, List<?> candidates,
List<?> found) {
if (!candidates.isEmpty()) {
this.logger.debug(prefix + "Looking for beans with " + type + ": "
+ candidates);
if (found.isEmpty()) {
this.logger.debug(prefix + "Found no beans");
} else {
this.logger.debug(prefix + "Found beans with " + type + ": " + found);
}
}
}
protected boolean evaluate(List<String> beanClassesFound, List<String> beanNamesFound) {
return !beanClassesFound.isEmpty() || !beanNamesFound.isEmpty();
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.apache.commons.logging.Log;
@@ -21,8 +22,9 @@ import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.MethodMetadata;
/**
* @author Dave Syer
* General utilities for constructing {@code @Conditional} log messages.
*
* @author Dave Syer
*/
public class ConditionLogUtils {

View File

@@ -23,15 +23,18 @@ import java.lang.annotation.Target;
import org.springframework.context.annotation.Conditional;
/**
* Configuration annotation for a conditional element that depends on teh value of a SpEL
* Configuration annotation for a conditional element that depends on the value of a SpEL
* expression.
*
* @author Dave Syer
*
*/
@Conditional(OnExpressionCondition.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface ConditionalOnExpression {
/**
* The SpEL expression.
*/
String value() default "true";
}
}

View File

@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for externalized configuration. Add this to a class definition if you want
* to bind and validate some external Properties (e.g. from a .properties file).

View File

@@ -35,4 +35,5 @@ public @interface EnableConfigurationProperties {
Class<?>[] value() default {};
// FIXME Javadoc
}

View File

@@ -30,7 +30,7 @@ import org.springframework.core.type.ClassMetadata;
* A Condition that evaluates a SpEL expression.
*
* @author Dave Syer
*
* @see ConditionalOnExpression
*/
public class OnExpressionCondition implements Condition {
@@ -72,4 +72,4 @@ public class OnExpressionCondition implements Condition {
return result;
}
}
}

View File

@@ -57,4 +57,5 @@ class OnWebApplicationCondition implements Condition {
return result;
}
// FIXME merge with OnNotWeb...
}

View File

@@ -27,6 +27,9 @@ import org.springframework.core.env.PropertySources;
import org.springframework.validation.Validator;
/**
* {@link BeanPostProcessor} to bind {@link PropertySources} to beans annotated with
* {@link ConfigurationProperties}.
*
* @author Dave Syer
*/
public class PropertySourcesBindingPostProcessor implements BeanPostProcessor {

View File

@@ -33,7 +33,6 @@ import org.springframework.util.Assert;
*
* @author Phillip Webb
* @author Dave Syer
* @since 4.0
*/
public abstract class AbstractEmbeddedServletContainerFactory implements
ConfigurableEmbeddedServletContainerFactory {

View File

@@ -31,7 +31,7 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
/**
* {@link EmbeddedWebApplicationContext} that accepts annotated classes as input - in
* particular {@link org.springframework.context.annotation.Configuration
* <code>@Configuration</code>} -annotated classes, but also plain
* <code>@Configuration</code>}-annotated classes, but also plain
* {@link org.springframework.stereotype.Component <code>@Component</code>} classes and
* JSR-330 compliant classes using {@code javax.inject} annotations. Allows for
* registering classes one by one (specifying class names as config location) as well as
@@ -43,7 +43,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
* to deliberately override certain bean definitions via an extra Configuration class.
*
* @author Phillip Webb
* @since 4.0
* @see #register(Class...)
* @see #scan(String...)
* @see EmbeddedWebApplicationContext

View File

@@ -25,11 +25,22 @@ package org.springframework.bootstrap.context.embedded;
* {@link EmbeddedServletContainerFactory}.
*
* @author Phillip Webb
* @since 4.0
* @author Dave Syer
* @see EmbeddedServletContainerFactory
*/
public interface EmbeddedServletContainer {
/**
* An empty {@link EmbeddedServletContainer} that does nothing.
*/
public static final EmbeddedServletContainer NONE = new EmbeddedServletContainer() {
@Override
public void stop() throws EmbeddedServletContainerException {
// Do nothing
}
};
/**
* Stops the embedded servlet container. Calling this method on an already stopped
* container has no effect.

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.embedded;
/**
@@ -24,10 +25,13 @@ package org.springframework.bootstrap.context.embedded;
* than injecting them with <code>@Autowired</code>.
*
* @author Dave Syer
*
*/
public interface EmbeddedServletContainerCustomizer {
/**
* Customize the specified {@link ConfigurableEmbeddedServletContainerFactory}.
* @param factory the factory to customize
*/
void customize(ConfigurableEmbeddedServletContainerFactory factory);
}

View File

@@ -25,7 +25,6 @@ import org.springframework.bootstrap.context.embedded.tomcat.TomcatEmbeddedServl
* {@link AbstractEmbeddedServletContainerFactory} when possible.
*
* @author Phillip Webb
* @since 4.0
* @see EmbeddedServletContainer
* @see AbstractEmbeddedServletContainerFactory
* @see JettyEmbeddedServletContainerFactory

View File

@@ -81,7 +81,6 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
* {@link XmlEmbeddedWebApplicationContext} variants.
*
* @author Phillip Webb
* @since 4.0
* @see AnnotationConfigEmbeddedWebApplicationContext
* @see XmlEmbeddedWebApplicationContext
* @see EmbeddedServletContainerFactory

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.embedded;
/**
* @author Dave Syer
*
*/
public class EmptyEmbeddedServletContainer implements EmbeddedServletContainer {
@Override
public void stop() throws EmbeddedServletContainerException {
// do nothing
}
}

View File

@@ -24,7 +24,6 @@ import org.springframework.util.ObjectUtils;
* the {@literal &lt;error-page&gt;} element traditionally found in web.xml.
*
* @author Dave Syer
* @since 4.0
*/
public class ErrorPage {

View File

@@ -44,7 +44,6 @@ import org.springframework.util.Assert;
* will be associated to '/*'. The filter name will be deduced if not specified.
*
* @author Phillip Webb
* @since 4.0
* @see ServletContextInitializer
* @see ServletContext#addFilter(String, Filter)
*/

View File

@@ -29,7 +29,6 @@ import org.springframework.util.Assert;
* {@link FilterRegistrationBean filter} registration beans.
*
* @author Phillip Webb
* @since 4.0
* @see ServletRegistrationBean
* @see FilterRegistrationBean
*/

View File

@@ -41,7 +41,6 @@ import org.springframework.util.Assert;
* omitted when mapping to '/*'. The servlet name will be deduced if not specified.
*
* @author Phillip Webb
* @since 4.0
* @see ServletContextInitializer
* @see ServletContext#addServlet(String, Servlet)
*/

View File

@@ -27,7 +27,6 @@ import org.springframework.util.Assert;
* {@link JettyEmbeddedServletContainerFactory} and not directly.
*
* @author Phillip Webb
* @since 4.0
* @see JettyEmbeddedServletContainerFactory
*/
public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {

View File

@@ -35,7 +35,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.springframework.bootstrap.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainer;
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.bootstrap.context.embedded.EmptyEmbeddedServletContainer;
import org.springframework.bootstrap.context.embedded.ErrorPage;
import org.springframework.bootstrap.context.embedded.ServletContextInitializer;
import org.springframework.context.ResourceLoaderAware;
@@ -50,12 +49,11 @@ import org.springframework.util.StringUtils;
* {@link ServletContextInitializer}s or Jetty {@link Configuration}s.
*
* <p>
* Unless explicitly configured otherwise this factory will created containers that listen
* for HTTP requests on port 8080.
* Unless explicitly configured otherwise this factory will created containers that
* listens for HTTP requests on port 8080.
*
* @author Phillip Webb
* @author Dave Syer
* @since 4.0
* @see #setPort(int)
* @see #setConfigurations(Collection)
* @see JettyEmbeddedServletContainer
@@ -99,7 +97,7 @@ public class JettyEmbeddedServletContainerFactory extends
public EmbeddedServletContainer getEmbdeddedServletContainer(
ServletContextInitializer... initializers) {
if (getPort() == 0) {
return new EmptyEmbeddedServletContainer();
return EmbeddedServletContainer.NONE;
}
Server server = new Server(new InetSocketAddress(getAddress(), getPort()));

View File

@@ -30,7 +30,6 @@ import org.springframework.util.Assert;
* Jetty {@link Configuration} that calls {@link ServletContextInitializer}s.
*
* @author Phillip Webb
* @since 4.0
*/
public class ServletContextInitializerConfiguration extends AbstractConfiguration {
@@ -61,8 +60,9 @@ public class ServletContextInitializerConfiguration extends AbstractConfiguratio
@Override
protected void doStart() throws Exception {
ServletContext servletContext = contextHandler.getServletContext();
for (ServletContextInitializer initializer : initializers) {
ServletContext servletContext = ServletContextInitializerConfiguration.this.contextHandler
.getServletContext();
for (ServletContextInitializer initializer : ServletContextInitializerConfiguration.this.initializers) {
initializer.onStartup(servletContext);
}
}

View File

@@ -29,7 +29,6 @@ import org.springframework.util.Assert;
* Tomcat {@link LifecycleListener} that calls {@link ServletContextInitializer}s.
*
* @author Phillip Webb
* @since 4.0
*/
public class ServletContextInitializerLifecycleListener implements LifecycleListener {

View File

@@ -28,7 +28,6 @@ import org.springframework.util.Assert;
* {@link TomcatEmbeddedServletContainerFactory} and not directly.
*
* @author Phillip Webb
* @since 4.0
* @see TomcatEmbeddedServletContainerFactory
*/
public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer {
@@ -53,7 +52,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
Thread awaitThread = new Thread() {
@Override
public void run() {
tomcat.getServer().await();
TomcatEmbeddedServletContainer.this.tomcat.getServer().await();
};
};
awaitThread.setDaemon(false);

View File

@@ -41,7 +41,6 @@ import org.springframework.bootstrap.context.embedded.AbstractEmbeddedServletCon
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainer;
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainerException;
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.bootstrap.context.embedded.EmptyEmbeddedServletContainer;
import org.springframework.bootstrap.context.embedded.ErrorPage;
import org.springframework.bootstrap.context.embedded.ServletContextInitializer;
import org.springframework.context.ResourceLoaderAware;
@@ -55,12 +54,11 @@ import org.springframework.util.ClassUtils;
* {@link ServletContextInitializer}s or Tomcat {@link LifecycleListener}s.
*
* <p>
* Unless explicitly configured otherwise this factory will created containers that listen
* for HTTP requests on port 8080.
* Unless explicitly configured otherwise this factory will created containers that
* listens for HTTP requests on port 8080.
*
* @author Phillip Webb
* @author Dave Syer
* @since 4.0
* @see #setPort(int)
* @see #setContextLifecycleListeners(Collection)
* @see TomcatEmbeddedServletContainer
@@ -110,7 +108,7 @@ public class TomcatEmbeddedServletContainerFactory extends
public EmbeddedServletContainer getEmbdeddedServletContainer(
ServletContextInitializer... initializers) {
if (getPort() == 0) {
return new EmptyEmbeddedServletContainer();
return EmbeddedServletContainer.NONE;
}
File baseDir = (this.baseDirectory != null ? this.baseDirectory
: createTempDir("tomcat"));
@@ -345,7 +343,7 @@ public class TomcatEmbeddedServletContainerFactory extends
ServletContextInitializer... initializers) {
if (getPort() == 0) {
return new EmptyEmbeddedServletContainer();
return EmbeddedServletContainer.NONE;
}
StandardService service = new StandardService();
service.setName(name);

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.initializer;
import java.io.IOException;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.initializer;
import java.util.ArrayList;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.io.FileNotFoundException;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.io.FileNotFoundException;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.main;
import java.util.ArrayList;
@@ -34,7 +35,6 @@ import org.springframework.util.ClassUtils;
* the {@link SpringApplication} run methods are often more convenient).
*
* @author Dave Syer
*
*/
@Configuration
@EnableAutoConfiguration

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap;
import org.junit.Ignore;
@@ -24,8 +25,8 @@ import org.springframework.bootstrap.main.SimpleMainTests;
/**
* A test suite for probing weird ordering problems in the tests.
* @author Dave Syer
*
* @author Dave Syer
*/
@RunWith(Suite.class)
@SuiteClasses({ SimpleMainTests.class, JettyEmbeddedServletContainerFactoryTests.class })

View File

@@ -104,7 +104,6 @@ public class BeanDefinitionLoaderTests {
int loaded = loader.load();
assertThat(loaded, equalTo(1));
assertTrue(this.registry.containsBean("myComponent"));
}
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap;
import java.util.HashMap;
@@ -23,7 +24,6 @@ import org.springframework.core.env.MapPropertySource;
/**
* @author Dave Syer
*
*/
public class TestUtils {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure;
import java.util.HashMap;
@@ -27,7 +28,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class MessageSourceAutoConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import java.util.Collection;
@@ -39,7 +40,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class BatchAutoConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.batch;
import org.junit.Test;
@@ -23,7 +24,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class JobExecutionExitCodeGeneratorTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.data;
import javax.persistence.EntityManagerFactory;
@@ -32,7 +33,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class JpaRepositoriesAutoConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.data;
import org.junit.Ignore;
@@ -32,7 +33,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
@Ignore
// until spring data commons 1.6.0, jpa 1.5.0 available

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.data.test;
import java.io.Serializable;

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.data.test;
import org.springframework.data.domain.Page;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import javax.sql.DataSource;
@@ -24,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class BasicDataSourceConfigurationTests {
@@ -35,7 +35,7 @@ public class BasicDataSourceConfigurationTests {
this.context.register(BasicDataSourceConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(DataSource.class));
context.close();
this.context.close();
}
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import java.util.HashMap;
@@ -35,7 +36,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class DataSourceAutoConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import javax.sql.DataSource;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class DataSourceTransactionManagerAutoConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import javax.sql.DataSource;
@@ -24,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class EmbeddedDatabaseConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.jdbc;
import java.lang.reflect.Field;
@@ -32,12 +33,13 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class TomcatDataSourceConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
private Map<Object, Object> old;
private Map<Object, Object> map;
@After

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.orm.jpa;
import javax.sql.DataSource;
@@ -31,7 +32,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class HibernateJpaAutoConfigurationTests {

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.orm.jpa.test;
import java.io.Serializable;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.autoconfigure.web;
import java.io.File;
@@ -36,7 +37,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class ServerPropertiesConfigurationTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.bind;
import java.util.Collections;
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class PropertySourcesPropertyValuesTests {

View File

@@ -1,14 +1,17 @@
/*
* Cloud Foundry 2012.02.03 Beta
* Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
* Copyright 2012-2013 the original author or authors.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* 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
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.bind;

View File

@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.bind;
import static org.junit.Assert.assertEquals;
package org.springframework.bootstrap.bind;
import java.util.Collections;
import java.util.HashMap;
@@ -31,9 +30,10 @@ import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.SpringValidatorAdapter;
import org.yaml.snakeyaml.error.YAMLException;
import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class YamlConfigurationFactoryTests {
@@ -44,14 +44,14 @@ public class YamlConfigurationFactoryTests {
private Map<Class<?>, Map<String, String>> aliases = new HashMap<Class<?>, Map<String, String>>();
private Foo createFoo(final String yaml) throws Exception {
factory = new YamlConfigurationFactory<Foo>(Foo.class);
factory.setYaml(yaml);
factory.setExceptionIfInvalid(true);
factory.setPropertyAliases(aliases);
factory.setValidator(validator);
factory.setMessageSource(new StaticMessageSource());
factory.afterPropertiesSet();
return factory.getObject();
this.factory = new YamlConfigurationFactory<Foo>(Foo.class);
this.factory.setYaml(yaml);
this.factory.setExceptionIfInvalid(true);
this.factory.setPropertyAliases(this.aliases);
this.factory.setValidator(this.validator);
this.factory.setMessageSource(new StaticMessageSource());
this.factory.afterPropertiesSet();
return this.factory.getObject();
}
@Test
@@ -62,7 +62,7 @@ public class YamlConfigurationFactoryTests {
@Test
public void testValidYamlWithAliases() throws Exception {
aliases.put(Foo.class, Collections.singletonMap("foo-name", "name"));
this.aliases.put(Foo.class, Collections.singletonMap("foo-name", "name"));
Foo foo = createFoo("foo-name: blah\nbar: blah");
assertEquals("blah", foo.name);
}
@@ -74,8 +74,8 @@ public class YamlConfigurationFactoryTests {
@Test(expected = BindException.class)
public void missingPropertyCausesValidationError() throws Exception {
validator = new SpringValidatorAdapter(Validation.buildDefaultValidatorFactory()
.getValidator());
this.validator = new SpringValidatorAdapter(Validation
.buildDefaultValidatorFactory().getValidator());
createFoo("bar: blah");
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.config;
import java.io.IOException;
@@ -30,7 +31,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class YamlMapFactoryBeanTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.config;
import java.util.Arrays;
@@ -33,7 +34,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class YamlPropertiesFactoryBeanTests {

View File

@@ -34,7 +34,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class EnableConfigurationPropertiesTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class NotWebApplicationConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Ignore;
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
@Ignore
public class OnBeanConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class OnClassConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class OnExpressionConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class OnMissingBeanConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class OnMissingClassConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -26,7 +27,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class OnResourceConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.annotation;
import org.junit.Test;
@@ -27,7 +28,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class WebApplicationConditionTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.initializer;
import java.util.HashMap;
@@ -21,7 +22,6 @@ import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.bootstrap.context.initializer.EnvironmentDelegateApplicationContextInitializer;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.context.test;
import java.util.Properties;
@@ -33,7 +34,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
*
*/
public class EnableConfigurationPropertiesTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.io.ByteArrayOutputStream;
@@ -29,7 +30,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class JavaLoggerConfigurerTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.io.ByteArrayOutputStream;
@@ -29,7 +30,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class LogbackConfigurerTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.io.ByteArrayOutputStream;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.logging;
import java.util.logging.Formatter;
@@ -20,7 +21,6 @@ import java.util.logging.LogRecord;
/**
* @author Dave Syer
*
*/
public class TestFormatter extends Formatter {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.main;
import org.junit.After;
@@ -25,7 +26,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
*/
public class SimpleMainTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.maven;
import java.io.ByteArrayOutputStream;
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
*
*/
public class PropertiesMergingResourceTransformerTests {

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.properties;
import java.net.InetAddress;