parent
33bd7ccc91
commit
952224ef56
|
|
@ -41,7 +41,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class MetricsAutoConfigurationTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
context.getBean(DataSource.class).getConnection().getMetaData();
|
context.getBean(DataSource.class).getConnection().getMetaData();
|
||||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
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();
|
.tags("name", "dataSource").meter()).isNotPresent();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ public class SessionAutoConfiguration {
|
||||||
* Base class for beans used to validate that only one supported implementation is
|
* 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.
|
* available in the classpath when the store-type property is not set.
|
||||||
*/
|
*/
|
||||||
static class AbstractSessionRepositoryImplementationValidator {
|
static abstract class AbstractSessionRepositoryImplementationValidator {
|
||||||
|
|
||||||
private final List<String> candidates;
|
private final List<String> candidates;
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ public class SessionAutoConfiguration {
|
||||||
/**
|
/**
|
||||||
* Base class for validating that a (reactive) session repository bean exists.
|
* Base class for validating that a (reactive) session repository bean exists.
|
||||||
*/
|
*/
|
||||||
static class AbstractSessionRepositoryValidator {
|
static abstract class AbstractSessionRepositoryValidator {
|
||||||
|
|
||||||
private final SessionProperties sessionProperties;
|
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.
|
* meaningful message if that's not the case.
|
||||||
*/
|
*/
|
||||||
static class ReactiveSessionRepositoryValidator
|
static class ReactiveSessionRepositoryValidator
|
||||||
|
|
|
||||||
|
|
@ -350,14 +350,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
|
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
|
||||||
embeddedFactory.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector()
|
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
|
||||||
.getProtocolHandler()).getAcceptCount()).isEqualTo(10);
|
.getProtocolHandler()).getAcceptCount()).isEqualTo(10);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedFactory.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,14 +368,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
|
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
|
||||||
embeddedFactory.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector()
|
assertThat(((AbstractProtocol<?>) server.getTomcat().getConnector()
|
||||||
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedFactory.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,14 +386,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
|
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
|
||||||
embeddedFactory.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize())
|
assertThat(server.getTomcat().getConnector().getMaxPostSize())
|
||||||
.isEqualTo(10000);
|
.isEqualTo(10000);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedFactory.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,14 +404,14 @@ public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
|
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
|
||||||
embeddedFactory.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize())
|
assertThat(server.getTomcat().getConnector().getMaxPostSize())
|
||||||
.isEqualTo(-1);
|
.isEqualTo(-1);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedFactory.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -611,15 +611,15 @@ public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
|
TomcatWebServer server = (TomcatWebServer) factory.getWebServer();
|
||||||
embeddedFactory.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
Tomcat tomcat = embeddedFactory.getTomcat();
|
Tomcat tomcat = server.getTomcat();
|
||||||
Context context = (Context) tomcat.getHost().findChildren()[0];
|
Context context = (Context) tomcat.getHost().findChildren()[0];
|
||||||
assertThat(context.getResources().getCacheTtl()).isEqualTo(10000L);
|
assertThat(context.getResources().getCacheTtl()).isEqualTo(10000L);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedFactory.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1015,7 +1015,7 @@ following information:
|
||||||
|
|
||||||
[[production-ready-metrics-jdbc]]
|
[[production-ready-metrics-jdbc]]
|
||||||
=== DataSource metrics
|
=== 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
|
metric named `data.source`. Data source instrumentation results in gauges representing
|
||||||
the currently active, maximum allowed, and minimum allowed connections in the pool. Each
|
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
|
of these gauges has a name which is prefixed by `data.source` by default. The prefix can
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,6 @@ public class AnnotationConfigReactiveWebApplicationContext
|
||||||
* with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
|
* with a {@code BeanNameGenerator} or {@code ScopeMetadataResolver} yet.
|
||||||
* @param beanFactory the bean factory to load bean definitions into
|
* @param beanFactory the bean factory to load bean definitions into
|
||||||
* @return the class path bean definition scanner
|
* @return the class path bean definition scanner
|
||||||
* @since 4.1.9
|
|
||||||
* @see #getEnvironment()
|
* @see #getEnvironment()
|
||||||
* @see #getBeanNameGenerator()
|
* @see #getBeanNameGenerator()
|
||||||
* @see #getScopeMetadataResolver()
|
* @see #getScopeMetadataResolver()
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.context.annotation.ScopeMetadataResolver;
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ReactiveWebServerApplicationContext} that accepts annotated classes as input -
|
* {@link ReactiveWebServerApplicationContext} that accepts annotated classes as input -
|
||||||
|
|
@ -124,8 +125,8 @@ public class AnnotationConfigReactiveWebServerApplicationContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a custom {@link BeanNameGenerator} for use with
|
* Provide a custom {@link BeanNameGenerator} for use with
|
||||||
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner}
|
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner},
|
||||||
* , if any.
|
* if any.
|
||||||
* <p>
|
* <p>
|
||||||
* Default is
|
* Default is
|
||||||
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
|
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
|
||||||
|
|
@ -197,10 +198,10 @@ public class AnnotationConfigReactiveWebServerApplicationContext
|
||||||
@Override
|
@Override
|
||||||
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
|
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
|
||||||
super.postProcessBeanFactory(beanFactory);
|
super.postProcessBeanFactory(beanFactory);
|
||||||
if (this.basePackages != null && this.basePackages.length > 0) {
|
if (!ObjectUtils.isEmpty(this.basePackages)) {
|
||||||
this.scanner.scan(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);
|
this.reader.register(this.annotatedClasses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,8 +122,8 @@ public class AnnotationConfigServletWebServerApplicationContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a custom {@link BeanNameGenerator} for use with
|
* Provide a custom {@link BeanNameGenerator} for use with
|
||||||
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner}
|
* {@link AnnotatedBeanDefinitionReader} and/or {@link ClassPathBeanDefinitionScanner},
|
||||||
* , if any.
|
* if any.
|
||||||
* <p>
|
* <p>
|
||||||
* Default is
|
* Default is
|
||||||
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
|
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
|
||||||
|
|
|
||||||
|
|
@ -101,12 +101,12 @@ public class ConfigurationPropertiesBinderBuilderTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void detectDefaultValidator() {
|
public void detectDefaultValidator() {
|
||||||
this.applicationContext.registerSingleton("configurationPropertiesValidator",
|
this.applicationContext.registerSingleton(ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME,
|
||||||
LocalValidatorFactoryBean.class);
|
LocalValidatorFactoryBean.class);
|
||||||
ConfigurationPropertiesBinder binder = this.builder
|
ConfigurationPropertiesBinder binder = this.builder
|
||||||
.withEnvironment(this.environment).build();
|
.withEnvironment(this.environment).build();
|
||||||
assertThat(ReflectionTestUtils.getField(binder, "validator")).isSameAs(
|
assertThat(ReflectionTestUtils.getField(binder, "validator")).isSameAs(
|
||||||
this.applicationContext.getBean("configurationPropertiesValidator"));
|
this.applicationContext.getBean(ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue