Restructure embedded web server packages

Rework `org.springframework.boot.context.embedded` to relocate classes
to `org.springframework.boot.web`. Packages are now organized around
the following areas:

Packages for shared concerns, for example the `WebServer` interface
to start/stop a server and the common configuration elements:
- org.springframework.boot.web.context
- org.springframework.boot.web.server

Servlet specific packages:
- org.springframework.boot.web.servlet.server
- org.springframework.boot.web.servlet.context
- org.springframework.boot.web.servlet.filter

Reactive specific packages:
- org.springframework.boot.web.reactive.context
- org.springframework.boot.web.reactive.server

Embedded server implementations (both reactive and servlet):
- org.springframework.boot.web.embedded

In addition:

- Rename `EmbeddedServletContainerFactory` to `ServletWebServerFactory`
  to align with the `ReactiveWebServerFactory`.
- Rename `EmbeddedWebApplicationContext` to
  `ServletWebServerApplicationContext` and
- Rename `EmbeddedReactiveWebApplicationContext` to
  `ReactiveWebServerApplicationContext`.
- Add checkstyle rules to restrict imports.
- Fixup all affected code to use the correct imports and local names.

Fixes gh-8532
pull/8585/head
Phillip Webb 8 years ago
parent 7b388e5865
commit 67556ba8ea

@ -45,17 +45,17 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.filter.ApplicationContextHeaderFilter;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.filter.ApplicationContextHeaderFilter;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
@ -95,7 +95,7 @@ import org.springframework.web.servlet.DispatcherServlet;
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(ManagementServerProperties.class)
@AutoConfigureAfter({ PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class, WebMvcAutoConfiguration.class,
RepositoryRestMvcAutoConfiguration.class, HypermediaAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class })
public class EndpointWebMvcAutoConfiguration
@ -138,13 +138,13 @@ public class EndpointWebMvcAutoConfiguration
.get(this.applicationContext.getEnvironment());
}
if (managementPort == ManagementServerPort.DIFFERENT) {
if (this.applicationContext instanceof EmbeddedWebApplicationContext
&& ((EmbeddedWebApplicationContext) this.applicationContext)
.getEmbeddedWebServer() != null) {
if (this.applicationContext instanceof ServletWebServerApplicationContext
&& ((ServletWebServerApplicationContext) this.applicationContext)
.getWebServer() != null) {
createChildManagementContext();
}
else {
logger.warn("Could not start embedded management container on "
logger.warn("Could not start management web server on "
+ "different port (management endpoints are still available "
+ "through JMX)");
}
@ -166,31 +166,30 @@ public class EndpointWebMvcAutoConfiguration
}
private void createChildManagementContext() {
AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
AnnotationConfigServletWebServerApplicationContext childContext = new AnnotationConfigServletWebServerApplicationContext();
childContext.setParent(this.applicationContext);
childContext.setNamespace("management");
childContext.setId(this.applicationContext.getId() + ":management");
childContext.setClassLoader(this.applicationContext.getClassLoader());
childContext.register(EndpointWebMvcChildContextConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class);
registerEmbeddedServletContainerFactory(childContext);
registerServletWebServerFactory(childContext);
CloseManagementContextListener.addIfPossible(this.applicationContext,
childContext);
childContext.refresh();
managementContextResolver().setApplicationContext(childContext);
}
private void registerEmbeddedServletContainerFactory(
AnnotationConfigEmbeddedWebApplicationContext childContext) {
private void registerServletWebServerFactory(
AnnotationConfigServletWebServerApplicationContext childContext) {
try {
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition("embeddedServletContainerFactory",
new RootBeanDefinition(
determineEmbeddedServletContainerFactoryClass()));
registry.registerBeanDefinition("ServletWebServerFactory",
new RootBeanDefinition(determineServletWebServerFactoryClass()));
}
}
catch (NoSuchBeanDefinitionException ex) {
@ -198,17 +197,17 @@ public class EndpointWebMvcAutoConfiguration
}
}
private Class<?> determineEmbeddedServletContainerFactoryClass()
private Class<?> determineServletWebServerFactoryClass()
throws NoSuchBeanDefinitionException {
Class<?> servletContainerFactoryClass = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class).getClass();
if (cannotBeInstantiated(servletContainerFactoryClass)) {
throw new FatalBeanException("EmbeddedServletContainerFactory implementation "
+ servletContainerFactoryClass.getName() + " cannot be instantiated. "
Class<?> factoryClass = this.applicationContext
.getBean(ServletWebServerFactory.class).getClass();
if (cannotBeInstantiated(factoryClass)) {
throw new FatalBeanException("ServletWebServerFactory implementation "
+ factoryClass.getName() + " cannot be instantiated. "
+ "To allow a separate management port to be used, a top-level class "
+ "or static inner class should be used instead");
}
return servletContainerFactoryClass;
return factoryClass;
}
private boolean cannotBeInstantiated(Class<?> clazz) {

@ -40,17 +40,17 @@ 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.DefaultServletWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -69,7 +69,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
* {@link EmbeddedWebServer} running on a different port is required.
* {@link WebServer} running on a different port is required.
*
* @author Dave Syer
* @author Stephane Nicoll
@ -109,8 +109,8 @@ public class EndpointWebMvcChildContextConfiguration {
}
@Bean
public ServerCustomization serverCustomization() {
return new ServerCustomization();
public ServerFactoryCustomization serverCustomization() {
return new ServerFactoryCustomization();
}
@Bean
@ -171,19 +171,19 @@ public class EndpointWebMvcChildContextConfiguration {
}
static class ServerCustomization
implements EmbeddedServletContainerCustomizer, Ordered {
static class ServerFactoryCustomization
implements ServletWebServerFactoryCustomizer, Ordered {
@Autowired
private ListableBeanFactory beanFactory;
// This needs to be lazily initialized because EmbeddedServletContainerCustomizer
// This needs to be lazily initialized because web server customizer
// instances get their callback very early in the context lifecycle.
private ManagementServerProperties managementServerProperties;
private ServerProperties server;
private DefaultServletContainerCustomizer serverCustomizer;
private DefaultServletWebServerFactoryCustomizer serverCustomizer;
@Override
public int getOrder() {
@ -191,7 +191,7 @@ public class EndpointWebMvcChildContextConfiguration {
}
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
public void customize(ConfigurableServletWebServerFactory webServerFactory) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
@ -199,23 +199,23 @@ public class EndpointWebMvcChildContextConfiguration {
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
this.serverCustomizer = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, DefaultServletContainerCustomizer.class);
this.beanFactory, DefaultServletWebServerFactoryCustomizer.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.serverCustomizer.customize(container);
this.serverCustomizer.customize(webServerFactory);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
webServerFactory.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path
container.setContextPath("");
webServerFactory.setContextPath("");
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
webServerFactory.setPort(this.managementServerProperties.getPort());
if (this.managementServerProperties.getSsl() != null) {
container.setSsl(this.managementServerProperties.getSsl());
webServerFactory.setSsl(this.managementServerProperties.getSsl());
}
container.setServerHeader(this.server.getServerHeader());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
webServerFactory.setServerHeader(this.server.getServerHeader());
webServerFactory.setAddress(this.managementServerProperties.getAddress());
webServerFactory.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
}
@ -343,8 +343,8 @@ public class EndpointWebMvcChildContextConfiguration {
}
static abstract class AccessLogCustomizer<T extends EmbeddedServletContainerFactory>
implements EmbeddedServletContainerCustomizer, Ordered {
static abstract class AccessLogCustomizer<T extends ServletWebServerFactory>
implements ServletWebServerFactoryCustomizer, Ordered {
private final Class<T> factoryClass;
@ -362,26 +362,26 @@ public class EndpointWebMvcChildContextConfiguration {
}
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.factoryClass.isInstance(container)) {
customize(this.factoryClass.cast(container));
public void customize(ConfigurableServletWebServerFactory serverFactory) {
if (this.factoryClass.isInstance(serverFactory)) {
customize(this.factoryClass.cast(serverFactory));
}
}
abstract void customize(T container);
abstract void customize(T webServerFactory);
}
static class TomcatAccessLogCustomizer
extends AccessLogCustomizer<TomcatEmbeddedServletContainerFactory> {
extends AccessLogCustomizer<TomcatServletWebServerFactory> {
TomcatAccessLogCustomizer() {
super(TomcatEmbeddedServletContainerFactory.class);
super(TomcatServletWebServerFactory.class);
}
@Override
public void customize(TomcatEmbeddedServletContainerFactory container) {
AccessLogValve accessLogValve = findAccessLogValve(container);
public void customize(TomcatServletWebServerFactory serverFactory) {
AccessLogValve accessLogValve = findAccessLogValve(serverFactory);
if (accessLogValve == null) {
return;
}
@ -389,8 +389,8 @@ public class EndpointWebMvcChildContextConfiguration {
}
private AccessLogValve findAccessLogValve(
TomcatEmbeddedServletContainerFactory container) {
for (Valve engineValve : container.getEngineValves()) {
TomcatServletWebServerFactory serverFactory) {
for (Valve engineValve : serverFactory.getEngineValves()) {
if (engineValve instanceof AccessLogValve) {
return (AccessLogValve) engineValve;
}
@ -401,15 +401,15 @@ public class EndpointWebMvcChildContextConfiguration {
}
static class UndertowAccessLogCustomizer
extends AccessLogCustomizer<UndertowEmbeddedServletContainerFactory> {
extends AccessLogCustomizer<UndertowServletWebServerFactory> {
UndertowAccessLogCustomizer() {
super(UndertowEmbeddedServletContainerFactory.class);
super(UndertowServletWebServerFactory.class);
}
@Override
public void customize(UndertowEmbeddedServletContainerFactory container) {
container.setAccessLogPrefix(customizePrefix(container.getAccessLogPrefix()));
public void customize(UndertowServletWebServerFactory serverFactory) {
serverFactory.setAccessLogPrefix(customizePrefix(serverFactory.getAccessLogPrefix()));
}
}

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -66,7 +66,7 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
@Conditional(JolokiaCondition.class)
@AutoConfigureBefore(ManagementWebSecurityAutoConfiguration.class)
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
@EnableConfigurationProperties(JolokiaProperties.class)
public class JolokiaAutoConfiguration {

@ -25,9 +25,9 @@ import javax.servlet.http.HttpSession;
import org.springframework.boot.autoconfigure.security.SecurityPrerequisite;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.boot.web.server.Ssl;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

@ -28,9 +28,9 @@ import org.apache.catalina.session.ManagerBase;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@ -47,9 +47,9 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
@Override
public Collection<Metric<?>> metrics() {
if (this.applicationContext instanceof EmbeddedWebApplicationContext) {
if (this.applicationContext instanceof ServletWebServerApplicationContext) {
Manager manager = getManager(
(EmbeddedWebApplicationContext) this.applicationContext);
(ServletWebServerApplicationContext) this.applicationContext);
if (manager != null) {
return metrics(manager);
}
@ -57,16 +57,16 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
return Collections.emptySet();
}
private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
EmbeddedWebServer embeddedWebServer = applicationContext.getEmbeddedWebServer();
if (embeddedWebServer instanceof TomcatEmbeddedServletContainer) {
return getManager((TomcatEmbeddedServletContainer) embeddedWebServer);
private Manager getManager(ServletWebServerApplicationContext applicationContext) {
WebServer webServer = applicationContext.getWebServer();
if (webServer instanceof TomcatWebServer) {
return getManager((TomcatWebServer) webServer);
}
return null;
}
private Manager getManager(TomcatEmbeddedServletContainer servletContainer) {
for (Container container : servletContainer.getTomcat().getHost()
private Manager getManager(TomcatWebServer webServer) {
for (Container container : webServer.getTomcat().getHost()
.findChildren()) {
if (container instanceof Context) {
return ((Context) container).getManager();

@ -23,10 +23,10 @@ import net.minidev.json.JSONArray;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class BootCuriesHrefIntegrationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@After
public void closeContext() {
@ -110,7 +110,7 @@ public class BootCuriesHrefIntegrationTests {
}
private int load(String... properties) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.setClassLoader(new ClassLoader(getClass().getClassLoader()) {
@Override

@ -42,14 +42,14 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -152,7 +152,7 @@ public class EndpointMvcIntegrationTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
JacksonAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -56,23 +56,23 @@ import org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.testutil.Matched;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
@ -115,7 +115,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private final AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext();
private final AnnotationConfigServletWebServerApplicationContext applicationContext = new AnnotationConfigServletWebServerApplicationContext();
private static ThreadLocal<Ports> ports = new ThreadLocal<>();
@ -185,10 +185,10 @@ public class EndpointWebMvcAutoConfigurationTests {
}
@Test
public void onDifferentPortWithSpecificContainer() throws Exception {
public void onDifferentPortWithSpecificServer() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.port=" + ports.get().management);
this.applicationContext.register(SpecificContainerConfig.class, RootConfig.class,
this.applicationContext.register(SpecificWebServerConfig.class, RootConfig.class,
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
@ -202,15 +202,13 @@ public class EndpointWebMvcAutoConfigurationTests {
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
EmbeddedServletContainerFactory parentContainerFactory = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class);
EmbeddedServletContainerFactory managementContainerFactory = managementContext
.getBean(EmbeddedServletContainerFactory.class);
assertThat(parentContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory).isNotSameAs(parentContainerFactory);
ServletWebServerFactory parentFactory = this.applicationContext
.getBean(ServletWebServerFactory.class);
ServletWebServerFactory managementFactory = managementContext
.getBean(ServletWebServerFactory.class);
assertThat(parentFactory).isInstanceOf(SpecificServletWebServerFactory.class);
assertThat(managementFactory).isInstanceOf(SpecificServletWebServerFactory.class);
assertThat(managementFactory).isNotSameAs(parentFactory);
}
@Test
@ -254,7 +252,7 @@ public class EndpointWebMvcAutoConfigurationTests {
}
@Test
public void onDifferentPortInServletContainer() throws Exception {
public void onDifferentPortInWebServer() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.port=" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
@ -282,7 +280,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext);
this.applicationContext.addApplicationListener(grabManagementPort);
this.applicationContext.refresh();
int managementPort = grabManagementPort.getServletContainer().getPort();
int managementPort = grabManagementPort.getWebServer().getPort();
assertThat(managementPort).isNotEqualTo(ports.get().server);
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
@ -348,7 +346,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.thrown.expect(EmbeddedWebServerException.class);
this.thrown.expect(WebServerException.class);
this.applicationContext.refresh();
}
finally {
@ -363,7 +361,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
PropertyPlaceholderAutoConfiguration.class,
JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
@ -379,7 +377,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
PropertyPlaceholderAutoConfiguration.class,
JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
@ -590,7 +588,7 @@ public class EndpointWebMvcAutoConfigurationTests {
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.port=" + ports.get().management);
this.applicationContext.register(TomcatContainerConfig.class, RootConfig.class,
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class,
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext,
@ -598,12 +596,11 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
EmbeddedServletContainerFactory servletContainerFactory = managementContext
.getBean(EmbeddedServletContainerFactory.class);
assertThat(servletContainerFactory)
.isInstanceOf(TomcatEmbeddedServletContainerFactory.class);
ServletWebServerFactory factory = managementContext
.getBean(ServletWebServerFactory.class);
assertThat(factory).isInstanceOf(TomcatServletWebServerFactory.class);
AccessLogValve accessLogValve = findAccessLogValve(
((TomcatEmbeddedServletContainerFactory) servletContainerFactory));
((TomcatServletWebServerFactory) factory));
assertThat(accessLogValve).isNotNull();
assertThat(accessLogValve.getPrefix()).isEqualTo("management_access_log");
}
@ -613,23 +610,22 @@ public class EndpointWebMvcAutoConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.port=" + ports.get().management,
"server.undertow.accesslog.enabled: true");
this.applicationContext.register(UndertowContainerConfig.class, RootConfig.class,
this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class,
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
EmbeddedServletContainerFactory servletContainerFactory = managementContext
.getBean(EmbeddedServletContainerFactory.class);
assertThat(servletContainerFactory)
.isInstanceOf(UndertowEmbeddedServletContainerFactory.class);
assertThat(((UndertowEmbeddedServletContainerFactory) servletContainerFactory)
.getAccessLogPrefix()).isEqualTo("management_access_log.");
ServletWebServerFactory factory = managementContext
.getBean(ServletWebServerFactory.class);
assertThat(factory).isInstanceOf(UndertowServletWebServerFactory.class);
assertThat(((UndertowServletWebServerFactory) factory).getAccessLogPrefix())
.isEqualTo("management_access_log.");
}
private AccessLogValve findAccessLogValve(
TomcatEmbeddedServletContainerFactory container) {
for (Valve engineValve : container.getEngineValves()) {
TomcatServletWebServerFactory webServerFactory) {
for (Valve engineValve : webServerFactory.getEngineValves()) {
if (engineValve instanceof AccessLogValve) {
return (AccessLogValve) engineValve;
}
@ -733,7 +729,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Configuration
@Import({ PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
JacksonAutoConfiguration.class, EndpointAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
@ -784,31 +780,31 @@ public class EndpointWebMvcAutoConfigurationTests {
}
@Configuration
public static class SpecificContainerConfig {
public static class SpecificWebServerConfig {
@Bean
public SpecificEmbeddedServletContainerFactory embeddedServletContainerFactory() {
return new SpecificEmbeddedServletContainerFactory();
public SpecificServletWebServerFactory webServerFactory() {
return new SpecificServletWebServerFactory();
}
}
@Configuration
public static class TomcatContainerConfig {
public static class TomcatWebServerConfig {
@Bean
public TomcatEmbeddedServletContainerFactory embeddedServletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory();
}
}
@Configuration
public static class UndertowContainerConfig {
public static class UndertowWebServerConfig {
@Bean
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
return new UndertowEmbeddedServletContainerFactory();
public UndertowServletWebServerFactory webServerFactory() {
return new UndertowServletWebServerFactory();
}
}
@ -879,31 +875,31 @@ public class EndpointWebMvcAutoConfigurationTests {
}
private static class GrabManagementPort
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
implements ApplicationListener<ServletWebServerInitializedEvent> {
private ApplicationContext rootContext;
private EmbeddedWebServer servletContainer;
private WebServer webServer;
GrabManagementPort(ApplicationContext rootContext) {
this.rootContext = rootContext;
}
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
if (event.getApplicationContext() != this.rootContext) {
this.servletContainer = event.getEmbeddedWebServer();
this.webServer = event.getWebServer();
}
}
public EmbeddedWebServer getServletContainer() {
return this.servletContainer;
public WebServer getWebServer() {
return this.webServer;
}
}
private static class SpecificEmbeddedServletContainerFactory
extends TomcatEmbeddedServletContainerFactory {
private static class SpecificServletWebServerFactory
extends TomcatServletWebServerFactory {
}

@ -30,12 +30,12 @@ import org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityIntercep
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.web.servlet.MockMvc;
@ -53,21 +53,21 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class JolokiaAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@After
public void close() {
if (this.context != null) {
this.context.close();
}
if (Config.containerFactory != null) {
Config.containerFactory = null;
if (Config.webServerFactory != null) {
Config.webServerFactory = null;
}
}
@Test
public void agentServletRegisteredWithAppContext() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1",
"jolokia.config[key2]:value2");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
@ -80,7 +80,7 @@ public class JolokiaAutoConfigurationTests {
@Test
public void agentServletWithCustomPath() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"endpoints.jolokia.path=/foo/bar");
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
@ -112,7 +112,7 @@ public class JolokiaAutoConfigurationTests {
}
private void assertEndpointDisabled(String... pairs) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, pairs);
this.context.register(Config.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
@ -123,7 +123,7 @@ public class JolokiaAutoConfigurationTests {
}
private void assertEndpointEnabled(String... pairs) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, pairs);
this.context.register(Config.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
@ -151,19 +151,19 @@ public class JolokiaAutoConfigurationTests {
@EnableConfigurationProperties
protected static class Config {
protected static MockEmbeddedServletContainerFactory containerFactory = null;
protected static MockServletWebServerFactory webServerFactory = null;
@Bean
public EmbeddedServletContainerFactory containerFactory() {
if (containerFactory == null) {
containerFactory = new MockEmbeddedServletContainerFactory();
public ServletWebServerFactory webServerFactory() {
if (webServerFactory == null) {
webServerFactory = new MockServletWebServerFactory();
}
return containerFactory;
return webServerFactory;
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}

@ -27,9 +27,9 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Configuration;
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class,
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
HypermediaAutoConfiguration.class, EndpointAutoConfiguration.class,

@ -43,9 +43,9 @@ import org.springframework.boot.actuate.metrics.rich.RichGaugeReader;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvidersConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.ConfigurableApplicationContext;
@ -237,14 +237,13 @@ public class PublicMetricsAutoConfigurationTests {
}
private void loadWeb(Class<?>... config) {
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
if (config.length > 0) {
context.register(config);
}
context.register(DataSourcePoolMetadataProvidersConfiguration.class,
CacheStatisticsAutoConfiguration.class,
PublicMetricsAutoConfiguration.class,
MockEmbeddedServletContainerFactory.class);
PublicMetricsAutoConfiguration.class, MockServletWebServerFactory.class);
context.refresh();
this.context = context;
}
@ -346,8 +345,8 @@ public class PublicMetricsAutoConfigurationTests {
static class TomcatConfiguration {
@Bean
public TomcatEmbeddedServletContainerFactory containerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
return factory;
}

@ -23,11 +23,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.ExampleServlet;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.server.ExampleServlet;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException;
@ -63,13 +63,12 @@ public class SkipSslVerificationHttpRequestFactoryTests {
}
private String getHttpsUrl() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(
0);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
factory.setSsl(getSsl("password", "classpath:test.jks"));
EmbeddedWebServer container = factory.getEmbeddedServletContainer(
WebServer webServer = factory.getWebServer(
new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
container.start();
return "https://localhost:" + container.getPort() + "/hello";
webServer.start();
return "https://localhost:" + webServer.getPort() + "/hello";
}
private Ssl getSsl(String keyPassword, String keyStore) {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -21,8 +21,8 @@ import java.util.Iterator;
import org.junit.Test;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.SocketUtils;
@ -39,7 +39,7 @@ public class TomcatPublicMetricsTests {
@Test
public void tomcatMetrics() throws Exception {
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
Config.class);
try {
TomcatPublicMetrics tomcatMetrics = context
@ -58,8 +58,8 @@ public class TomcatPublicMetricsTests {
static class Config {
@Bean
public TomcatEmbeddedServletContainerFactory containerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
return factory;
}

@ -23,10 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

@ -23,10 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

@ -26,8 +26,8 @@ import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -38,8 +38,8 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
* configure beans that you are likely to need. Auto-configuration classes are usually
* applied based on your classpath and what beans you have defined. For example, If you
* have {@code tomcat-embedded.jar} on your classpath you are likely to want a
* {@link TomcatEmbeddedServletContainerFactory} (unless you have defined your own
* {@link EmbeddedServletContainerFactory} bean).
* {@link TomcatServletWebServerFactory} (unless you have defined your own
* {@link ServletWebServerFactory} bean).
* <p>
* Auto-configuration tries to be as intelligent as possible and will back-away as you
* define more of your own configuration. You can always manually {@link #exclude()} any

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.condition;
import java.util.Map;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.context.ReactiveWebApplicationContext;
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.Ordered;

@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeStacktrace;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@ -38,7 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
* Basic global error {@link Controller}, rendering {@link ErrorAttributes}. More specific
* errors can be handled either using Spring MVC abstractions (e.g.
* {@code @ExceptionHandler}) or by adding servlet
* {@link AbstractEmbeddedServletContainerFactory#setErrorPages container error pages}.
* {@link AbstractServletWebServerFactory#setErrorPages server error pages}.
*
* @author Dave Syer
* @author Phillip Webb

@ -43,19 +43,19 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.springframework.boot.autoconfigure.web.ServerProperties.Session;
import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.InitParameterConfiguringServletContextInitializer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.InitParameterConfiguringServletContextInitializer;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
@ -63,26 +63,26 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Customizer used by an {@link EmbeddedServletContainerFactory} when an
* {@link EmbeddedServletContainerCustomizerBeanPostProcessor} is active.
* Customizer used by an {@link ServletWebServerFactory} when an
* {@link ServletWebServerFactoryCustomizerBeanPostProcessor} is active.
*
* @author Brian Clozel
* @author Stephane Nicoll
* @since 2.0.0
*/
public class DefaultServletContainerCustomizer
implements EmbeddedServletContainerCustomizer, EnvironmentAware, Ordered {
public class DefaultServletWebServerFactoryCustomizer
implements ServletWebServerFactoryCustomizer, EnvironmentAware, Ordered {
private final ServerProperties serverProperties;
private Environment environment;
public DefaultServletContainerCustomizer(ServerProperties serverProperties) {
public DefaultServletWebServerFactoryCustomizer(ServerProperties serverProperties) {
this.serverProperties = serverProperties;
}
public void setLoader(String value) {
// no op to support Tomcat running as a traditional container (not embedded)
// no op to support Tomcat running as a traditional server (not embedded)
}
@Override
@ -96,50 +96,50 @@ public class DefaultServletContainerCustomizer
}
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
public void customize(ConfigurableServletWebServerFactory factory) {
if (this.serverProperties.getPort() != null) {
container.setPort(this.serverProperties.getPort());
factory.setPort(this.serverProperties.getPort());
}
if (this.serverProperties.getAddress() != null) {
container.setAddress(this.serverProperties.getAddress());
factory.setAddress(this.serverProperties.getAddress());
}
if (this.serverProperties.getServlet().getContextPath() != null) {
container.setContextPath(this.serverProperties.getServlet().getContextPath());
factory.setContextPath(this.serverProperties.getServlet().getContextPath());
}
if (this.serverProperties.getDisplayName() != null) {
container.setDisplayName(this.serverProperties.getDisplayName());
factory.setDisplayName(this.serverProperties.getDisplayName());
}
if (this.serverProperties.getSession().getTimeout() != null) {
container.setSessionTimeout(this.serverProperties.getSession().getTimeout());
factory.setSessionTimeout(this.serverProperties.getSession().getTimeout());
}
container.setPersistSession(this.serverProperties.getSession().isPersistent());
container.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
factory.setPersistSession(this.serverProperties.getSession().isPersistent());
factory.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
if (this.serverProperties.getSsl() != null) {
container.setSsl(this.serverProperties.getSsl());
factory.setSsl(this.serverProperties.getSsl());
}
if (this.serverProperties.getServlet() != null) {
container.setJsp(this.serverProperties.getServlet().getJsp());
factory.setJsp(this.serverProperties.getServlet().getJsp());
}
if (this.serverProperties.getCompression() != null) {
container.setCompression(this.serverProperties.getCompression());
factory.setCompression(this.serverProperties.getCompression());
}
container.setServerHeader(this.serverProperties.getServerHeader());
if (container instanceof TomcatEmbeddedServletContainerFactory) {
factory.setServerHeader(this.serverProperties.getServerHeader());
if (factory instanceof TomcatServletWebServerFactory) {
TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment,
(TomcatEmbeddedServletContainerFactory) container);
(TomcatServletWebServerFactory) factory);
}
if (container instanceof JettyEmbeddedServletContainerFactory) {
if (factory instanceof JettyServletWebServerFactory) {
JettyCustomizer.customizeJetty(this.serverProperties, this.environment,
(JettyEmbeddedServletContainerFactory) container);
(JettyServletWebServerFactory) factory);
}
if (container instanceof UndertowEmbeddedServletContainerFactory) {
if (factory instanceof UndertowServletWebServerFactory) {
UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment,
(UndertowEmbeddedServletContainerFactory) container);
(UndertowServletWebServerFactory) factory);
}
container.addInitializers(
factory.addInitializers(
new SessionConfiguringInitializer(this.serverProperties.getSession()));
container.addInitializers(new InitParameterConfiguringServletContextInitializer(
factory.addInitializers(new InitParameterConfiguringServletContextInitializer(
this.serverProperties.getServlet().getContextParameters()));
}
@ -216,7 +216,7 @@ public class DefaultServletContainerCustomizer
private static class TomcatCustomizer {
public static void customizeTomcat(ServerProperties serverProperties,
Environment environment, TomcatEmbeddedServletContainerFactory factory) {
Environment environment, TomcatServletWebServerFactory factory) {
ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();
if (tomcatProperties.getBasedir() != null) {
@ -266,8 +266,8 @@ public class DefaultServletContainerCustomizer
}
}
private static void customizeAcceptCount(
TomcatEmbeddedServletContainerFactory factory, final int acceptCount) {
private static void customizeAcceptCount(TomcatServletWebServerFactory factory,
final int acceptCount) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -282,8 +282,8 @@ public class DefaultServletContainerCustomizer
});
}
private static void customizeMaxConnections(
TomcatEmbeddedServletContainerFactory factory, final int maxConnections) {
private static void customizeMaxConnections(TomcatServletWebServerFactory factory,
final int maxConnections) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -299,8 +299,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeConnectionTimeout(
TomcatEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
TomcatServletWebServerFactory factory, final int connectionTimeout) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -316,7 +315,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeRemoteIpValve(ServerProperties properties,
Environment environment, TomcatEmbeddedServletContainerFactory factory) {
Environment environment, TomcatServletWebServerFactory factory) {
String protocolHeader = properties.getTomcat().getProtocolHeader();
String remoteIpHeader = properties.getTomcat().getRemoteIpHeader();
// For back compatibility the valve is also enabled if protocol-header is set
@ -340,8 +339,8 @@ public class DefaultServletContainerCustomizer
}
@SuppressWarnings("rawtypes")
private static void customizeMaxThreads(
TomcatEmbeddedServletContainerFactory factory, final int maxThreads) {
private static void customizeMaxThreads(TomcatServletWebServerFactory factory,
final int maxThreads) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
@ -357,8 +356,7 @@ public class DefaultServletContainerCustomizer
}
@SuppressWarnings("rawtypes")
private static void customizeMinThreads(
TomcatEmbeddedServletContainerFactory factory,
private static void customizeMinThreads(TomcatServletWebServerFactory factory,
final int minSpareThreads) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -376,8 +374,7 @@ public class DefaultServletContainerCustomizer
@SuppressWarnings("rawtypes")
private static void customizeMaxHttpHeaderSize(
TomcatEmbeddedServletContainerFactory factory,
final int maxHttpHeaderSize) {
TomcatServletWebServerFactory factory, final int maxHttpHeaderSize) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -393,8 +390,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeMaxHttpPostSize(
TomcatEmbeddedServletContainerFactory factory,
final int maxHttpPostSize) {
TomcatServletWebServerFactory factory, final int maxHttpPostSize) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
@ -406,7 +402,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeAccessLog(ServerProperties.Tomcat tomcatProperties,
TomcatEmbeddedServletContainerFactory factory) {
TomcatServletWebServerFactory factory) {
AccessLogValve valve = new AccessLogValve();
valve.setPattern(tomcatProperties.getAccesslog().getPattern());
@ -423,7 +419,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeRedirectContextRoot(
TomcatEmbeddedServletContainerFactory factory,
TomcatServletWebServerFactory factory,
final boolean redirectContextRoot) {
factory.addContextCustomizers(new TomcatContextCustomizer() {
@ -440,8 +436,7 @@ public class DefaultServletContainerCustomizer
private static class UndertowCustomizer {
protected static void customizeUndertow(final ServerProperties serverProperties,
Environment environment,
UndertowEmbeddedServletContainerFactory factory) {
Environment environment, UndertowServletWebServerFactory factory) {
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow();
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
@ -484,8 +479,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeConnectionTimeout(
UndertowEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
UndertowServletWebServerFactory factory, final int connectionTimeout) {
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
public void customize(Undertow.Builder builder) {
@ -496,8 +490,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeMaxHttpHeaderSize(
UndertowEmbeddedServletContainerFactory factory,
final int maxHttpHeaderSize) {
UndertowServletWebServerFactory factory, final int maxHttpHeaderSize) {
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
@ -510,8 +503,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeMaxHttpPostSize(
UndertowEmbeddedServletContainerFactory factory,
final long maxHttpPostSize) {
UndertowServletWebServerFactory factory, final long maxHttpPostSize) {
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
@ -528,7 +520,7 @@ public class DefaultServletContainerCustomizer
private static class JettyCustomizer {
public static void customizeJetty(final ServerProperties serverProperties,
Environment environment, JettyEmbeddedServletContainerFactory factory) {
Environment environment, JettyServletWebServerFactory factory) {
ServerProperties.Jetty jettyProperties = serverProperties.getJetty();
factory.setUseForwardHeaders(
getOrDeduceUseForwardHeaders(serverProperties, environment));
@ -553,8 +545,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeConnectionTimeout(
JettyEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
JettyServletWebServerFactory factory, final int connectionTimeout) {
factory.addServerCustomizers(new JettyServerCustomizer() {
@Override
@ -572,8 +563,7 @@ public class DefaultServletContainerCustomizer
}
private static void customizeMaxHttpHeaderSize(
JettyEmbeddedServletContainerFactory factory,
final int maxHttpHeaderSize) {
JettyServletWebServerFactory factory, final int maxHttpHeaderSize) {
factory.addServerCustomizers(new JettyServerCustomizer() {
@Override
@ -619,8 +609,8 @@ public class DefaultServletContainerCustomizer
});
}
private static void customizeMaxHttpPostSize(
JettyEmbeddedServletContainerFactory factory, final int maxHttpPostSize) {
private static void customizeMaxHttpPostSize(JettyServletWebServerFactory factory,
final int maxHttpPostSize) {
factory.addServerCustomizers(new JettyServerCustomizer() {
@Override

@ -53,7 +53,7 @@ import org.springframework.web.servlet.DispatcherServlet;
/**
* {@link EnableAutoConfiguration Auto-configuration} for the Spring
* {@link DispatcherServlet}. Should work for a standalone application where an embedded
* servlet container is already present and also for a deployable application using
* web server is already present and also for a deployable application using
* {@link SpringBootServletInitializer}.
*
* @author Phillip Webb
@ -65,7 +65,7 @@ import org.springframework.web.servlet.DispatcherServlet;
@Configuration
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass(DispatcherServlet.class)
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
@EnableConfigurationProperties(ServerProperties.class)
public class DispatcherServletAutoConfiguration {

@ -44,11 +44,11 @@ import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
import org.springframework.boot.web.servlet.ErrorPageRegistry;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext;
@ -296,8 +296,7 @@ public class ErrorMvcAutoConfiguration {
}
/**
* {@link EmbeddedServletContainerCustomizer} that configures the container's error
* pages.
* {@link ServletWebServerFactoryCustomizer} that configures the server's error pages.
*/
private static class ErrorPageCustomizer implements ErrorPageRegistrar, Ordered {

@ -22,10 +22,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.HttpEncodingProperties.Type;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.filter.OrderedCharacterEncodingFilter;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
@ -68,7 +68,7 @@ public class HttpEncodingAutoConfiguration {
}
private static class LocaleCharsetMappingsCustomizer
implements EmbeddedServletContainerCustomizer, Ordered {
implements ServletWebServerFactoryCustomizer, Ordered {
private final HttpEncodingProperties properties;
@ -77,9 +77,9 @@ public class HttpEncodingAutoConfiguration {
}
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
public void customize(ConfigurableServletWebServerFactory webServerFactory) {
if (this.properties.getMapping() != null) {
container.setLocaleCharsetMappings(this.properties.getMapping());
webServerFactory.setLocaleCharsetMappings(this.properties.getMapping());
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -23,8 +23,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
@ -35,11 +35,11 @@ import org.springframework.web.servlet.DispatcherServlet;
* {@link EnableAutoConfiguration Auto-configuration} for multi-part uploads. Adds a
* {@link StandardServletMultipartResolver} if none is present, and adds a
* {@link javax.servlet.MultipartConfigElement multipartConfigElement} if none is
* otherwise defined. The {@link EmbeddedWebApplicationContext} will associate the
* otherwise defined. The {@link ServletWebServerApplicationContext} will associate the
* {@link MultipartConfigElement} bean to any {@link Servlet} beans.
* <p>
* The {@link javax.servlet.MultipartConfigElement} is a Servlet API that's used to
* configure how the container handles file uploads. By default
* configure how the server handles file uploads. By default
*
* @author Greg Turnquist
* @author Josh Long

@ -20,15 +20,20 @@ import java.io.File;
import java.net.InetAddress;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.Servlet;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.boot.web.server.Compression;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.servlet.server.Jsp;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* {@link ConfigurationProperties} for a web server (e.g. port and path settings).
@ -82,8 +87,8 @@ public class ServerProperties {
/**
* Time in milliseconds that connectors will wait for another HTTP request before
* closing the connection. When not set, the connector's container-specific default
* will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
* closing the connection. When not set, the connector's server-specific default will
* be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
*/
private Integer connectionTimeout;
@ -95,7 +100,6 @@ public class ServerProperties {
@NestedConfigurationProperty
private Compression compression = new Compression();
@NestedConfigurationProperty
private Servlet servlet = new Servlet();
private final Tomcat tomcat = new Tomcat();
@ -204,6 +208,120 @@ public class ServerProperties {
return this.undertow;
}
/**
* Servlet properties.
*/
public class Servlet {
/**
* ServletContext parameters.
*/
private final Map<String, String> contextParameters = new HashMap<>();
/**
* Context path of the application.
*/
private String contextPath;
/**
* Path of the main dispatcher servlet.
*/
private String path = "/";
@NestedConfigurationProperty
private Jsp jsp = new Jsp();
public String getContextPath() {
return this.contextPath;
}
public void setContextPath(String contextPath) {
this.contextPath = cleanContextPath(contextPath);
}
private String cleanContextPath(String contextPath) {
if (StringUtils.hasText(contextPath) && contextPath.endsWith("/")) {
return contextPath.substring(0, contextPath.length() - 1);
}
return contextPath;
}
public String getPath() {
return this.path;
}
public void setPath(String path) {
Assert.notNull(path, "Path must not be null");
this.path = path;
}
public Map<String, String> getContextParameters() {
return this.contextParameters;
}
public Jsp getJsp() {
return this.jsp;
}
public void setJsp(Jsp jsp) {
this.jsp = jsp;
}
public String getServletMapping() {
if (this.path.equals("") || this.path.equals("/")) {
return "/";
}
if (this.path.contains("*")) {
return this.path;
}
if (this.path.endsWith("/")) {
return this.path + "*";
}
return this.path + "/*";
}
public String getPath(String path) {
String prefix = getServletPrefix();
if (!path.startsWith("/")) {
path = "/" + path;
}
return prefix + path;
}
public String getServletPrefix() {
String result = this.path;
if (result.contains("*")) {
result = result.substring(0, result.indexOf("*"));
}
if (result.endsWith("/")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
public String[] getPathsArray(Collection<String> paths) {
String[] result = new String[paths.size()];
int i = 0;
for (String path : paths) {
result[i++] = getPath(path);
}
return result;
}
public String[] getPathsArray(String[] paths) {
String[] result = new String[paths.length];
int i = 0;
for (String path : paths) {
result[i++] = getPath(path);
}
return result;
}
}
/**
* Session properties.
*/
public static class Session {
/**
@ -264,6 +382,9 @@ public class ServerProperties {
this.storeDir = storeDir;
}
/**
* Cookie properties.
*/
public static class Cookie {
/**
@ -384,6 +505,9 @@ public class ServerProperties {
}
/**
* Tomcat properties.
*/
public static class Tomcat {
/**
@ -615,6 +739,9 @@ public class ServerProperties {
this.additionalTldSkipPatterns = additionalTldSkipPatterns;
}
/**
* Tomcat access log properties.
*/
public static class Accesslog {
/**
@ -753,6 +880,9 @@ public class ServerProperties {
}
/**
* Jetty properties.
*/
public static class Jetty {
/**
@ -796,6 +926,9 @@ public class ServerProperties {
}
/**
* Undertow properties.
*/
public static class Undertow {
/**
@ -884,6 +1017,9 @@ public class ServerProperties {
return this.accesslog;
}
/**
* Undertow access log properties.
*/
public static class Accesslog {
/**

@ -38,14 +38,14 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration.BeanPostProcessorsRegistrar;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ErrorPageRegistrarBeanPostProcessor;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPageRegistrarBeanPostProcessor;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -55,7 +55,7 @@ import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.ObjectUtils;
/**
* {@link EnableAutoConfiguration Auto-configuration} for an embedded servlet containers.
* {@link EnableAutoConfiguration Auto-configuration} for servlet web servers.
*
* @author Phillip Webb
* @author Dave Syer
@ -68,13 +68,13 @@ import org.springframework.util.ObjectUtils;
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(ServerProperties.class)
@Import(BeanPostProcessorsRegistrar.class)
public class EmbeddedServletContainerAutoConfiguration {
public class ServletWebServerFactoryAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public DefaultServletContainerCustomizer serverPropertiesServletContainerCustomizer(
public DefaultServletWebServerFactoryCustomizer serverPropertiesWebServerFactoryCustomizer(
ServerProperties serverProperties) {
return new DefaultServletContainerCustomizer(serverProperties);
return new DefaultServletWebServerFactoryCustomizer(serverProperties);
}
/**
@ -82,12 +82,12 @@ public class EmbeddedServletContainerAutoConfiguration {
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Tomcat.class })
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedTomcat {
@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
return new TomcatServletWebServerFactory();
}
}
@ -98,12 +98,12 @@ public class EmbeddedServletContainerAutoConfiguration {
@Configuration
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
WebAppContext.class })
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedJetty {
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
return new JettyEmbeddedServletContainerFactory();
public JettyServletWebServerFactory JettyServletWebServerFactory() {
return new JettyServletWebServerFactory();
}
}
@ -113,18 +113,18 @@ public class EmbeddedServletContainerAutoConfiguration {
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class })
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedUndertow {
@Bean
public UndertowEmbeddedServletContainerFactory undertowEmbeddedServletContainerFactory() {
return new UndertowEmbeddedServletContainerFactory();
public UndertowServletWebServerFactory undertowServletWebServerFactory() {
return new UndertowServletWebServerFactory();
}
}
/**
* Registers a {@link EmbeddedServletContainerCustomizerBeanPostProcessor}. Registered
* Registers a {@link ServletWebServerFactoryCustomizerBeanPostProcessor}. Registered
* via {@link ImportBeanDefinitionRegistrar} for early registration.
*/
public static class BeanPostProcessorsRegistrar
@ -146,8 +146,8 @@ public class EmbeddedServletContainerAutoConfiguration {
return;
}
registerSyntheticBeanIfMissing(registry,
"embeddedServletContainerCustomizerBeanPostProcessor",
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
"ServletWebServerCustomizerBeanPostProcessor",
ServletWebServerFactoryCustomizerBeanPostProcessor.class);
registerSyntheticBeanIfMissing(registry,
"errorPageRegistrarBeanPostProcessor",
ErrorPageRegistrarBeanPostProcessor.class);

@ -47,9 +47,9 @@ import org.springframework.boot.autoconfigure.validation.SpringValidator;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.filter.OrderedHiddenHttpMethodFilter;
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.filter.OrderedRequestContextFilter;
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@ -15,6 +15,6 @@
*/
/**
* Auto-configuration for embedded servlet containers and Spring MVC.
* Auto-configuration for embedded web servers and Spring MVC.
*/
package org.springframework.boot.autoconfigure.web;

@ -17,15 +17,15 @@
package org.springframework.boot.autoconfigure.webflux;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.ConfigurableReactiveWebServer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizer;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizer;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.core.Ordered;
/**
* Customizer used by an {@link ReactiveWebServerFactory} when an
* {@link EmbeddedServletContainerCustomizerBeanPostProcessor} is active.
* {@link ServletWebServerFactoryCustomizerBeanPostProcessor} is active.
*
* @author Brian Clozel
* @since 2.0.0
@ -45,7 +45,7 @@ public class DefaultReactiveWebServerCustomizer
}
@Override
public void customize(ConfigurableReactiveWebServer server) {
public void customize(ConfigurableReactiveWebServerFactory server) {
if (this.serverProperties.getPort() != null) {
server.setPort(this.serverProperties.getPort());
}

@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizerBeanPostProcessor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@ -21,11 +21,11 @@ import reactor.ipc.netty.http.server.HttpServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.context.embedded.jetty.JettyReactiveWebServerFactory;
import org.springframework.boot.context.embedded.reactor.ReactorNettyReactiveWebServerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatReactiveWebServerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowReactiveWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
/**
@ -43,8 +43,8 @@ abstract class ReactiveWebServerConfiguration {
static class ReactorNettyAutoConfiguration {
@Bean
public ReactorNettyReactiveWebServerFactory reactorNettyReactiveWebServerFactory() {
return new ReactorNettyReactiveWebServerFactory();
public NettyReactiveWebServerFactory NettyReactiveWebServerFactory() {
return new NettyReactiveWebServerFactory();
}
}

@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
@ -46,7 +46,7 @@ import org.springframework.ws.transport.http.MessageDispatcherServlet;
@ConditionalOnClass(MessageDispatcherServlet.class)
@ConditionalOnMissingBean(WsConfigurationSupport.class)
@EnableConfigurationProperties(WebServicesProperties.class)
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
public class WebServicesAutoConfiguration {
private final WebServicesProperties properties;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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.
@ -22,10 +22,10 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
/**
* {@link WebSocketContainerCustomizer} for {@link JettyEmbeddedServletContainerFactory}.
* {@link WebSocketContainerCustomizer} for {@link JettyServletWebServerFactory}.
*
* @author Dave Syer
* @author Phillip Webb
@ -33,11 +33,11 @@ import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletConta
* @since 1.2.0
*/
public class JettyWebSocketContainerCustomizer
extends WebSocketContainerCustomizer<JettyEmbeddedServletContainerFactory> {
extends WebSocketContainerCustomizer<JettyServletWebServerFactory> {
@Override
protected void doCustomize(JettyEmbeddedServletContainerFactory container) {
container.addConfigurations(new AbstractConfiguration() {
protected void doCustomize(JettyServletWebServerFactory factory) {
factory.addConfigurations(new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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.
@ -21,13 +21,13 @@ import java.lang.reflect.Constructor;
import org.apache.catalina.Context;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
* {@link WebSocketContainerCustomizer} for {@link TomcatEmbeddedServletContainerFactory}.
* {@link WebSocketContainerCustomizer} for {@link TomcatServletWebServerFactory}.
*
* @author Dave Syer
* @author Phillip Webb
@ -35,7 +35,7 @@ import org.springframework.util.ReflectionUtils;
* @since 1.2.0
*/
public class TomcatWebSocketContainerCustomizer
extends WebSocketContainerCustomizer<TomcatEmbeddedServletContainerFactory> {
extends WebSocketContainerCustomizer<TomcatServletWebServerFactory> {
private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener";
@ -44,12 +44,14 @@ public class TomcatWebSocketContainerCustomizer
private static final String WS_LISTENER = "org.apache.tomcat.websocket.server.WsContextListener";
@Override
public void doCustomize(TomcatEmbeddedServletContainerFactory tomcatContainer) {
tomcatContainer.addContextCustomizers(new TomcatContextCustomizer() {
public void doCustomize(TomcatServletWebServerFactory factory) {
factory.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
addListener(context, findListenerType());
}
});
}
@ -65,10 +67,9 @@ public class TomcatWebSocketContainerCustomizer
}
/**
* Instead of registering the WsSci directly as a ServletContainerInitializer, we use
* the ApplicationListener provided by Tomcat. Unfortunately the ApplicationListener
* class moved packages in Tomcat 8 and been deleted in 8.0.8 so we have to use
* reflection.
* Instead of registering directly as a ServletContainerInitializer, we use the
* ApplicationListener provided by Tomcat. Unfortunately the ApplicationListener class
* moved packages in Tomcat 8 and been deleted in 8.0.8 so we have to use reflection.
* @param context the current context
* @param listenerType the type of listener to add
*/

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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.
@ -19,23 +19,22 @@ package org.springframework.boot.autoconfigure.websocket;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
import org.springframework.boot.context.embedded.undertow.UndertowDeploymentInfoCustomizer;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
/**
* {@link WebSocketContainerCustomizer} for
* {@link UndertowEmbeddedServletContainerFactory}.
* {@link WebSocketContainerCustomizer} for {@link UndertowServletWebServerFactory}.
*
* @author Phillip Webb
* @since 1.2.0
*/
public class UndertowWebSocketContainerCustomizer
extends WebSocketContainerCustomizer<UndertowEmbeddedServletContainerFactory> {
extends WebSocketContainerCustomizer<UndertowServletWebServerFactory> {
@Override
protected void doCustomize(UndertowEmbeddedServletContainerFactory container) {
protected void doCustomize(UndertowServletWebServerFactory factory) {
WebsocketDeploymentInfoCustomizer customizer = new WebsocketDeploymentInfoCustomizer();
container.addDeploymentInfoCustomizers(customizer);
factory.addDeploymentInfoCustomizers(customizer);
}
private static class WebsocketDeploymentInfoCustomizer

@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -36,16 +36,16 @@ import org.springframework.context.annotation.Configuration;
* the appropriate WebSocket modules to be on the classpath.
* <p>
* If Tomcat's WebSocket support is detected on the classpath we add a customizer that
* installs the Tomcat Websocket initializer. In a non-embedded container it should
* already be there.
* installs the Tomcat Websocket initializer. In a non-embedded server it should already
* be there.
* <p>
* If Jetty's WebSocket support is detected on the classpath we add a configuration that
* configures the context with WebSocket support. In a non-embedded container it should
* configures the context with WebSocket support. In a non-embedded server it should
* already be there.
* <p>
* If Undertow's WebSocket support is detected on the classpath we add a customizer that
* installs the Undertow Websocket DeploymentInfo Customizer. In a non-embedded container
* it should already be there.
* installs the Undertow Websocket DeploymentInfo Customizer. In a non-embedded server it
* should already be there.
*
* @author Dave Syer
* @author Phillip Webb
@ -54,7 +54,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass({ Servlet.class, ServerContainer.class })
@ConditionalOnWebApplication(type = Type.SERVLET)
@AutoConfigureBefore(EmbeddedServletContainerAutoConfiguration.class)
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
public class WebSocketAutoConfiguration {
@Configuration

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -16,24 +16,24 @@
package org.springframework.boot.autoconfigure.websocket;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.core.Ordered;
import org.springframework.core.ResolvableType;
/**
* {@link EmbeddedServletContainerCustomizer} to configure websockets for a given
* {@link EmbeddedServletContainerFactory}.
* {@link ServletWebServerFactoryCustomizer} to configure websockets for a given
* {@link ServletWebServerFactory}.
*
* @param <T> the embedded servlet container factory
* @param <T> the {@link ServletWebServerFactory}
* @author Dave Syer
* @author Phillip Webb
* @author Andy Wilkinson
* @since 1.2.0
*/
public abstract class WebSocketContainerCustomizer<T extends EmbeddedServletContainerFactory>
implements EmbeddedServletContainerCustomizer, Ordered {
public abstract class WebSocketContainerCustomizer<T extends ServletWebServerFactory>
implements ServletWebServerFactoryCustomizer, Ordered {
@Override
public int getOrder() {
@ -42,17 +42,17 @@ public abstract class WebSocketContainerCustomizer<T extends EmbeddedServletCont
@SuppressWarnings("unchecked")
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (getContainerType().isAssignableFrom(container.getClass())) {
doCustomize((T) container);
public void customize(ConfigurableServletWebServerFactory factory) {
if (getWebServerFactoryType().isAssignableFrom(factory.getClass())) {
doCustomize((T) factory);
}
}
protected Class<?> getContainerType() {
protected Class<?> getWebServerFactoryType() {
return ResolvableType.forClass(WebSocketContainerCustomizer.class, getClass())
.resolveGeneric();
}
protected abstract void doCustomize(T container);
protected abstract void doCustomize(T factory);
}

@ -105,7 +105,7 @@ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,\
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\
org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration,\
org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,\
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,\

@ -20,7 +20,7 @@ import org.junit.After;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@ -48,7 +48,7 @@ public class AutoConfigurationReproTests {
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
SpringApplication application = new SpringApplication(EarlyInitConfig.class,
PropertySourcesPlaceholderConfigurer.class,
EmbeddedServletContainerAutoConfiguration.class);
ServletWebServerFactoryAutoConfiguration.class);
this.context = application.run("--server.port=0");
String bean = (String) this.context.getBean("earlyInit");
assertThat(bean).isEqualTo("bucket");

@ -36,10 +36,10 @@ import org.springframework.boot.WebApplicationType;
import org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -119,16 +119,16 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
.sources(ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
assertThat(this.context).isInstanceOf(ServletWebServerApplicationContext.class);
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedWebServer().getPort();
int expected = ((ServletWebServerApplicationContext) this.context)
.getWebServer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}

@ -21,8 +21,8 @@ import org.junit.Test;
import reactor.core.publisher.Mono;
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

@ -22,8 +22,8 @@ import reactor.core.publisher.Mono;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomFilterContextPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -94,7 +94,7 @@ public class JerseyAutoConfigurationCustomFilterPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -29,7 +29,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.ApplicationContext;
@ -73,7 +73,7 @@ public class JerseyAutoConfigurationCustomLoadOnStartupTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -121,7 +121,7 @@ public class JerseyAutoConfigurationCustomObjectMapperProviderTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomServletContextPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomServletPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -92,7 +92,7 @@ public class JerseyAutoConfigurationDefaultFilterPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -93,7 +93,7 @@ public class JerseyAutoConfigurationDefaultServletPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -35,7 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -132,7 +132,7 @@ public class JerseyAutoConfigurationObjectMapperProviderTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -32,11 +32,11 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServletContainerTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -67,7 +67,7 @@ public class JerseyAutoConfigurationServletContainerTests {
"Servlet " + Application.class.getName() + " was not registered");
}
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class,
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
@Import(ContainerConfiguration.class)
@Path("/hello")
@ -91,8 +91,8 @@ public class JerseyAutoConfigurationServletContainerTests {
public static class ContainerConfiguration {
@Bean
public TomcatEmbeddedServletContainerFactory tomcat() {
return new TomcatEmbeddedServletContainerFactory() {
public TomcatServletWebServerFactory tomcat() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {

@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@ -92,7 +92,7 @@ public class JerseyAutoConfigurationWithoutApplicationPathTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -32,11 +32,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Controller;
@ -58,13 +58,13 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MustacheAutoConfigurationIntegrationTests {
@Autowired
private EmbeddedWebApplicationContext context;
private ServletWebServerApplicationContext context;
private int port;
@Before
public void init() {
this.port = this.context.getEmbeddedWebServer().getPort();
this.port = this.context.getWebServer().getPort();
}
@Test
@ -112,7 +112,7 @@ public class MustacheAutoConfigurationIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ MustacheAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -37,11 +37,11 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
import org.springframework.boot.autoconfigure.mustache.MustacheResourceTemplateLoader;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -64,13 +64,13 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MustacheWebIntegrationTests {
@Autowired
private EmbeddedWebApplicationContext context;
private ServletWebServerApplicationContext context;
private int port;
@Before
public void init() {
this.port = this.context.getEmbeddedWebServer().getPort();
this.port = this.context.getWebServer().getPort();
}
@Test
@ -138,7 +138,7 @@ public class MustacheWebIntegrationTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
protected @interface MinimalWebConfiguration {

@ -33,10 +33,10 @@ import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -58,13 +58,13 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
@Test
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
try {
EnvironmentTestUtils.addEnvironment(context, "server.port:0",
"security.user.password:password");
context.register(Config.class);
context.refresh();
int port = context.getEmbeddedWebServer().getPort();
int port = context.getWebServer().getPort();
new TestRestTemplate("user", "password")
.getForEntity("http://localhost:" + port, Object.class);
// If early initialization occurred a ConverterNotFoundException is thrown
@ -87,8 +87,8 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
static class Config {
@Bean
public TomcatEmbeddedServletContainerFactory containerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(0);
return factory;
}

@ -32,9 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.ConfigurableApplicationContext;
@ -321,7 +321,7 @@ public class SpringBootWebSecurityConfigurationTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -34,10 +34,10 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceS
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@ -116,11 +116,11 @@ public class OAuth2AutoConfigurationTests {
private static final Class<?> AUTHORIZATION_SERVER_CONFIG = OAuth2AuthorizationServerConfiguration.class;
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@Test
public void testDefaultConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(AuthorizationAndResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -148,7 +148,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void methodSecurityExpressionHandlerIsConfiguredWithRoleHierarchyFromTheContext() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(RoleHierarchyConfiguration.class,
AuthorizationAndResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
@ -164,7 +164,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void methodSecurityExpressionHandlerIsConfiguredWithPermissionEvaluatorFromTheContext() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(PermissionEvaluatorConfiguration.class,
AuthorizationAndResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
@ -181,7 +181,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testEnvironmentalOverrides() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"security.oauth2.client.clientId:myclientid",
"security.oauth2.client.clientSecret:mysecret",
@ -204,7 +204,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testDisablingResourceServer() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(AuthorizationServerConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -214,7 +214,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testClientIsNotResourceServer() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(ClientConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -226,7 +226,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testCanUseClientCredentials() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(TestSecurityConfiguration.class,
MinimalSecureWebApplication.class);
EnvironmentTestUtils.addEnvironment(this.context,
@ -241,7 +241,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testCanUseClientCredentialsWithEnableOAuth2Client() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(ClientConfiguration.class,
MinimalSecureWebApplication.class);
EnvironmentTestUtils.addEnvironment(this.context,
@ -274,7 +274,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testDisablingAuthorizationServer() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(ResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
EnvironmentTestUtils.addEnvironment(this.context,
@ -288,7 +288,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testResourceServerOverride() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(AuthorizationAndResourceServerConfiguration.class,
CustomResourceServer.class, MinimalSecureWebApplication.class);
this.context.refresh();
@ -301,7 +301,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testAuthorizationServerOverride() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"security.oauth2.resourceId:resource-id");
this.context.register(AuthorizationAndResourceServerConfiguration.class,
@ -321,7 +321,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testDefaultPrePostSecurityAnnotations() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(AuthorizationAndResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -339,7 +339,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testClassicSecurityAnnotationOverride() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(SecuredEnabledConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -357,7 +357,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testJsr250SecurityAnnotationOverride() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(Jsr250EnabledConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -375,7 +375,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void testMethodSecurityBackingOff() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(CustomMethodSecurity.class, TestSecurityConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
@ -391,7 +391,7 @@ public class OAuth2AutoConfigurationTests {
@Test
public void resourceServerConditionWhenJwkConfigurationPresentShouldMatch()
throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys");
this.context.register(ResourceServerConfiguration.class,
@ -411,7 +411,7 @@ public class OAuth2AutoConfigurationTests {
private void verifyAuthentication(ClientDetails config, HttpStatus finalStatus) {
String baseUrl = "http://localhost:"
+ this.context.getEmbeddedWebServer().getPort();
+ this.context.getWebServer().getPort();
TestRestTemplate rest = new TestRestTemplate();
// First, verify the web endpoint can't be reached
assertEndpointUnauthorized(baseUrl, rest);
@ -573,8 +573,8 @@ public class OAuth2AutoConfigurationTests {
protected static class UseFreePortEmbeddedContainerConfiguration {
@Bean
TomcatEmbeddedServletContainerFactory containerFactory() {
return new TomcatEmbeddedServletContainerFactory(0);
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory(0);
}
}

@ -35,10 +35,10 @@ import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestO
import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration;
import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -317,8 +317,8 @@ public class ResourceServerTokenServicesConfigurationTests {
protected static class ResourceNoClientConfiguration extends ResourceConfiguration {
@Bean
public MockEmbeddedServletContainerFactory embeddedServletContainerFactory() {
return new MockEmbeddedServletContainerFactory();
public MockServletWebServerFactory webServerFactory() {
return new MockServletWebServerFactory();
}
}
@ -344,8 +344,8 @@ public class ResourceServerTokenServicesConfigurationTests {
protected static class SocialResourceConfiguration extends ResourceConfiguration {
@Bean
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
return mock(EmbeddedServletContainerFactory.class);
public ServletWebServerFactory webServerFactory() {
return mock(ServletWebServerFactory.class);
}
}

@ -26,12 +26,12 @@ import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;
@ -110,7 +110,7 @@ public class UserInfoTokenServicesRefreshTokenTests {
}
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -25,9 +25,9 @@ import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -36,7 +36,7 @@ import org.springframework.context.annotation.Import;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })

@ -124,7 +124,7 @@ public class BasicErrorControllerDirectMockMvcTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -100,7 +100,7 @@ public class BasicErrorControllerMockMvcTests {
@Test
public void testBindingExceptionForMachineClient() throws Exception {
// In a real container the response is carried over into the error dispatcher, but
// In a real server the response is carried over into the error dispatcher, but
// in the mock a new one is created so we have to assert the status at this
// intermediate point
MvcResult result = this.mockMvc.perform(get("/bind"))
@ -125,8 +125,8 @@ public class BasicErrorControllerMockMvcTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class,
EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.EmbeddedTomcat.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -108,7 +108,7 @@ public class DefaultErrorViewIntegrationTests {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })

@ -29,17 +29,17 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
@ -49,23 +49,23 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Integration tests for {@link DefaultServletContainerCustomizer}.
* Integration tests for {@link DefaultServletWebServerFactoryCustomizer}.
*
* @author Dave Syer
* @author Ivan Sopov
*/
public class DefaultServletContainerCustomizerIntegrationTests {
public class DefaultServletWebServerFactoryCustomizerTests {
private static AbstractEmbeddedServletContainerFactory containerFactory;
private static AbstractServletWebServerFactory webServerFactory;
@Rule
public ExpectedException thrown = ExpectedException.none();
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@Before
public void init() {
containerFactory = mock(AbstractEmbeddedServletContainerFactory.class);
webServerFactory = mock(AbstractServletWebServerFactory.class);
}
@After
@ -85,20 +85,20 @@ public class DefaultServletContainerCustomizerIntegrationTests {
@Test
public void createFromConfigClass() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "server.port:9000");
this.context.refresh();
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
assertThat(server.getPort().intValue()).isEqualTo(9000);
verify(containerFactory).setPort(9000);
verify(webServerFactory).setPort(9000);
}
@Test
public void tomcatProperties() throws Exception {
containerFactory = mock(TomcatEmbeddedServletContainerFactory.class);
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
webServerFactory = mock(TomcatServletWebServerFactory.class);
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"server.tomcat.basedir:target/foo", "server.port:9000");
@ -106,49 +106,47 @@ public class DefaultServletContainerCustomizerIntegrationTests {
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
assertThat(server.getTomcat().getBasedir()).isEqualTo(new File("target/foo"));
verify(containerFactory).setPort(9000);
verify(webServerFactory).setPort(9000);
}
@Test
public void customizeWithJettyContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomJettyContainerConfig.class,
public void customizeWithJettyWebServerFactory() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(CustomJettyWebServerConfig.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
webServerFactory = this.context.getBean(AbstractServletWebServerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
// The server.port environment property was not explicitly set so the container
// The server.port environment property was not explicitly set so the server
// factory should take precedence...
assertThat(containerFactory.getPort()).isEqualTo(3000);
assertThat(webServerFactory.getPort()).isEqualTo(3000);
}
@Test
public void customizeWithUndertowContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomUndertowContainerConfig.class,
public void customizeWithUndertowWebServerFactory() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(CustomUndertowWebServerConfig.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
webServerFactory = this.context.getBean(AbstractServletWebServerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
assertThat(containerFactory.getPort()).isEqualTo(3000);
assertThat(webServerFactory.getPort()).isEqualTo(3000);
}
@Test
public void customizeTomcatWithCustomizer() throws Exception {
containerFactory = mock(TomcatEmbeddedServletContainerFactory.class);
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
webServerFactory = mock(TomcatServletWebServerFactory.class);
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(Config.class, CustomizeConfig.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
// The server.port environment property was not explicitly set so the container
// The server.port environment property was not explicitly set so the server
// customizer should take precedence...
verify(containerFactory).setPort(3000);
verify(webServerFactory).setPort(3000);
}
@Configuration
@ -156,55 +154,55 @@ public class DefaultServletContainerCustomizerIntegrationTests {
protected static class Config {
@Bean
public DefaultServletContainerCustomizer defaultServletContainerCustomizer(
public DefaultServletWebServerFactoryCustomizer defaultServletWebServerFactoryCustomizer(
ServerProperties properties) {
return new DefaultServletContainerCustomizer(properties);
return new DefaultServletWebServerFactoryCustomizer(properties);
}
@Bean
public EmbeddedServletContainerFactory containerFactory() {
return DefaultServletContainerCustomizerIntegrationTests.containerFactory;
public ServletWebServerFactory webServerFactory() {
return DefaultServletWebServerFactoryCustomizerTests.webServerFactory;
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}
@Configuration
@EnableConfigurationProperties(ServerProperties.class)
protected static class CustomJettyContainerConfig {
protected static class CustomJettyWebServerConfig {
@Bean
public EmbeddedServletContainerFactory containerFactory() {
JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory();
public ServletWebServerFactory webServerFactory() {
JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
factory.setPort(3000);
return factory;
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}
@Configuration
@EnableConfigurationProperties(ServerProperties.class)
protected static class CustomUndertowContainerConfig {
protected static class CustomUndertowWebServerConfig {
@Bean
public EmbeddedServletContainerFactory containerFactory() {
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
public ServletWebServerFactory webServerFactory() {
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
factory.setPort(3000);
return factory;
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}
@ -213,12 +211,12 @@ public class DefaultServletContainerCustomizerIntegrationTests {
protected static class CustomizeConfig {
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
public ServletWebServerFactoryCustomizer webServerFactoryCustomizer() {
return new ServletWebServerFactoryCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(3000);
public void customize(ConfigurableServletWebServerFactory serverFactory) {
serverFactory.setPort(3000);
}
};

@ -28,13 +28,13 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory.RegisteredFilter;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.filter.OrderedCharacterEncodingFilter;
import org.springframework.boot.web.filter.OrderedRequestContextFilter;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory.RegisteredFilter;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnection;
@ -54,7 +54,7 @@ import static org.mockito.Mockito.mock;
*/
public class FilterOrderingIntegrationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@After
public void cleanup() {
@ -67,7 +67,7 @@ public class FilterOrderingIntegrationTests {
public void testFilterOrdering() {
load();
List<RegisteredFilter> registeredFilters = this.context
.getBean(MockEmbeddedServletContainerFactory.class).getContainer()
.getBean(MockServletWebServerFactory.class).getWebServer()
.getRegisteredFilters();
List<Filter> filters = new ArrayList<>(registeredFilters.size());
for (RegisteredFilter registeredFilter : registeredFilters) {
@ -83,10 +83,10 @@ public class FilterOrderingIntegrationTests {
}
private void load() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.session.store-type=hash-map");
this.context.register(MockEmbeddedServletContainerConfiguration.class,
this.context.register(MockWebServerConfiguration.class,
TestRedisConfiguration.class, WebMvcAutoConfiguration.class,
SecurityAutoConfiguration.class, SessionAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
@ -96,16 +96,16 @@ public class FilterOrderingIntegrationTests {
}
@Configuration
static class MockEmbeddedServletContainerConfiguration {
static class MockWebServerConfiguration {
@Bean
public MockEmbeddedServletContainerFactory containerFactory() {
return new MockEmbeddedServletContainerFactory();
public MockServletWebServerFactory webServerFactory() {
return new MockServletWebServerFactory();
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}

@ -30,12 +30,12 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.filter.OrderedHiddenHttpMethodFilter;
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@ -145,10 +145,10 @@ public class HttpEncodingAutoConfigurationTests {
@Test
public void noLocaleCharsetMapping() {
load(EmptyConfiguration.class);
Map<String, EmbeddedServletContainerCustomizer> beans = this.context
.getBeansOfType(EmbeddedServletContainerCustomizer.class);
Map<String, ServletWebServerFactoryCustomizer> beans = this.context
.getBeansOfType(ServletWebServerFactoryCustomizer.class);
assertThat(beans.size()).isEqualTo(1);
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
assertThat(this.context.getBean(MockServletWebServerFactory.class)
.getLocaleCharsetMappings().size()).isEqualTo(0);
}
@ -156,15 +156,15 @@ public class HttpEncodingAutoConfigurationTests {
public void customLocaleCharsetMappings() {
load(EmptyConfiguration.class, "spring.http.encoding.mapping.en:UTF-8",
"spring.http.encoding.mapping.fr_FR:UTF-8");
Map<String, EmbeddedServletContainerCustomizer> beans = this.context
.getBeansOfType(EmbeddedServletContainerCustomizer.class);
Map<String, ServletWebServerFactoryCustomizer> beans = this.context
.getBeansOfType(ServletWebServerFactoryCustomizer.class);
assertThat(beans.size()).isEqualTo(1);
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
assertThat(this.context.getBean(MockServletWebServerFactory.class)
.getLocaleCharsetMappings().size()).isEqualTo(2);
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
assertThat(this.context.getBean(MockServletWebServerFactory.class)
.getLocaleCharsetMappings().get(Locale.ENGLISH))
.isEqualTo(Charset.forName("UTF-8"));
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
assertThat(this.context.getBean(MockServletWebServerFactory.class)
.getLocaleCharsetMappings().get(Locale.FRANCE))
.isEqualTo(Charset.forName("UTF-8"));
}
@ -230,13 +230,13 @@ public class HttpEncodingAutoConfigurationTests {
static class MinimalWebAutoConfiguration {
@Bean
public MockEmbeddedServletContainerFactory mockEmbeddedServletContainerFactory() {
return new MockEmbeddedServletContainerFactory();
public MockServletWebServerFactory MockServletWebServerFactory() {
return new MockServletWebServerFactory();
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}

@ -23,18 +23,17 @@ import javax.servlet.MultipartConfigElement;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -68,7 +67,7 @@ import static org.mockito.Mockito.mock;
*/
public class MultipartAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@Rule
public ExpectedException thrown = ExpectedException.none();
@ -80,18 +79,18 @@ public class MultipartAutoConfigurationTests {
}
}
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
@Before
@After
public void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test
public void containerWithNothing() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithNothing.class, BaseConfiguration.class);
public void webServerWithNothing() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithNothing.class, BaseConfiguration.class);
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
verify404();
assertThat(servlet.getMultipartResolver()).isNotNull();
@ -101,9 +100,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithNoMultipartJettyConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithNoMultipartJetty.class, BaseConfiguration.class);
public void webServerWithNoMultipartJettyConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithNoMultipartJetty.class, BaseConfiguration.class);
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
assertThat(servlet.getMultipartResolver()).isNotNull();
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
@ -113,9 +112,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithNoMultipartUndertowConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithNoMultipartUndertow.class, BaseConfiguration.class);
public void webServerWithNoMultipartUndertowConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithNoMultipartUndertow.class, BaseConfiguration.class);
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
verifyServletWorks();
assertThat(servlet.getMultipartResolver()).isNotNull();
@ -125,9 +124,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithNoMultipartTomcatConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithNoMultipartTomcat.class, BaseConfiguration.class);
public void webServerWithNoMultipartTomcatConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithNoMultipartTomcat.class, BaseConfiguration.class);
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
assertThat(servlet.getMultipartResolver()).isNull();
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
@ -137,9 +136,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithAutomatedMultipartJettyConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithEverythingJetty.class, BaseConfiguration.class);
public void webServerWithAutomatedMultipartJettyConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithEverythingJetty.class, BaseConfiguration.class);
this.context.getBean(MultipartConfigElement.class);
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
this.context.getBean(DispatcherServlet.class).getMultipartResolver());
@ -147,11 +146,11 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithAutomatedMultipartTomcatConfiguration() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithEverythingTomcat.class, BaseConfiguration.class);
public void webServerWithAutomatedMultipartTomcatConfiguration() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithEverythingTomcat.class, BaseConfiguration.class);
new RestTemplate().getForObject(
"http://localhost:" + this.context.getEmbeddedWebServer().getPort() + "/",
"http://localhost:" + this.context.getWebServer().getPort() + "/",
String.class);
this.context.getBean(MultipartConfigElement.class);
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
@ -160,9 +159,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithAutomatedMultipartUndertowConfiguration() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithEverythingUndertow.class, BaseConfiguration.class);
public void webServerWithAutomatedMultipartUndertowConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithEverythingUndertow.class, BaseConfiguration.class);
this.context.getBean(MultipartConfigElement.class);
verifyServletWorks();
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
@ -170,21 +169,21 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithMultipartConfigDisabled() {
testContainerWithCustomMultipartConfigEnabledSetting("false", 0);
public void webServerWithMultipartConfigDisabled() {
testWebServerWithCustomMultipartConfigEnabledSetting("false", 0);
}
@Test
public void containerWithMultipartConfigEnabled() {
testContainerWithCustomMultipartConfigEnabledSetting("true", 1);
public void webServerWithMultipartConfigEnabled() {
testWebServerWithCustomMultipartConfigEnabledSetting("true", 1);
}
private void testContainerWithCustomMultipartConfigEnabledSetting(
private void testWebServerWithCustomMultipartConfigEnabledSetting(
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.http.multipart.enabled=" + propertyValue);
this.context.register(ContainerWithNoMultipartTomcat.class,
this.context.register(WebServerWithNoMultipartTomcat.class,
BaseConfiguration.class);
this.context.refresh();
this.context.getBean(MultipartProperties.class);
@ -193,9 +192,9 @@ public class MultipartAutoConfigurationTests {
}
@Test
public void containerWithCustomMultipartResolver() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
ContainerWithCustomMultipartResolver.class, BaseConfiguration.class);
public void webServerWithCustomMultipartResolver() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(
WebServerWithCustomMultipartResolver.class, BaseConfiguration.class);
MultipartResolver multipartResolver = this.context
.getBean(MultipartResolver.class);
assertThat(multipartResolver)
@ -204,10 +203,10 @@ public class MultipartAutoConfigurationTests {
@Test
public void configureResolveLazily() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.http.multipart.resolve-lazily=true");
this.context.register(ContainerWithNothing.class, BaseConfiguration.class);
this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
this.context.refresh();
StandardServletMultipartResolver multipartResolver = this.context
.getBean(StandardServletMultipartResolver.class);
@ -218,32 +217,32 @@ public class MultipartAutoConfigurationTests {
private void verify404() throws Exception {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
ClientHttpRequest request = requestFactory.createRequest(
new URI("http://localhost:"
+ this.context.getEmbeddedWebServer().getPort() + "/"),
HttpMethod.GET);
ClientHttpRequest request = requestFactory
.createRequest(
new URI("http://localhost:"
+ this.context.getWebServer().getPort() + "/"),
HttpMethod.GET);
ClientHttpResponse response = request.execute();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
private void verifyServletWorks() {
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:" + this.context.getEmbeddedWebServer().getPort()
+ "/";
String url = "http://localhost:" + this.context.getWebServer().getPort() + "/";
assertThat(restTemplate.getForObject(url, String.class)).isEqualTo("Hello");
}
@Configuration
public static class ContainerWithNothing {
public static class WebServerWithNothing {
}
@Configuration
public static class ContainerWithNoMultipartJetty {
public static class WebServerWithNoMultipartJetty {
@Bean
JettyEmbeddedServletContainerFactory containerFactory() {
return new JettyEmbeddedServletContainerFactory();
JettyServletWebServerFactory webServerFactory() {
return new JettyServletWebServerFactory();
}
@Bean
@ -254,11 +253,11 @@ public class MultipartAutoConfigurationTests {
}
@Configuration
public static class ContainerWithNoMultipartUndertow {
public static class WebServerWithNoMultipartUndertow {
@Bean
UndertowEmbeddedServletContainerFactory containerFactory() {
return new UndertowEmbeddedServletContainerFactory();
UndertowServletWebServerFactory webServerFactory() {
return new UndertowServletWebServerFactory();
}
@Bean
@ -269,7 +268,7 @@ public class MultipartAutoConfigurationTests {
}
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, MultipartAutoConfiguration.class })
@EnableConfigurationProperties(MultipartProperties.class)
protected static class BaseConfiguration {
@ -284,11 +283,11 @@ public class MultipartAutoConfigurationTests {
}
@Configuration
public static class ContainerWithNoMultipartTomcat {
public static class WebServerWithNoMultipartTomcat {
@Bean
TomcatEmbeddedServletContainerFactory containerFactory() {
return new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory();
}
@Bean
@ -299,7 +298,7 @@ public class MultipartAutoConfigurationTests {
}
@Configuration
public static class ContainerWithEverythingJetty {
public static class WebServerWithEverythingJetty {
@Bean
MultipartConfigElement multipartConfigElement() {
@ -307,8 +306,8 @@ public class MultipartAutoConfigurationTests {
}
@Bean
JettyEmbeddedServletContainerFactory containerFactory() {
return new JettyEmbeddedServletContainerFactory();
JettyServletWebServerFactory webServerFactory() {
return new JettyServletWebServerFactory();
}
@Bean
@ -320,7 +319,7 @@ public class MultipartAutoConfigurationTests {
@Configuration
@EnableWebMvc
public static class ContainerWithEverythingTomcat {
public static class WebServerWithEverythingTomcat {
@Bean
MultipartConfigElement multipartConfigElement() {
@ -328,8 +327,8 @@ public class MultipartAutoConfigurationTests {
}
@Bean
TomcatEmbeddedServletContainerFactory containerFactory() {
return new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory();
}
@Bean
@ -341,7 +340,7 @@ public class MultipartAutoConfigurationTests {
@Configuration
@EnableWebMvc
public static class ContainerWithEverythingUndertow {
public static class WebServerWithEverythingUndertow {
@Bean
MultipartConfigElement multipartConfigElement() {
@ -349,8 +348,8 @@ public class MultipartAutoConfigurationTests {
}
@Bean
UndertowEmbeddedServletContainerFactory containerFactory() {
return new UndertowEmbeddedServletContainerFactory();
UndertowServletWebServerFactory webServerFactory() {
return new UndertowServletWebServerFactory();
}
@Bean
@ -360,7 +359,7 @@ public class MultipartAutoConfigurationTests {
}
public static class ContainerWithCustomMultipartResolver {
public static class WebServerWithCustomMultipartResolver {
@Bean
MultipartResolver multipartResolver() {

@ -21,13 +21,13 @@ import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
import org.springframework.boot.web.servlet.ErrorPageRegistry;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Controller;
@ -71,7 +71,7 @@ public class RemappedErrorViewIntegrationTests {
@Configuration
@Import({ PropertyPlaceholderAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, ErrorMvcAutoConfiguration.class })
@Controller
public static class TestConfiguration implements ErrorPageRegistrar {

@ -39,13 +39,14 @@ import org.mockito.MockitoAnnotations;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.boot.bind.RelaxedDataBinder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
@ -58,84 +59,83 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link DefaultServletContainerCustomizer}.
* Tests for {@link ServerProperties} {@link ServletWebServerFactoryCustomizer}.
*
* @author Brian Clozel
*/
public class DefaultServletContainerCustomizerTests {
public class ServerPropertiesServletWebServerFactoryCustomizerTests {
private final ServerProperties properties = new ServerProperties();
private DefaultServletContainerCustomizer customizer;
private DefaultServletWebServerFactoryCustomizer customizer;
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
this.customizer = new DefaultServletContainerCustomizer(this.properties);
this.customizer = new DefaultServletWebServerFactoryCustomizer(this.properties);
}
@Test
public void tomcatAccessLogIsDisabledByDefault() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(tomcatContainer);
assertThat(tomcatContainer.getEngineValves()).isEmpty();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).isEmpty();
}
@Test
public void tomcatAccessLogCanBeEnabled() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true");
bindProperties(map);
this.customizer.customize(tomcatContainer);
assertThat(tomcatContainer.getEngineValves()).hasSize(1);
assertThat(tomcatContainer.getEngineValves()).first()
.isInstanceOf(AccessLogValve.class);
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).hasSize(1);
assertThat(factory.getEngineValves()).first().isInstanceOf(AccessLogValve.class);
}
@Test
public void tomcatAccessLogFileDateFormatByDefault() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accesslog.enabled", "true");
bindProperties(map);
this.customizer.customize(tomcatContainer);
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
.getFileDateFormat()).isEqualTo(".yyyy-MM-dd");
}
@Test
public void tomcatAccessLogFileDateFormatCanBeRedefined() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accesslog.enabled", "true");
map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH");
bindProperties(map);
this.customizer.customize(tomcatContainer);
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
.getFileDateFormat()).isEqualTo("yyyy-MM-dd.HH");
}
@Test
public void tomcatAccessLogIsBufferedByDefault() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true");
bindProperties(map);
this.customizer.customize(tomcatContainer);
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
.isBuffered()).isTrue();
}
@Test
public void tomcatAccessLogBufferingCanBeDisabled() {
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true");
map.put("server.tomcat.accesslog.buffered", "false");
bindProperties(map);
this.customizer.customize(tomcatContainer);
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
.isBuffered()).isFalse();
}
@ -146,11 +146,10 @@ public class DefaultServletContainerCustomizerTests {
bindProperties(map);
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
Context context = mock(Context.class);
for (TomcatContextCustomizer customizer : container
.getTomcatContextCustomizers()) {
for (TomcatContextCustomizer customizer : factory.getTomcatContextCustomizers()) {
customizer.customize(context);
}
verify(context).setMapperContextRootRedirectEnabled(false);
@ -158,24 +157,24 @@ public class DefaultServletContainerCustomizerTests {
@Test
public void testCustomizeTomcat() throws Exception {
ConfigurableEmbeddedServletContainer factory = mock(
ConfigurableEmbeddedServletContainer.class);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory, never()).setContextPath("");
}
@Test
public void testDefaultDisplayName() throws Exception {
ConfigurableEmbeddedServletContainer factory = mock(
ConfigurableEmbeddedServletContainer.class);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setDisplayName("application");
}
@Test
public void testCustomizeDisplayName() throws Exception {
ConfigurableEmbeddedServletContainer factory = mock(
ConfigurableEmbeddedServletContainer.class);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.properties.setDisplayName("TestName");
this.customizer.customize(factory);
verify(factory).setDisplayName("TestName");
@ -194,8 +193,8 @@ public class DefaultServletContainerCustomizerTests {
map.put("server.session.cookie.secure", "true");
map.put("server.session.cookie.max-age", "60");
bindProperties(map);
ConfigurableEmbeddedServletContainer factory = mock(
ConfigurableEmbeddedServletContainer.class);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
ServletContext servletContext = mock(ServletContext.class);
SessionCookieConfig sessionCookieConfig = mock(SessionCookieConfig.class);
given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
@ -215,8 +214,8 @@ public class DefaultServletContainerCustomizerTests {
@Test
public void testCustomizeTomcatPort() throws Exception {
ConfigurableEmbeddedServletContainer factory = mock(
ConfigurableEmbeddedServletContainer.class);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.properties.setPort(8080);
this.customizer.customize(factory);
verify(factory).setPort(8080);
@ -227,9 +226,9 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.display-name", "MyBootApp");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(container.getDisplayName()).isEqualTo("MyBootApp");
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getDisplayName()).isEqualTo("MyBootApp");
}
@Test
@ -238,19 +237,17 @@ public class DefaultServletContainerCustomizerTests {
map.put("server.tomcat.remote_ip_header", "");
map.put("server.tomcat.protocol_header", "");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(container.getEngineValves()).isEmpty();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).isEmpty();
}
@Test
public void defaultTomcatBackgroundProcessorDelay() throws Exception {
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(
((TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer())
.getTomcat().getEngine().getBackgroundProcessorDelay())
.isEqualTo(30);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine()
.getBackgroundProcessorDelay()).isEqualTo(30);
}
@Test
@ -258,12 +255,10 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.background-processor-delay", "5");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(
((TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer())
.getTomcat().getEngine().getBackgroundProcessorDelay())
.isEqualTo(5);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine()
.getBackgroundProcessorDelay()).isEqualTo(5);
}
@Test
@ -290,10 +285,10 @@ public class DefaultServletContainerCustomizerTests {
}
private void testRemoteIpValveConfigured() {
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(container.getEngineValves()).hasSize(1);
Valve valve = container.getEngineValves().iterator().next();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).hasSize(1);
Valve valve = factory.getEngineValves().iterator().next();
assertThat(valve).isInstanceOf(RemoteIpValve.class);
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("X-Forwarded-Proto");
@ -318,10 +313,10 @@ public class DefaultServletContainerCustomizerTests {
map.put("server.tomcat.port-header", "x-my-forward-port");
map.put("server.tomcat.protocol-header-https-value", "On");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(container.getEngineValves()).hasSize(1);
Valve valve = container.getEngineValves().iterator().next();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getEngineValves()).hasSize(1);
Valve valve = factory.getEngineValves().iterator().next();
assertThat(valve).isInstanceOf(RemoteIpValve.class);
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("x-my-protocol-header");
@ -336,18 +331,16 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accept-count", "10");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
0);
this.customizer.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
embeddedContainer.start();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
embeddedfactory.start();
try {
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
assertThat(((AbstractProtocol<?>) embeddedfactory.getTomcat().getConnector()
.getProtocolHandler()).getBacklog()).isEqualTo(10);
}
finally {
embeddedContainer.stop();
embeddedfactory.stop();
}
}
@ -356,18 +349,16 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.max-connections", "5");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
0);
this.customizer.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
embeddedContainer.start();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
embeddedfactory.start();
try {
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
assertThat(((AbstractProtocol<?>) embeddedfactory.getTomcat().getConnector()
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
}
finally {
embeddedContainer.stop();
embeddedfactory.stop();
}
}
@ -376,18 +367,16 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.max-http-post-size", "10000");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
0);
this.customizer.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
embeddedContainer.start();
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
embeddedfactory.start();
try {
assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize())
assertThat(embeddedfactory.getTomcat().getConnector().getMaxPostSize())
.isEqualTo(10000);
}
finally {
embeddedContainer.stop();
embeddedfactory.stop();
}
}
@ -401,15 +390,15 @@ public class DefaultServletContainerCustomizerTests {
map.put("server.undertow.accesslog.dir", "test-logs");
map.put("server.undertow.accesslog.rotate", "false");
bindProperties(map);
UndertowEmbeddedServletContainerFactory container = spy(
new UndertowEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setAccessLogEnabled(true);
verify(container).setAccessLogPattern("foo");
verify(container).setAccessLogPrefix("test_log");
verify(container).setAccessLogSuffix("txt");
verify(container).setAccessLogDirectory(new File("test-logs"));
verify(container).setAccessLogRotate(false);
UndertowServletWebServerFactory factory = spy(
new UndertowServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setAccessLogEnabled(true);
verify(factory).setAccessLogPattern("foo");
verify(factory).setAccessLogPrefix("test_log");
verify(factory).setAccessLogSuffix("txt");
verify(factory).setAccessLogDirectory(new File("test-logs"));
verify(factory).setAccessLogRotate(false);
}
@Test
@ -438,63 +427,60 @@ public class DefaultServletContainerCustomizerTests {
}
private void testCustomTomcatTldSkip(String... expectedJars) {
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.customizer.customize(container);
assertThat(container.getTldSkipPatterns()).contains(expectedJars);
assertThat(container.getTldSkipPatterns()).contains("junit-*.jar",
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getTldSkipPatterns()).contains(expectedJars);
assertThat(factory.getTldSkipPatterns()).contains("junit-*.jar",
"spring-boot-*.jar");
}
@Test
public void defaultUseForwardHeadersUndertow() throws Exception {
UndertowEmbeddedServletContainerFactory container = spy(
new UndertowEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(false);
UndertowServletWebServerFactory factory = spy(
new UndertowServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(false);
}
@Test
public void setUseForwardHeadersUndertow() throws Exception {
this.properties.setUseForwardHeaders(true);
UndertowEmbeddedServletContainerFactory container = spy(
new UndertowEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(true);
UndertowServletWebServerFactory factory = spy(
new UndertowServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void deduceUseForwardHeadersUndertow() throws Exception {
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
UndertowEmbeddedServletContainerFactory container = spy(
new UndertowEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(true);
UndertowServletWebServerFactory factory = spy(
new UndertowServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void defaultUseForwardHeadersJetty() throws Exception {
JettyEmbeddedServletContainerFactory container = spy(
new JettyEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(false);
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(false);
}
@Test
public void setUseForwardHeadersJetty() throws Exception {
this.properties.setUseForwardHeaders(true);
JettyEmbeddedServletContainerFactory container = spy(
new JettyEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(true);
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void deduceUseForwardHeadersJetty() throws Exception {
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
JettyEmbeddedServletContainerFactory container = spy(
new JettyEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setUseForwardHeaders(true);
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
@ -502,24 +488,22 @@ public class DefaultServletContainerCustomizerTests {
Map<String, String> map = new HashMap<>();
map.put("server.session.store-dir", "myfolder");
bindProperties(map);
JettyEmbeddedServletContainerFactory container = spy(
new JettyEmbeddedServletContainerFactory());
this.customizer.customize(container);
verify(container).setSessionStoreDir(new File("myfolder"));
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
this.customizer.customize(factory);
verify(factory).setSessionStoreDir(new File("myfolder"));
}
@Test
public void skipNullElementsForUndertow() throws Exception {
UndertowEmbeddedServletContainerFactory container = mock(
UndertowEmbeddedServletContainerFactory.class);
this.customizer.customize(container);
verify(container, never()).setAccessLogEnabled(anyBoolean());
UndertowServletWebServerFactory factory = mock(
UndertowServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory, never()).setAccessLogEnabled(anyBoolean());
}
private void triggerInitializers(ConfigurableEmbeddedServletContainer container,
private void triggerInitializers(ConfigurableServletWebServerFactory factory,
ServletContext servletContext) throws ServletException {
verify(container, atLeastOnce())
.addInitializers(this.initializersCaptor.capture());
verify(factory, atLeastOnce()).addInitializers(this.initializersCaptor.capture());
for (Object initializers : this.initializersCaptor.getAllValues()) {
if (initializers instanceof ServletContextInitializer) {
((ServletContextInitializer) initializers).onStartup(servletContext);

@ -26,13 +26,13 @@ import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -44,31 +44,32 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link EmbeddedServletContainerAutoConfiguration}.
* Tests for {@link ServletWebServerFactoryAutoConfiguration}.
*
* @author Dave Syer
* @author Phillip Webb
*/
public class EmbeddedServletContainerAutoConfigurationTests {
public class ServletWebServerFactoryAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@Test
public void createFromConfigClass() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
BaseConfiguration.class);
verifyContext();
}
@Test
public void contextAlreadyHasDispatcherServletWithDefaultName() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
DispatcherServletConfiguration.class, BaseConfiguration.class);
verifyContext();
}
@Test
public void contextAlreadyHasDispatcherServlet() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
SpringServletConfiguration.class, BaseConfiguration.class);
verifyContext();
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
@ -77,7 +78,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
@Test
public void contextAlreadyHasNonDispatcherServlet() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
NonSpringServletConfiguration.class, BaseConfiguration.class);
verifyContext(); // the non default servlet is still registered
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
@ -86,7 +87,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
@Test
public void contextAlreadyHasNonServlet() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
NonServletConfiguration.class, BaseConfiguration.class);
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
.isEqualTo(0);
@ -95,7 +96,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
@Test
public void contextAlreadyHasDispatcherServletAndRegistration() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
this.context = new AnnotationConfigServletWebServerApplicationContext(
DispatcherServletWithRegistrationConfiguration.class,
BaseConfiguration.class);
verifyContext();
@ -104,23 +105,23 @@ public class EmbeddedServletContainerAutoConfigurationTests {
}
@Test
public void containerHasNoServletContext() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
EnsureContainerHasNoServletContext.class, BaseConfiguration.class);
public void webServerHasNoServletContext() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(
EnsureWebServerHasNoServletContext.class, BaseConfiguration.class);
verifyContext();
}
@Test
public void customizeContainerThroughCallback() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
CallbackEmbeddedContainerCustomizer.class, BaseConfiguration.class);
public void customizeWebServerFactoryThroughCallback() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(
CallbackEmbeddedServerFactoryCustomizer.class, BaseConfiguration.class);
verifyContext();
assertThat(getContainerFactory().getPort()).isEqualTo(9000);
assertThat(getWebServerFactory().getPort()).isEqualTo(9000);
}
@Test
public void initParametersAreConfiguredOnTheServletContext() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"server.servlet.context-parameters.a:alpha",
"server.servlet.context-parameters.b:bravo");
@ -133,21 +134,20 @@ public class EmbeddedServletContainerAutoConfigurationTests {
}
private void verifyContext() {
MockEmbeddedServletContainerFactory containerFactory = getContainerFactory();
MockServletWebServerFactory factory = getWebServerFactory();
Servlet servlet = this.context.getBean(
DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME,
Servlet.class);
verify(containerFactory.getServletContext()).addServlet("dispatcherServlet",
servlet);
verify(factory.getServletContext()).addServlet("dispatcherServlet", servlet);
}
private MockEmbeddedServletContainerFactory getContainerFactory() {
return this.context.getBean(MockEmbeddedServletContainerFactory.class);
private MockServletWebServerFactory getWebServerFactory() {
return this.context.getBean(MockServletWebServerFactory.class);
}
@Configuration
@Import({ EmbeddedContainerConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
@Import({ WebServerConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class })
protected static class BaseConfiguration {
@ -155,11 +155,11 @@ public class EmbeddedServletContainerAutoConfigurationTests {
@Configuration
@ConditionalOnExpression("true")
public static class EmbeddedContainerConfiguration {
public static class WebServerConfiguration {
@Bean
public EmbeddedServletContainerFactory containerFactory() {
return new MockEmbeddedServletContainerFactory();
public ServletWebServerFactory webServerFactory() {
return new MockServletWebServerFactory();
}
}
@ -225,14 +225,14 @@ public class EmbeddedServletContainerAutoConfigurationTests {
}
@Component
public static class EnsureContainerHasNoServletContext implements BeanPostProcessor {
public static class EnsureWebServerHasNoServletContext implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof ConfigurableEmbeddedServletContainer) {
MockEmbeddedServletContainerFactory containerFactory = (MockEmbeddedServletContainerFactory) bean;
assertThat(containerFactory.getServletContext()).isNull();
if (bean instanceof ConfigurableServletWebServerFactory) {
MockServletWebServerFactory webServerFactory = (MockServletWebServerFactory) bean;
assertThat(webServerFactory.getServletContext()).isNull();
}
return bean;
}
@ -245,12 +245,12 @@ public class EmbeddedServletContainerAutoConfigurationTests {
}
@Component
public static class CallbackEmbeddedContainerCustomizer
implements EmbeddedServletContainerCustomizer {
public static class CallbackEmbeddedServerFactoryCustomizer
implements ServletWebServerFactoryCustomizer {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(9000);
public void customize(ConfigurableServletWebServerFactory serverFactory) {
serverFactory.setPort(9000);
}
}

@ -21,13 +21,13 @@ import javax.servlet.ServletContextListener;
import org.junit.Test;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -36,11 +36,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link EmbeddedWebServer}s driving {@link ServletContextListener}s correctly
* Tests for {@link WebServer}s driving {@link ServletContextListener}s correctly
*
* @author Andy Wilkinson
*/
public class EmbeddedServletContainerServletContextListenerTests {
public class ServletWebServerServletContextListenerTests {
@Test
public void registeredServletContextListenerBeanIsCalledByJetty() {
@ -73,7 +73,7 @@ public class EmbeddedServletContainerServletContextListenerTests {
}
private void servletContextListenerBeanIsCalled(Class<?> configuration) {
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
ServletContextListenerBeanConfiguration.class, configuration);
ServletContextListener servletContextListener = context
.getBean("servletContextListener", ServletContextListener.class);
@ -82,7 +82,7 @@ public class EmbeddedServletContainerServletContextListenerTests {
}
private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
ServletListenerRegistrationBeanConfiguration.class, configuration);
ServletContextListener servletContextListener = (ServletContextListener) context
.getBean("registration", ServletListenerRegistrationBean.class)
@ -95,8 +95,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
static class TomcatConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory(0);
public ServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory(0);
}
}
@ -105,8 +105,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
static class JettyConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
return new JettyEmbeddedServletContainerFactory(0);
public ServletWebServerFactory webServerFactory() {
return new JettyServletWebServerFactory(0);
}
}
@ -115,8 +115,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
static class UndertowConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
return new UndertowEmbeddedServletContainerFactory(0);
public ServletWebServerFactory webServerFactory() {
return new UndertowServletWebServerFactory(0);
}
}

@ -42,12 +42,12 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.validation.SpringValidator;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WelcomePageHandlerMapping;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -116,12 +116,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*/
public class WebMvcAutoConfigurationTests {
private static final MockEmbeddedServletContainerFactory containerFactory = new MockEmbeddedServletContainerFactory();
private static final MockServletWebServerFactory webServerFactory = new MockServletWebServerFactory();
@Rule
public ExpectedException thrown = ExpectedException.none();
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@After
public void close() {
@ -411,7 +411,7 @@ public class WebMvcAutoConfigurationTests {
@Test
public void overrideIgnoreDefaultModelOnRedirect() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mvc.ignore-default-model-on-redirect:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
@ -708,7 +708,7 @@ public class WebMvcAutoConfigurationTests {
}
private void load(Class<?> config, String... environment) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, environment);
List<Class<?>> configClasses = new ArrayList<>();
if (config != null) {
@ -768,13 +768,13 @@ public class WebMvcAutoConfigurationTests {
public static class Config {
@Bean
public EmbeddedServletContainerFactory containerFactory() {
return containerFactory;
public ServletWebServerFactory webServerFactory() {
return webServerFactory;
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}

@ -22,7 +22,7 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.ConfigurableReactiveWebServer;
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@ -45,7 +45,7 @@ public class DefaultReactiveWebServerCustomizerTests {
@Test
public void testCustomizeServerPort() throws Exception {
ConfigurableReactiveWebServer factory = mock(ConfigurableReactiveWebServer.class);
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
this.properties.setPort(9000);
this.customizer.customize(factory);
verify(factory).setPort(9000);
@ -53,7 +53,7 @@ public class DefaultReactiveWebServerCustomizerTests {
@Test
public void testCustomizeServerAddress() throws Exception {
ConfigurableReactiveWebServer factory = mock(ConfigurableReactiveWebServer.class);
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
InetAddress address = mock(InetAddress.class);
this.properties.setAddress(address);
this.customizer.customize(factory);

@ -20,8 +20,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@ -18,10 +18,10 @@ package org.springframework.boot.autoconfigure.webflux;
import java.util.Map;
import org.springframework.boot.context.embedded.AbstractReactiveWebServerFactory;
import org.springframework.boot.context.embedded.EmbeddedWebServer;
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.http.server.reactive.HttpHandler;
import static org.mockito.Mockito.spy;
@ -36,13 +36,13 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
private MockReactiveWebServer webServer;
@Override
public EmbeddedWebServer getReactiveHttpServer(HttpHandler httpHandler) {
public WebServer getWebServer(HttpHandler httpHandler) {
this.webServer = spy(new MockReactiveWebServer(httpHandler, getPort()));
return this.webServer;
}
@Override
public EmbeddedWebServer getReactiveHttpServer(Map<String, HttpHandler> handlerMap) {
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
this.webServer = spy(new MockReactiveWebServer(handlerMap, getPort()));
return this.webServer;
}
@ -51,7 +51,7 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
return this.webServer;
}
public static class MockReactiveWebServer implements EmbeddedWebServer {
public static class MockReactiveWebServer implements WebServer {
private final int port;
@ -78,12 +78,12 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
}
@Override
public void start() throws EmbeddedWebServerException {
public void start() throws WebServerException {
}
@Override
public void stop() throws EmbeddedWebServerException {
public void stop() throws WebServerException {
}

@ -22,9 +22,9 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import org.springframework.boot.context.embedded.EmbeddedReactiveWebApplicationContext;
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizer;
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizer;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -40,14 +40,14 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class ReactiveWebServerAutoConfigurationTests {
private EmbeddedReactiveWebApplicationContext context;
private ReactiveWebServerApplicationContext context;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void createFromConfigClass() {
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class);
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class);
assertThat(this.context.getBeansOfType(ReactiveWebServerFactory.class))
.hasSize(1);
assertThat(this.context.getBeansOfType(ReactiveWebServerCustomizer.class))
@ -60,7 +60,7 @@ public class ReactiveWebServerAutoConfigurationTests {
public void missingHttpHandler() {
this.thrown.expect(ApplicationContextException.class);
this.thrown.expectMessage(Matchers.containsString("missing HttpHandler bean"));
this.context = new EmbeddedReactiveWebApplicationContext(
this.context = new ReactiveWebServerApplicationContext(
MissingHttpHandlerConfiguration.class);
}
@ -69,13 +69,13 @@ public class ReactiveWebServerAutoConfigurationTests {
this.thrown.expect(ApplicationContextException.class);
this.thrown.expectMessage(Matchers.containsString(
"multiple HttpHandler beans : httpHandler,additionalHttpHandler"));
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class,
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class,
TooManyHttpHandlers.class);
}
@Test
public void customizeReactiveWebServer() {
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class,
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class,
ReactiveWebServerCustomization.class);
MockReactiveWebServerFactory factory = this.context
.getBean(MockReactiveWebServerFactory.class);

@ -24,9 +24,9 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.validation.SpringValidator;
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@ -27,11 +27,11 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
@ -45,11 +45,11 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class WebSocketAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
@Before
public void createContext() {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
}
@After
@ -92,8 +92,8 @@ public class WebSocketAutoConfigurationTests {
static class CommonConfiguration {
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}
@ -102,10 +102,10 @@ public class WebSocketAutoConfigurationTests {
static class TomcatConfiguration extends CommonConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
tomcatEmbeddedServletContainerFactory.setPort(0);
return tomcatEmbeddedServletContainerFactory;
public ServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(0);
return factory;
}
}
@ -114,10 +114,10 @@ public class WebSocketAutoConfigurationTests {
static class JettyConfiguration extends CommonConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory = new JettyEmbeddedServletContainerFactory();
jettyEmbeddedServletContainerFactory.setPort(0);
return jettyEmbeddedServletContainerFactory;
public ServletWebServerFactory webServerFactory() {
JettyServletWebServerFactory JettyServletWebServerFactory = new JettyServletWebServerFactory();
JettyServletWebServerFactory.setPort(0);
return JettyServletWebServerFactory;
}
}

@ -34,12 +34,12 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.CompositeMessageConverter;
@ -78,7 +78,7 @@ import static org.junit.Assert.fail;
*/
public class WebSocketMessagingAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
private AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
private SockJsClient sockJsClient;
@ -208,7 +208,7 @@ public class WebSocketMessagingAutoConfigurationTests {
@EnableConfigurationProperties
@EnableWebSocketMessageBroker
@ImportAutoConfiguration({ JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
WebSocketMessagingAutoConfiguration.class,
DispatcherServletAutoConfiguration.class })
static class WebSocketMessagingConfiguration
@ -230,8 +230,8 @@ public class WebSocketMessagingAutoConfigurationTests {
}
@Bean
public TomcatEmbeddedServletContainerFactory tomcat() {
return new TomcatEmbeddedServletContainerFactory(0);
public TomcatServletWebServerFactory tomcat() {
return new TomcatServletWebServerFactory(0);
}
@Bean

@ -16,7 +16,7 @@ class Example implements CommandLineRunner {
}
void run(String... args) {
def port = context.embeddedWebServer.port;
def port = context.webServer.port;
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
print "Hello " + world
}

@ -33,10 +33,8 @@ import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
import org.springframework.boot.devtools.filewatch.ChangedFiles;
@ -45,6 +43,8 @@ import org.springframework.boot.devtools.restart.FailureHandler;
import org.springframework.boot.devtools.restart.MockRestartInitializer;
import org.springframework.boot.devtools.restart.MockRestarter;
import org.springframework.boot.devtools.restart.Restarter;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -243,8 +243,8 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void devToolsSwitchesJspServletToDevelopmentMode() {
this.context = initializeAndRun(Config.class);
TomcatEmbeddedServletContainer tomcatContainer = (TomcatEmbeddedServletContainer) ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedWebServer();
TomcatWebServer tomcatContainer = (TomcatWebServer) ((ServletWebServerApplicationContext) this.context)
.getWebServer();
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils
@ -277,14 +277,14 @@ public class LocalDevToolsAutoConfigurationTests {
}
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
public static class Config {
}
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
public static class ConfigWithMockLiveReload {
@ -296,7 +296,7 @@ public class LocalDevToolsAutoConfigurationTests {
}
@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class,
@Import({ ServletWebServerFactoryAutoConfiguration.class,
LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
public static class WebResourcesConfig {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -23,8 +23,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.devtools.remote.server.AccessManager;
import org.springframework.boot.devtools.remote.server.Dispatcher;
import org.springframework.boot.devtools.remote.server.DispatcherFilter;
@ -42,6 +40,8 @@ import org.springframework.boot.devtools.tunnel.server.TargetServerConnection;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
@ -95,8 +95,8 @@ public class HttpTunnelIntegrationTests {
private int httpServerPort = SocketUtils.findAvailableTcpPort();
@Bean
public EmbeddedServletContainerFactory container() {
return new TomcatEmbeddedServletContainerFactory(this.httpServerPort);
public ServletWebServerFactory container() {
return new TomcatServletWebServerFactory(this.httpServerPort);
}
@Bean

@ -28,8 +28,6 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer;
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
@ -43,6 +41,8 @@ import org.springframework.boot.devtools.restart.RestartScopeInitializer;
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.server.ServerHttpRequest;
@ -71,7 +71,7 @@ public class RemoteClientConfigurationTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private AnnotationConfigEmbeddedWebApplicationContext context;
private AnnotationConfigServletWebServerApplicationContext context;
private static int remotePort = SocketUtils.findAvailableTcpPort();
@ -149,7 +149,7 @@ public class RemoteClientConfigurationTests {
}
private void configure(String remoteUrl, boolean setSecret, String... pairs) {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context = new AnnotationConfigServletWebServerApplicationContext();
new RestartScopeInitializer().initialize(this.context);
this.context.register(Config.class, RemoteClientConfiguration.class);
String remoteUrlProperty = "remoteUrl:" + remoteUrl + ":"
@ -167,8 +167,8 @@ public class RemoteClientConfigurationTests {
static class Config {
@Bean
public TomcatEmbeddedServletContainerFactory tomcat() {
return new TomcatEmbeddedServletContainerFactory(remotePort);
public TomcatServletWebServerFactory tomcat() {
return new TomcatServletWebServerFactory(remotePort);
}
@Bean

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -19,8 +19,10 @@ package org.springframework.boot.context.embedded;
import org.apache.catalina.Context;
import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -33,20 +35,20 @@ public class TomcatLegacyCookieProcessorExample {
/**
* Configuration class that declares the required
* {@link EmbeddedServletContainerCustomizer}.
* {@link ServletWebServerFactoryCustomizer}.
*/
@Configuration
static class LegacyCookieProcessorConfiguration {
// tag::customizer[]
@Bean
public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() {
return new EmbeddedServletContainerCustomizer() {
public ServletWebServerFactoryCustomizer cookieProcessorCustomizer() {
return new ServletWebServerFactoryCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
((TomcatEmbeddedServletContainerFactory) container)
public void customize(ConfigurableServletWebServerFactory serverFactory) {
if (serverFactory instanceof TomcatServletWebServerFactory) {
((TomcatServletWebServerFactory) serverFactory)
.addContextCustomizers(new TomcatContextCustomizer() {
@Override

@ -22,8 +22,10 @@ import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.embedded.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -38,10 +40,10 @@ public class TomcatLegacyCookieProcessorExampleTests {
@Test
public void cookieProcessorIsCustomized() {
EmbeddedWebApplicationContext applicationContext = (EmbeddedWebApplicationContext) new SpringApplication(
ServletWebServerApplicationContext applicationContext = (ServletWebServerApplicationContext) new SpringApplication(
TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
Context context = (Context) ((TomcatEmbeddedServletContainer) applicationContext
.getEmbeddedWebServer()).getTomcat().getHost().findChildren()[0];
Context context = (Context) ((TomcatWebServer) applicationContext
.getWebServer()).getTomcat().getHost().findChildren()[0];
assertThat(context.getCookieProcessor())
.isInstanceOf(LegacyCookieProcessor.class);
}
@ -50,13 +52,13 @@ public class TomcatLegacyCookieProcessorExampleTests {
static class TestConfiguration {
@Bean
public TomcatEmbeddedServletContainerFactory tomcatFactory() {
return new TomcatEmbeddedServletContainerFactory(0);
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory(0);
}
@Bean
public EmbeddedServletContainerCustomizerBeanPostProcessor postProcessor() {
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
public ServletWebServerFactoryCustomizerBeanPostProcessor postProcessor() {
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
}
}

@ -70,21 +70,21 @@ public class WarPackagingTests {
@Test
public void onlyTomcatIsPackagedInWebInfLibProvided() throws IOException {
checkWebInfEntriesForServletContainer("tomcat",
checkWebInfEntriesForWebServer("tomcat",
TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
}
@Test
public void onlyJettyIsPackagedInWebInfLibProvided() throws IOException {
checkWebInfEntriesForServletContainer("jetty",
checkWebInfEntriesForWebServer("jetty",
JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
}
private void checkWebInfEntriesForServletContainer(String servletContainer,
private void checkWebInfEntriesForWebServer(String webServer,
Set<String> expectedLibProvidedEntries) throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PservletContainer=" + servletContainer)
"-PservletContainer=" + webServer)
.run();
JarFile war = new JarFile("target/war-packaging/build/libs/war-packaging.war");

@ -301,7 +301,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.1.1</version>
<version>7.6</version>
</dependency>
</dependencies>
</plugin>

@ -77,6 +77,10 @@
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
<property name="processJavadoc" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck">
<property name="file" value="spring-boot-parent/src/checkstyle/import-control.xml" />
<property name="path" value="^.*[\\/]src[\\/]main[\\/].*$" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
<property name="groups" value="java,/^javax?\./,*,org.springframework" />
<property name="ordered" value="true" />

@ -0,0 +1,72 @@
<?xml version="1.0"?>
<!DOCTYPE import-control PUBLIC "-//Puppy Crawl//DTD Import Control 1.1//EN" "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
<import-control pkg="org.springframework.boot">
<allow pkg=".*" regex="true" />
<!-- Web related concerns -->
<subpackage name="web">
<!-- Lock things down -->
<disallow pkg="org.springframework.boot.web" />
<disallow pkg="org.springframework.web.servlet" />
<disallow pkg="javax.servlet" />
<!-- Common -->
<subpackage name="client">
</subpackage>
<subpackage name="server">
<disallow pkg="org.springframework.context" />
</subpackage>
<subpackage name="context">
<allow pkg="org.springframework.boot.web.server" />
</subpackage>
<!-- Servlet -->
<subpackage name="servlet">
<allow pkg="javax.servlet" />
<subpackage name="context">
<allow pkg="org.springframework.boot.web.context" />
<allow pkg="org.springframework.boot.web.server" />
<allow pkg="org.springframework.boot.web.servlet.server" />
<allow pkg="org.springframework.boot.web.servlet" />
</subpackage>
<subpackage name="filter">
<allow pkg="javax.servlet" />
<allow pkg="org.springframework.boot.web.servlet" />
</subpackage>
<subpackage name="server">
<disallow pkg="org.springframework.context" />
<allow pkg="org.springframework.boot.web.server" />
<allow pkg="org.springframework.boot.web.servlet" />
</subpackage>
</subpackage>
<subpackage name="support">
<allow pkg="javax.servlet" />
<allow pkg="org.springframework.boot.web.servlet" />
<allow pkg="org.springframework.boot.web.server" />
</subpackage>
<!-- Reactive -->
<subpackage name="reactive">
<subpackage name="context">
<allow pkg="org.springframework.boot.web.context" />
<allow pkg="org.springframework.boot.web.server" />
<allow pkg="org.springframework.boot.web.reactive.server" />
</subpackage>
<subpackage name="server">
<allow pkg="org.springframework.boot.web.server" />
<disallow pkg="org.springframework.context" />
</subpackage>
</subpackage>
<!-- Embedded Servers -->
<subpackage name="embedded">
<allow pkg="javax.servlet" />
<allow pkg="org.springframework.boot.web.server" />
<allow pkg="org.springframework.boot.web.servlet" />
<allow pkg="org.springframework.boot.web.servlet.server" />
<allow pkg="org.springframework.boot.web.reactive.server" />
</subpackage>
</subpackage>
</import-control>

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -22,10 +22,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -22,10 +22,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -29,9 +29,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -25,7 +25,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
@ -41,8 +41,8 @@ public class SampleJersey1Application {
@Bean
// Not needed if Spring Web MVC is also present on classpath
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory();
public TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory();
}
@Bean

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@ -19,11 +19,11 @@ package sample.jetty.ssl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;

@ -21,7 +21,7 @@ import java.net.URI;
import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.http.HttpHeaders;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@ -20,8 +20,8 @@ import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.util.SocketUtils;
@ -40,8 +40,8 @@ public class SampleTomcatTwoConnectorsApplication {
}
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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,9 +31,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save