Closes gh-11193
This commit is contained in:
Johnny Lim 2017-11-29 08:21:59 +09:00 committed by Stephane Nicoll
parent 33bd7ccc91
commit 952224ef56
9 changed files with 36 additions and 37 deletions

View File

@ -41,7 +41,6 @@ import org.springframework.context.annotation.Configuration;
*
* @author Andy Wilkinson
* @author Phillip Webb
* @since 2.0.0
*/
@Configuration
@ConditionalOnWebApplication(type = Type.SERVLET)

View File

@ -86,7 +86,7 @@ public class MetricsAutoConfigurationTests {
.run((context) -> {
context.getBean(DataSource.class).getConnection().getMetaData();
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("custom.name.max.connections")
assertThat(registry.find("data.source.max.connections")
.tags("name", "dataSource").meter()).isNotPresent();
});
}

View File

@ -153,7 +153,7 @@ public class SessionAutoConfiguration {
* Base class for beans used to validate that only one supported implementation is
* available in the classpath when the store-type property is not set.
*/
static class AbstractSessionRepositoryImplementationValidator {
static abstract class AbstractSessionRepositoryImplementationValidator {
private final List<String> candidates;
@ -233,7 +233,7 @@ public class SessionAutoConfiguration {
/**
* Base class for validating that a (reactive) session repository bean exists.
*/
static class AbstractSessionRepositoryValidator {
static abstract class AbstractSessionRepositoryValidator {
private final SessionProperties sessionProperties;
@ -276,7 +276,7 @@ public class SessionAutoConfiguration {
}
/**
* Bean used to validate that a {@link SessionRepository} exists and provide a
* Bean used to validate that a {@link ReactiveSessionRepository} exists and provide a
* meaningful message if that's not the case.
*/
static class ReactiveSessionRepositoryValidator

View File

@ -350,14 +350,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
server.start();
try {
assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector()
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
.getProtocolHandler()).getAcceptCount()).isEqualTo(10);
}
finally {
embeddedFactory.stop();
server.stop();
}
}
@ -368,14 +368,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
server.start();
try {
assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector()
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
}
finally {
embeddedFactory.stop();
server.stop();
}
}
@ -386,14 +386,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
server.start();
try {
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize())
assertThat(server.getTomcat().getConnector().getMaxPostSize())
.isEqualTo(10000);
}
finally {
embeddedFactory.stop();
server.stop();
}
}
@ -404,14 +404,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
server.start();
try {
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize())
assertThat(server.getTomcat().getConnector().getMaxPostSize())
.isEqualTo(-1);
}
finally {
embeddedFactory.stop();
server.stop();
}
}
@ -611,15 +611,15 @@ public class DefaultServletWebServerFactoryCustomizerTests {
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
server.start();
try {
Tomcat tomcat = embeddedFactory.getTomcat();
Tomcat tomcat = server.getTomcat();
Context context = (Context) tomcat.getHost().findChildren()[0];
assertThat(context.getResources().getCacheTtl()).isEqualTo(10000L);
}
finally {
embeddedFactory.stop();
server.stop();
}
}

View File

@ -1015,7 +1015,7 @@ following information:
[[production-ready-metrics-jdbc]]
=== DataSource metrics
Auto-configuration will enable the instrumentation of all available `DataSources` with a
Auto-configuration will enable the instrumentation of all available ``DataSource``s with a
metric named `data.source`. Data source instrumentation results in gauges representing
the currently active, maximum allowed, and minimum allowed connections in the pool. Each
of these gauges has a name which is prefixed by `data.source` by default. The prefix can

View File

@ -38,7 +38,7 @@ import org.springframework.util.StringUtils;
/**
* {@link ConfigurableReactiveWebApplicationContext} that accepts annotated classes as
* input - in particular
* {@link org.springframework.context.annotation.Configuration @Configuration} -annotated
* {@link org.springframework.context.annotation.Configuration @Configuration}-annotated
* classes, but also plain {@link Component @Component} 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 for classpath scanning
@ -311,7 +311,6 @@ public class AnnotationConfigReactiveWebApplicationContext
* with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
* @param beanFactory the bean factory to load bean definitions into
* @return the class path bean definition scanner
* @since 4.1.9
* @see #getEnvironment()
* @see #getBeanNameGenerator()
* @see #getScopeMetadataResolver()

View File

@ -28,11 +28,12 @@ import org.springframework.context.annotation.ScopeMetadataResolver;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* {@link ReactiveWebServerApplicationContext} that accepts annotated classes as input -
* in particular
* {@link org.springframework.context.annotation.Configuration @Configuration} -annotated
* {@link org.springframework.context.annotation.Configuration @Configuration}-annotated
* classes, but also plain {@link Component @Component} 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 for classpath scanning
@ -124,8 +125,8 @@ public class AnnotationConfigReactiveWebServerApplicationContext
/**
* Provide a custom {@link BeanNameGenerator} for use with
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner}
* , if any.
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner},
* if any.
* <p>
* Default is
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
@ -197,10 +198,10 @@ public class AnnotationConfigReactiveWebServerApplicationContext
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
super.postProcessBeanFactory(beanFactory);
if (this.basePackages != null && this.basePackages.length > 0) {
if (!ObjectUtils.isEmpty(this.basePackages)) {
this.scanner.scan(this.basePackages);
}
if (this.annotatedClasses != null && this.annotatedClasses.length > 0) {
if (!ObjectUtils.isEmpty(this.annotatedClasses)) {
this.reader.register(this.annotatedClasses);
}
}

View File

@ -122,8 +122,8 @@ public class AnnotationConfigServletWebServerApplicationContext
/**
* Provide a custom {@link BeanNameGenerator} for use with
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner}
* , if any.
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner},
* if any.
* <p>
* Default is
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.

View File

@ -101,12 +101,12 @@ public class ConfigurationPropertiesBinderBuilderTests {
@Test
public void detectDefaultValidator() {
this.applicationContext.registerSingleton("configurationPropertiesValidator",
this.applicationContext.registerSingleton(ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME,
LocalValidatorFactoryBean.class);
ConfigurationPropertiesBinder binder = this.builder
.withEnvironment(this.environment).build();
assertThat(ReflectionTestUtils.getField(binder, "validator")).isSameAs(
this.applicationContext.getBean("configurationPropertiesValidator"));
this.applicationContext.getBean(ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME));
}
@Test