Separate container customization from ServerProperties

This commit creates a separate
`ServerPropertiesServletContainerCustomizer` that holds the servlet
container customization code, separating that concern from the server
configuration keys.

See gh-8066
This commit is contained in:
Brian Clozel
2017-01-27 21:29:02 +01:00
parent 8899b93de0
commit aeef41c977
11 changed files with 1175 additions and 1054 deletions

View File

@@ -40,6 +40,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.hateoas.HypermediaHttpMessageConverterConfiguration;
import org.springframework.boot.autoconfigure.web.DefaultServletContainerCustomizer;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ServerProperties;
@@ -182,6 +183,8 @@ public class EndpointWebMvcChildContextConfiguration {
private ServerProperties server;
private DefaultServletContainerCustomizer serverCustomizer;
@Override
public int getOrder() {
return 0;
@@ -195,10 +198,12 @@ public class EndpointWebMvcChildContextConfiguration {
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
this.serverCustomizer = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, DefaultServletContainerCustomizer.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
this.serverCustomizer.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path

View File

@@ -736,7 +736,7 @@ public class EndpointWebMvcAutoConfigurationTests {
}
@Configuration
@Import({ PropertyPlaceholderAutoConfiguration.class,
@Import({PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
JacksonAutoConfiguration.class, EndpointAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,