Commit 46021928 authored by Phillip Webb's avatar Phillip Webb

Rework common server customization

Update the configurable embedded web server factory interfaces to
extend `ConfigurableWebServerFactory` so that the can be used in a
`WebServerFactoryCustomizer`.

Extract server specific customization to their own auto-configuration
and align reactive/servlet server auto-configuration.

Closes gh-8573
parent aafa1e96
...@@ -19,10 +19,13 @@ package org.springframework.boot.actuate.autoconfigure.web.reactive; ...@@ -19,10 +19,13 @@ package org.springframework.boot.actuate.autoconfigure.web.reactive;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerFactoryCustomizer; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.web.reactive.DefaultReactiveWebServerFactoryCustomizer; import org.springframework.boot.autoconfigure.web.embedded.JettyWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.TomcatWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryCustomizer;
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -44,9 +47,9 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; ...@@ -44,9 +47,9 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
public class ReactiveManagementChildContextConfiguration { public class ReactiveManagementChildContextConfiguration {
@Bean @Bean
public ReactiveManagementServerFactoryCustomizer reactiveManagementServerFactoryCustomizer( public ReactiveManagementWebServerFactoryCustomizer reactiveManagementWebServerFactoryCustomizer(
ListableBeanFactory beanFactory) { ListableBeanFactory beanFactory) {
return new ReactiveManagementServerFactoryCustomizer(beanFactory); return new ReactiveManagementWebServerFactoryCustomizer(beanFactory);
} }
@Bean @Bean
...@@ -54,11 +57,14 @@ public class ReactiveManagementChildContextConfiguration { ...@@ -54,11 +57,14 @@ public class ReactiveManagementChildContextConfiguration {
return WebHttpHandlerBuilder.applicationContext(applicationContext).build(); return WebHttpHandlerBuilder.applicationContext(applicationContext).build();
} }
class ReactiveManagementServerFactoryCustomizer extends class ReactiveManagementWebServerFactoryCustomizer extends
ManagementServerFactoryCustomizer<ConfigurableReactiveWebServerFactory> { ManagementWebServerFactoryCustomizer<ConfigurableReactiveWebServerFactory> {
ReactiveManagementServerFactoryCustomizer(ListableBeanFactory beanFactory) { ReactiveManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory) {
super(beanFactory, DefaultReactiveWebServerFactoryCustomizer.class); super(beanFactory, ReactiveWebServerFactoryCustomizer.class,
TomcatWebServerFactoryCustomizer.class,
JettyWebServerFactoryCustomizer.class,
UndertowWebServerFactoryCustomizer.class);
} }
} }
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,11 +16,17 @@ ...@@ -16,11 +16,17 @@
package org.springframework.boot.actuate.autoconfigure.web.server; package org.springframework.boot.actuate.autoconfigure.web.server;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.util.LambdaSafe;
import org.springframework.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage; import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.Ssl; import org.springframework.boot.web.server.Ssl;
...@@ -36,17 +42,18 @@ import org.springframework.core.Ordered; ...@@ -36,17 +42,18 @@ import org.springframework.core.Ordered;
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
*/ */
public abstract class ManagementServerFactoryCustomizer<T extends ConfigurableWebServerFactory> public abstract class ManagementWebServerFactoryCustomizer<T extends ConfigurableWebServerFactory>
implements WebServerFactoryCustomizer<T>, Ordered { implements WebServerFactoryCustomizer<T>, Ordered {
private final ListableBeanFactory beanFactory; private final ListableBeanFactory beanFactory;
private final Class<? extends WebServerFactoryCustomizer<T>> customizerClass; private final Class<? extends WebServerFactoryCustomizer<?>>[] customizerClasses;
protected ManagementServerFactoryCustomizer(ListableBeanFactory beanFactory, @SafeVarargs
Class<? extends WebServerFactoryCustomizer<T>> customizerClass) { protected ManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory,
Class<? extends WebServerFactoryCustomizer<?>>... customizerClasses) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
this.customizerClass = customizerClass; this.customizerClasses = customizerClasses;
} }
@Override @Override
...@@ -59,19 +66,42 @@ public abstract class ManagementServerFactoryCustomizer<T extends ConfigurableWe ...@@ -59,19 +66,42 @@ public abstract class ManagementServerFactoryCustomizer<T extends ConfigurableWe
ManagementServerProperties managementServerProperties = BeanFactoryUtils ManagementServerProperties managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory, .beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class); ManagementServerProperties.class);
ServerProperties serverProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory, ServerProperties.class);
WebServerFactoryCustomizer<T> webServerFactoryCustomizer = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory, this.customizerClass);
// Customize as per the parent context first (so e.g. the access logs go to // Customize as per the parent context first (so e.g. the access logs go to
// the same place) // the same place)
webServerFactoryCustomizer.customize(factory); customizeSameAsParentContext(factory);
// Then reset the error pages // Then reset the error pages
factory.setErrorPages(Collections.emptySet()); factory.setErrorPages(Collections.emptySet());
// and add the management-specific bits // and add the management-specific bits
ServerProperties serverProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory, ServerProperties.class);
customize(factory, managementServerProperties, serverProperties); customize(factory, managementServerProperties, serverProperties);
} }
private void customizeSameAsParentContext(T factory) {
List<WebServerFactoryCustomizer<?>> customizers = Arrays
.stream(this.customizerClasses).map(this::getCustomizer)
.filter(Objects::nonNull).collect(Collectors.toList());
invokeCustomizers(factory, customizers);
}
private WebServerFactoryCustomizer<?> getCustomizer(
Class<? extends WebServerFactoryCustomizer<?>> customizerClass) {
try {
return BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory,
customizerClass);
}
catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
@SuppressWarnings("unchecked")
private void invokeCustomizers(T factory,
List<WebServerFactoryCustomizer<?>> customizers) {
LambdaSafe.callbacks(WebServerFactoryCustomizer.class, customizers, factory)
.invoke((customizer) -> customizer.customize(factory));
}
protected void customize(T factory, protected void customize(T factory,
ManagementServerProperties managementServerProperties, ManagementServerProperties managementServerProperties,
ServerProperties serverProperties) { ServerProperties serverProperties) {
......
...@@ -26,15 +26,19 @@ import org.springframework.beans.factory.HierarchicalBeanFactory; ...@@ -26,15 +26,19 @@ import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerFactoryCustomizer;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.DefaultServletWebServerFactoryCustomizer; import org.springframework.boot.autoconfigure.web.embedded.JettyWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.TomcatWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.server.WebServerFactoryCustomizer;
...@@ -61,9 +65,9 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe ...@@ -61,9 +65,9 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
class ServletManagementChildContextConfiguration { class ServletManagementChildContextConfiguration {
@Bean @Bean
public ServletManagementServerFactoryCustomizer serverFactoryCustomizer( public ServletManagementWebServerFactoryCustomizer servletManagementWebServerFactoryCustomizer(
ListableBeanFactory beanFactory) { ListableBeanFactory beanFactory) {
return new ServletManagementServerFactoryCustomizer(beanFactory); return new ServletManagementWebServerFactoryCustomizer(beanFactory);
} }
@Bean @Bean
...@@ -90,11 +94,15 @@ class ServletManagementChildContextConfiguration { ...@@ -90,11 +94,15 @@ class ServletManagementChildContextConfiguration {
} }
static class ServletManagementServerFactoryCustomizer extends static class ServletManagementWebServerFactoryCustomizer extends
ManagementServerFactoryCustomizer<ConfigurableServletWebServerFactory> { ManagementWebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
ServletManagementServerFactoryCustomizer(ListableBeanFactory beanFactory) { ServletManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory) {
super(beanFactory, DefaultServletWebServerFactoryCustomizer.class); super(beanFactory, ServletWebServerFactoryCustomizer.class,
TomcatServletWebServerFactoryCustomizer.class,
TomcatWebServerFactoryCustomizer.class,
JettyWebServerFactoryCustomizer.class,
UndertowWebServerFactoryCustomizer.class);
} }
@Override @Override
......
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.embedded;
import io.undertow.Undertow;
import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.UpgradeProtocol;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.xnio.SslClientAuthMode;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
/**
* {@link EnableAutoConfiguration Auto-configuration} for embedded servlet and reactive
* web servers customizations.
*
* @author Phillip Webb
* @since 2.0.0
*/
@Configuration
@EnableConfigurationProperties(ServerProperties.class)
public class EmbeddedWebServerFactoryCustomizerAutoConfiguration {
@ConditionalOnClass({ Tomcat.class, UpgradeProtocol.class })
public static class TomcatWebServerFactoryCustomizerConfiguration {
@Bean
public TomcatWebServerFactoryCustomizer tomcatWebServerFactoryCustomizer(
Environment environment, ServerProperties serverProperties) {
return new TomcatWebServerFactoryCustomizer(environment, serverProperties);
}
}
/**
* Nested configuration if Jetty is being used.
*/
@Configuration
@ConditionalOnClass({ Server.class, Loader.class, WebAppContext.class })
public static class JettyWebServerFactoryCustomizerConfiguration {
@Bean
public JettyWebServerFactoryCustomizer jettyWebServerFactoryCustomizer(
Environment environment, ServerProperties serverProperties) {
return new JettyWebServerFactoryCustomizer(environment, serverProperties);
}
}
/**
* Nested configuration if Undertow is being used.
*/
@Configuration
@ConditionalOnClass({ Undertow.class, SslClientAuthMode.class })
public static class UndertowWebServerFactoryCustomizerConfiguration {
@Bean
public UndertowWebServerFactoryCustomizer undertowWebServerFactoryCustomizer(
Environment environment, ServerProperties serverProperties) {
return new UndertowWebServerFactoryCustomizer(environment, serverProperties);
}
}
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.embedded.jetty; package org.springframework.boot.autoconfigure.web.embedded;
import java.time.Duration; import java.time.Duration;
...@@ -33,38 +33,53 @@ import org.springframework.boot.cloud.CloudPlatform; ...@@ -33,38 +33,53 @@ import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory; import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer; import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
/** /**
* Customization for Jetty-specific features common for both Servlet and Reactive servers. * Customization for Jetty-specific features common for both Servlet and Reactive servers.
* *
* @author Brian Clozel * @author Brian Clozel
* @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
public final class JettyCustomizer { public class JettyWebServerFactoryCustomizer implements
WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory>, Ordered {
private JettyCustomizer() { private final Environment environment;
private final ServerProperties serverProperties;
public JettyWebServerFactoryCustomizer(Environment environment,
ServerProperties serverProperties) {
this.environment = environment;
this.serverProperties = serverProperties;
}
@Override
public int getOrder() {
return 0;
} }
public static void customizeJetty(ServerProperties serverProperties, @Override
Environment environment, ConfigurableJettyWebServerFactory factory) { public void customize(ConfigurableJettyWebServerFactory factory) {
ServerProperties.Jetty jettyProperties = serverProperties.getJetty(); ServerProperties properties = this.serverProperties;
ServerProperties.Jetty jettyProperties = properties.getJetty();
factory.setUseForwardHeaders( factory.setUseForwardHeaders(
getOrDeduceUseForwardHeaders(serverProperties, environment)); getOrDeduceUseForwardHeaders(properties, this.environment));
PropertyMapper propertyMapper = PropertyMapper.get(); PropertyMapper propertyMapper = PropertyMapper.get();
propertyMapper.from(jettyProperties::getAcceptors).whenNonNull() propertyMapper.from(jettyProperties::getAcceptors).whenNonNull()
.to(factory::setAcceptors); .to(factory::setAcceptors);
propertyMapper.from(jettyProperties::getSelectors).whenNonNull() propertyMapper.from(jettyProperties::getSelectors).whenNonNull()
.to(factory::setSelectors); .to(factory::setSelectors);
propertyMapper.from(serverProperties::getMaxHttpHeaderSize) propertyMapper.from(properties::getMaxHttpHeaderSize).when(this::isPositive)
.when(JettyCustomizer::isPositive)
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory, .to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
maxHttpHeaderSize)); maxHttpHeaderSize));
propertyMapper.from(jettyProperties::getMaxHttpPostSize) propertyMapper.from(jettyProperties::getMaxHttpPostSize).when(this::isPositive)
.when(JettyCustomizer::isPositive)
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory, .to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
maxHttpPostSize)); maxHttpPostSize));
propertyMapper.from(serverProperties::getConnectionTimeout).whenNonNull() propertyMapper.from(properties::getConnectionTimeout).whenNonNull()
.to((connectionTimeout) -> customizeConnectionTimeout(factory, .to((connectionTimeout) -> customizeConnectionTimeout(factory,
connectionTimeout)); connectionTimeout));
propertyMapper.from(jettyProperties::getAccesslog) propertyMapper.from(jettyProperties::getAccesslog)
...@@ -72,11 +87,11 @@ public final class JettyCustomizer { ...@@ -72,11 +87,11 @@ public final class JettyCustomizer {
.to((accesslog) -> customizeAccessLog(factory, accesslog)); .to((accesslog) -> customizeAccessLog(factory, accesslog));
} }
private static boolean isPositive(Integer value) { private boolean isPositive(Integer value) {
return value > 0; return value > 0;
} }
private static boolean getOrDeduceUseForwardHeaders(ServerProperties serverProperties, private boolean getOrDeduceUseForwardHeaders(ServerProperties serverProperties,
Environment environment) { Environment environment) {
if (serverProperties.isUseForwardHeaders() != null) { if (serverProperties.isUseForwardHeaders() != null) {
return serverProperties.isUseForwardHeaders(); return serverProperties.isUseForwardHeaders();
...@@ -85,8 +100,8 @@ public final class JettyCustomizer { ...@@ -85,8 +100,8 @@ public final class JettyCustomizer {
return platform != null && platform.isUsingForwardHeaders(); return platform != null && platform.isUsingForwardHeaders();
} }
private static void customizeConnectionTimeout( private void customizeConnectionTimeout(ConfigurableJettyWebServerFactory factory,
ConfigurableJettyWebServerFactory factory, Duration connectionTimeout) { Duration connectionTimeout) {
factory.addServerCustomizers((server) -> { factory.addServerCustomizers((server) -> {
for (org.eclipse.jetty.server.Connector connector : server.getConnectors()) { for (org.eclipse.jetty.server.Connector connector : server.getConnectors()) {
if (connector instanceof AbstractConnector) { if (connector instanceof AbstractConnector) {
...@@ -97,8 +112,8 @@ public final class JettyCustomizer { ...@@ -97,8 +112,8 @@ public final class JettyCustomizer {
}); });
} }
private static void customizeMaxHttpHeaderSize( private void customizeMaxHttpHeaderSize(ConfigurableJettyWebServerFactory factory,
ConfigurableJettyWebServerFactory factory, int maxHttpHeaderSize) { int maxHttpHeaderSize) {
factory.addServerCustomizers(new JettyServerCustomizer() { factory.addServerCustomizers(new JettyServerCustomizer() {
@Override @Override
...@@ -124,8 +139,8 @@ public final class JettyCustomizer { ...@@ -124,8 +139,8 @@ public final class JettyCustomizer {
}); });
} }
private static void customizeMaxHttpPostSize( private void customizeMaxHttpPostSize(ConfigurableJettyWebServerFactory factory,
ConfigurableJettyWebServerFactory factory, int maxHttpPostSize) { int maxHttpPostSize) {
factory.addServerCustomizers(new JettyServerCustomizer() { factory.addServerCustomizers(new JettyServerCustomizer() {
@Override @Override
...@@ -153,7 +168,7 @@ public final class JettyCustomizer { ...@@ -153,7 +168,7 @@ public final class JettyCustomizer {
}); });
} }
private static void customizeAccessLog(ConfigurableJettyWebServerFactory factory, private void customizeAccessLog(ConfigurableJettyWebServerFactory factory,
ServerProperties.Jetty.Accesslog properties) { ServerProperties.Jetty.Accesslog properties) {
factory.addServerCustomizers((server) -> { factory.addServerCustomizers((server) -> {
NCSARequestLog log = new NCSARequestLog(); NCSARequestLog log = new NCSARequestLog();
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.embedded.undertow; package org.springframework.boot.autoconfigure.web.embedded;
import java.time.Duration; import java.time.Duration;
...@@ -24,6 +24,8 @@ import org.springframework.boot.autoconfigure.web.ServerProperties; ...@@ -24,6 +24,8 @@ import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.cloud.CloudPlatform; import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory; import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
/** /**
...@@ -33,15 +35,31 @@ import org.springframework.core.env.Environment; ...@@ -33,15 +35,31 @@ import org.springframework.core.env.Environment;
* @author Brian Clozel * @author Brian Clozel
* @author Yulin Qin * @author Yulin Qin
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Phillip Webb
* @since 2.0.0
*/ */
public final class UndertowCustomizer { public class UndertowWebServerFactoryCustomizer implements
WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory>, Ordered {
private UndertowCustomizer() { private final Environment environment;
private final ServerProperties serverProperties;
public UndertowWebServerFactoryCustomizer(Environment environment,
ServerProperties serverProperties) {
this.environment = environment;
this.serverProperties = serverProperties;
}
@Override
public int getOrder() {
return 0;
} }
public static void customizeUndertow(ServerProperties serverProperties, @Override
Environment environment, ConfigurableUndertowWebServerFactory factory) { public void customize(ConfigurableUndertowWebServerFactory factory) {
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow(); ServerProperties properties = this.serverProperties;
ServerProperties.Undertow undertowProperties = properties.getUndertow();
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
.getAccesslog(); .getAccesslog();
PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
...@@ -63,52 +81,48 @@ public final class UndertowCustomizer { ...@@ -63,52 +81,48 @@ public final class UndertowCustomizer {
.to(factory::setAccessLogSuffix); .to(factory::setAccessLogSuffix);
propertyMapper.from(accesslogProperties::isRotate) propertyMapper.from(accesslogProperties::isRotate)
.to(factory::setAccessLogRotate); .to(factory::setAccessLogRotate);
propertyMapper propertyMapper.from(() -> getOrDeduceUseForwardHeaders())
.from(() -> getOrDeduceUseForwardHeaders(serverProperties, environment))
.to(factory::setUseForwardHeaders); .to(factory::setUseForwardHeaders);
propertyMapper.from(serverProperties::getMaxHttpHeaderSize) propertyMapper.from(properties::getMaxHttpHeaderSize).when(this::isPositive)
.when(UndertowCustomizer::isPositive)
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory, .to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
maxHttpHeaderSize)); maxHttpHeaderSize));
propertyMapper.from(undertowProperties::getMaxHttpPostSize) propertyMapper.from(undertowProperties::getMaxHttpPostSize).when(this::isPositive)
.when(UndertowCustomizer::isPositive)
.to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory, .to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory,
maxHttpPostSize)); maxHttpPostSize));
propertyMapper.from(serverProperties::getConnectionTimeout) propertyMapper.from(properties::getConnectionTimeout)
.to((connectionTimeout) -> customizeConnectionTimeout(factory, .to((connectionTimeout) -> customizeConnectionTimeout(factory,
connectionTimeout)); connectionTimeout));
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo
.setEagerFilterInit(undertowProperties.isEagerFilterInit())); .setEagerFilterInit(undertowProperties.isEagerFilterInit()));
} }
private static boolean isPositive(Number value) { private boolean isPositive(Number value) {
return value.longValue() > 0; return value.longValue() > 0;
} }
private static void customizeConnectionTimeout( private void customizeConnectionTimeout(ConfigurableUndertowWebServerFactory factory,
ConfigurableUndertowWebServerFactory factory, Duration connectionTimeout) { Duration connectionTimeout) {
factory.addBuilderCustomizers((builder) -> builder.setSocketOption( factory.addBuilderCustomizers((builder) -> builder.setSocketOption(
UndertowOptions.NO_REQUEST_TIMEOUT, (int) connectionTimeout.toMillis())); UndertowOptions.NO_REQUEST_TIMEOUT, (int) connectionTimeout.toMillis()));
} }
private static void customizeMaxHttpHeaderSize( private void customizeMaxHttpHeaderSize(ConfigurableUndertowWebServerFactory factory,
ConfigurableUndertowWebServerFactory factory, int maxHttpHeaderSize) { int maxHttpHeaderSize) {
factory.addBuilderCustomizers((builder) -> builder factory.addBuilderCustomizers((builder) -> builder
.setServerOption(UndertowOptions.MAX_HEADER_SIZE, maxHttpHeaderSize)); .setServerOption(UndertowOptions.MAX_HEADER_SIZE, maxHttpHeaderSize));
} }
private static void customizeMaxHttpPostSize( private void customizeMaxHttpPostSize(ConfigurableUndertowWebServerFactory factory,
ConfigurableUndertowWebServerFactory factory, long maxHttpPostSize) { long maxHttpPostSize) {
factory.addBuilderCustomizers((builder) -> builder factory.addBuilderCustomizers((builder) -> builder
.setServerOption(UndertowOptions.MAX_ENTITY_SIZE, maxHttpPostSize)); .setServerOption(UndertowOptions.MAX_ENTITY_SIZE, maxHttpPostSize));
} }
private static boolean getOrDeduceUseForwardHeaders(ServerProperties serverProperties, private boolean getOrDeduceUseForwardHeaders() {
Environment environment) { if (this.serverProperties.isUseForwardHeaders() != null) {
if (serverProperties.isUseForwardHeaders() != null) { return this.serverProperties.isUseForwardHeaders();
return serverProperties.isUseForwardHeaders();
} }
CloudPlatform platform = CloudPlatform.getActive(environment); CloudPlatform platform = CloudPlatform.getActive(this.environment);
return platform != null && platform.isUsingForwardHeaders(); return platform != null && platform.isUsingForwardHeaders();
} }
......
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Configuration for embedded reactive and servlet Jetty web servers.
*
* @see org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory
*/
package org.springframework.boot.autoconfigure.web.embedded.jetty;
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
*/ */
/** /**
* Support classes for the auto-configuration of embedded Undertow. * Configuration for embedded reactive and servlet web servers.
*/ */
package org.springframework.boot.autoconfigure.web.embedded.undertow; package org.springframework.boot.autoconfigure.web.embedded;
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Configuration for embedded reactive and servlet Tomcat web servers.
*
* @see org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory
*/
package org.springframework.boot.autoconfigure.web.embedded.tomcat;
...@@ -25,7 +25,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition; ...@@ -25,7 +25,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 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;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
...@@ -51,17 +50,16 @@ import org.springframework.util.ObjectUtils; ...@@ -51,17 +50,16 @@ import org.springframework.util.ObjectUtils;
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@EnableConfigurationProperties(ServerProperties.class) @EnableConfigurationProperties(ServerProperties.class)
@Import({ ReactiveWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar.class, @Import({ ReactiveWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar.class,
ReactiveWebServerFactoryConfiguration.TomcatConfiguration.class, ReactiveWebServerFactoryConfiguration.EmbeddedNetty.class,
ReactiveWebServerFactoryConfiguration.JettyConfiguration.class, ReactiveWebServerFactoryConfiguration.EmbeddedTomcat.class,
ReactiveWebServerFactoryConfiguration.UndertowConfiguration.class, ReactiveWebServerFactoryConfiguration.EmbeddedJetty.class,
ReactiveWebServerFactoryConfiguration.ReactorNettyConfiguration.class }) ReactiveWebServerFactoryConfiguration.EmbeddedUndertow.class })
public class ReactiveWebServerFactoryAutoConfiguration { public class ReactiveWebServerFactoryAutoConfiguration {
@ConditionalOnMissingBean
@Bean @Bean
public DefaultReactiveWebServerFactoryCustomizer defaultReactiveWebServerCustomizer( public ReactiveWebServerFactoryCustomizer reactiveWebServerFactoryCustomizer(
ServerProperties serverProperties) { ServerProperties serverProperties) {
return new DefaultReactiveWebServerFactoryCustomizer(serverProperties); return new ReactiveWebServerFactoryCustomizer(serverProperties);
} }
/** /**
...@@ -86,14 +84,18 @@ public class ReactiveWebServerFactoryAutoConfiguration { ...@@ -86,14 +84,18 @@ public class ReactiveWebServerFactoryAutoConfiguration {
if (this.beanFactory == null) { if (this.beanFactory == null) {
return; return;
} }
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType( registerSyntheticBeanIfMissing(registry,
WebServerFactoryCustomizerBeanPostProcessor.class, true, false))) { "webServerFactoryCustomizerBeanPostProcessor",
RootBeanDefinition beanDefinition = new RootBeanDefinition( WebServerFactoryCustomizerBeanPostProcessor.class);
WebServerFactoryCustomizerBeanPostProcessor.class); }
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(
"webServerFactoryCustomizerBeanPostProcessor", beanDefinition);
private void registerSyntheticBeanIfMissing(BeanDefinitionRegistry registry,
String name, Class<?> beanClass) {
if (ObjectUtils.isEmpty(
this.beanFactory.getBeanNamesForType(beanClass, true, false))) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(name, beanDefinition);
} }
} }
......
...@@ -27,6 +27,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFacto ...@@ -27,6 +27,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFacto
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory; import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/** /**
* Configuration classes for reactive web servers * Configuration classes for reactive web servers
...@@ -38,9 +39,10 @@ import org.springframework.context.annotation.Bean; ...@@ -38,9 +39,10 @@ import org.springframework.context.annotation.Bean;
*/ */
abstract class ReactiveWebServerFactoryConfiguration { abstract class ReactiveWebServerFactoryConfiguration {
@Configuration
@ConditionalOnMissingBean(ReactiveWebServerFactory.class) @ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({ HttpServer.class }) @ConditionalOnClass({ HttpServer.class })
static class ReactorNettyConfiguration { static class EmbeddedNetty {
@Bean @Bean
public NettyReactiveWebServerFactory NettyReactiveWebServerFactory() { public NettyReactiveWebServerFactory NettyReactiveWebServerFactory() {
...@@ -49,9 +51,10 @@ abstract class ReactiveWebServerFactoryConfiguration { ...@@ -49,9 +51,10 @@ abstract class ReactiveWebServerFactoryConfiguration {
} }
@Configuration
@ConditionalOnMissingBean(ReactiveWebServerFactory.class) @ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({ org.apache.catalina.startup.Tomcat.class }) @ConditionalOnClass({ org.apache.catalina.startup.Tomcat.class })
static class TomcatConfiguration { static class EmbeddedTomcat {
@Bean @Bean
public TomcatReactiveWebServerFactory tomcatReactiveWebServerFactory() { public TomcatReactiveWebServerFactory tomcatReactiveWebServerFactory() {
...@@ -60,9 +63,10 @@ abstract class ReactiveWebServerFactoryConfiguration { ...@@ -60,9 +63,10 @@ abstract class ReactiveWebServerFactoryConfiguration {
} }
@Configuration
@ConditionalOnMissingBean(ReactiveWebServerFactory.class) @ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({ org.eclipse.jetty.server.Server.class }) @ConditionalOnClass({ org.eclipse.jetty.server.Server.class })
static class JettyConfiguration { static class EmbeddedJetty {
@Bean @Bean
public JettyReactiveWebServerFactory jettyReactiveWebServerFactory() { public JettyReactiveWebServerFactory jettyReactiveWebServerFactory() {
...@@ -73,7 +77,7 @@ abstract class ReactiveWebServerFactoryConfiguration { ...@@ -73,7 +77,7 @@ abstract class ReactiveWebServerFactoryConfiguration {
@ConditionalOnMissingBean(ReactiveWebServerFactory.class) @ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({ Undertow.class }) @ConditionalOnClass({ Undertow.class })
static class UndertowConfiguration { static class EmbeddedUndertow {
@Bean @Bean
public UndertowReactiveWebServerFactory undertowReactiveWebServerFactory() { public UndertowReactiveWebServerFactory undertowReactiveWebServerFactory() {
......
...@@ -17,35 +17,25 @@ ...@@ -17,35 +17,25 @@
package org.springframework.boot.autoconfigure.web.reactive; package org.springframework.boot.autoconfigure.web.reactive;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.embedded.jetty.JettyCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.tomcat.TomcatCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.undertow.UndertowCustomizer;
import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
/** /**
* Default {@link WebServerFactoryCustomizer} for reactive servers. * {@link WebServerFactoryCustomizer} to apply {@link ServerProperties} to reactive
* servers.
* *
* @author Brian Clozel * @author Brian Clozel
* @author Yunkun Huang * @author Yunkun Huang
* @since 2.0.0 * @since 2.0.0
*/ */
public class DefaultReactiveWebServerFactoryCustomizer public class ReactiveWebServerFactoryCustomizer implements
implements WebServerFactoryCustomizer<ConfigurableReactiveWebServerFactory>, WebServerFactoryCustomizer<ConfigurableReactiveWebServerFactory>, Ordered {
EnvironmentAware, Ordered {
private final ServerProperties serverProperties; private final ServerProperties serverProperties;
private Environment environment; public ReactiveWebServerFactoryCustomizer(ServerProperties serverProperties) {
public DefaultReactiveWebServerFactoryCustomizer(ServerProperties serverProperties) {
this.serverProperties = serverProperties; this.serverProperties = serverProperties;
} }
...@@ -54,11 +44,6 @@ public class DefaultReactiveWebServerFactoryCustomizer ...@@ -54,11 +44,6 @@ public class DefaultReactiveWebServerFactoryCustomizer
return 0; return 0;
} }
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
@Override @Override
public void customize(ConfigurableReactiveWebServerFactory factory) { public void customize(ConfigurableReactiveWebServerFactory factory) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
...@@ -67,15 +52,6 @@ public class DefaultReactiveWebServerFactoryCustomizer ...@@ -67,15 +52,6 @@ public class DefaultReactiveWebServerFactoryCustomizer
map.from(this.serverProperties::getSsl).to(factory::setSsl); map.from(this.serverProperties::getSsl).to(factory::setSsl);
map.from(this.serverProperties::getCompression).to(factory::setCompression); map.from(this.serverProperties::getCompression).to(factory::setCompression);
map.from(this.serverProperties::getHttp2).to(factory::setHttp2); map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
map.from(() -> factory).whenInstanceOf(TomcatReactiveWebServerFactory.class).to(
(tomcatFactory) -> TomcatCustomizer.customizeTomcat(this.serverProperties,
this.environment, tomcatFactory));
map.from(() -> factory).whenInstanceOf(JettyReactiveWebServerFactory.class).to(
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
this.environment, jettyFactory));
map.from(() -> factory).whenInstanceOf(UndertowReactiveWebServerFactory.class)
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
this.serverProperties, this.environment, undertowFactory));
} }
} }
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,17 +16,8 @@ ...@@ -16,17 +16,8 @@
package org.springframework.boot.autoconfigure.web.servlet; package org.springframework.boot.autoconfigure.web.servlet;
import javax.servlet.Servlet;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import io.undertow.Undertow;
import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.UpgradeProtocol;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.xnio.SslClientAuthMode;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
...@@ -36,19 +27,12 @@ import org.springframework.beans.factory.support.RootBeanDefinition; ...@@ -36,19 +27,12 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 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;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
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.server.ErrorPageRegistrarBeanPostProcessor;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor; import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
...@@ -66,65 +50,28 @@ import org.springframework.util.ObjectUtils; ...@@ -66,65 +50,28 @@ import org.springframework.util.ObjectUtils;
* @author Brian Clozel * @author Brian Clozel
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Configuration @Configuration
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnClass(ServletRequest.class) @ConditionalOnClass(ServletRequest.class)
@ConditionalOnWebApplication(type = Type.SERVLET) @ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(ServerProperties.class) @EnableConfigurationProperties(ServerProperties.class)
@Import(BeanPostProcessorsRegistrar.class) @Import({ ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar.class,
ServletWebServerFactoryConfiguration.EmbeddedTomcat.class,
ServletWebServerFactoryConfiguration.EmbeddedJetty.class,
ServletWebServerFactoryConfiguration.EmbeddedUndertow.class })
public class ServletWebServerFactoryAutoConfiguration { public class ServletWebServerFactoryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean public ServletWebServerFactoryCustomizer servletWebServerFactoryCustomizer(
public DefaultServletWebServerFactoryCustomizer serverPropertiesWebServerFactoryCustomizer(
ServerProperties serverProperties) { ServerProperties serverProperties) {
return new DefaultServletWebServerFactoryCustomizer(serverProperties); return new ServletWebServerFactoryCustomizer(serverProperties);
}
/**
* Nested configuration if Tomcat is being used.
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Tomcat.class, UpgradeProtocol.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedTomcat {
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
return new TomcatServletWebServerFactory();
}
}
/**
* Nested configuration if Jetty is being used.
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
WebAppContext.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedJetty {
@Bean
public JettyServletWebServerFactory JettyServletWebServerFactory() {
return new JettyServletWebServerFactory();
}
} }
/** @Bean
* Nested configuration if Undertow is being used. @ConditionalOnClass(name = "org.apache.catalina.startup.Tomcat")
*/ public TomcatServletWebServerFactoryCustomizer tomcatServletWebServerFactoryCustomizer(
@Configuration ServerProperties serverProperties) {
@ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class }) return new TomcatServletWebServerFactoryCustomizer(serverProperties);
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedUndertow {
@Bean
public UndertowServletWebServerFactory undertowServletWebServerFactory() {
return new UndertowServletWebServerFactory();
}
} }
/** /**
......
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import javax.servlet.Servlet;
import io.undertow.Undertow;
import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.UpgradeProtocol;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.xnio.SslClientAuthMode;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
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.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Configuration classes for servlet web servers
* <p>
* Those should be {@code @Import} in a regular auto-configuration class to guarantee
* their order of execution.
*
* @author Phillip Webb
* @author Dave Syer
* @author Ivan Sopov
* @author Brian Clozel
* @author Stephane Nicoll
*/
class ServletWebServerFactoryConfiguration {
@Configuration
@ConditionalOnClass({ Servlet.class, Tomcat.class, UpgradeProtocol.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedTomcat {
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
return new TomcatServletWebServerFactory();
}
}
/**
* Nested configuration if Jetty is being used.
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
WebAppContext.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedJetty {
@Bean
public JettyServletWebServerFactory JettyServletWebServerFactory() {
return new JettyServletWebServerFactory();
}
}
/**
* Nested configuration if Undertow is being used.
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedUndertow {
@Bean
public UndertowServletWebServerFactory undertowServletWebServerFactory() {
return new UndertowServletWebServerFactory();
}
}
}
...@@ -17,23 +17,14 @@ ...@@ -17,23 +17,14 @@
package org.springframework.boot.autoconfigure.web.servlet; package org.springframework.boot.autoconfigure.web.servlet;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.embedded.jetty.JettyCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.tomcat.TomcatCustomizer;
import org.springframework.boot.autoconfigure.web.embedded.undertow.UndertowCustomizer;
import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
import org.springframework.util.ObjectUtils;
/** /**
* Default {@link WebServerFactoryCustomizer} for {@link ServerProperties}. * {@link WebServerFactoryCustomizer} to apply {@link ServerProperties} to servlet web
* servers.
* *
* @author Brian Clozel * @author Brian Clozel
* @author Stephane Nicoll * @author Stephane Nicoll
...@@ -41,32 +32,20 @@ import org.springframework.util.ObjectUtils; ...@@ -41,32 +32,20 @@ import org.springframework.util.ObjectUtils;
* @author Yunkun Huang * @author Yunkun Huang
* @since 2.0.0 * @since 2.0.0
*/ */
public class DefaultServletWebServerFactoryCustomizer public class ServletWebServerFactoryCustomizer implements
implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>, WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>, Ordered {
EnvironmentAware, Ordered {
private final ServerProperties serverProperties; private final ServerProperties serverProperties;
private Environment environment; public ServletWebServerFactoryCustomizer(ServerProperties serverProperties) {
public DefaultServletWebServerFactoryCustomizer(ServerProperties serverProperties) {
this.serverProperties = serverProperties; this.serverProperties = serverProperties;
} }
public void setLoader(String value) {
// no op to support Tomcat running as a traditional server (not embedded)
}
@Override @Override
public int getOrder() { public int getOrder() {
return 0; return 0;
} }
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
@Override @Override
public void customize(ConfigurableServletWebServerFactory factory) { public void customize(ConfigurableServletWebServerFactory factory) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
...@@ -83,54 +62,8 @@ public class DefaultServletWebServerFactoryCustomizer ...@@ -83,54 +62,8 @@ public class DefaultServletWebServerFactoryCustomizer
map.from(this.serverProperties::getCompression).to(factory::setCompression); map.from(this.serverProperties::getCompression).to(factory::setCompression);
map.from(this.serverProperties::getHttp2).to(factory::setHttp2); map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader); map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader);
map.from(() -> factory).whenInstanceOf(TomcatServletWebServerFactory.class)
.to((tomcatFactory) -> {
TomcatCustomizer.customizeTomcat(this.serverProperties,
this.environment, tomcatFactory);
TomcatServletCustomizer.customizeTomcat(this.serverProperties,
this.environment, tomcatFactory);
});
map.from(() -> factory).whenInstanceOf(JettyServletWebServerFactory.class).to(
(jettyFactory) -> JettyCustomizer.customizeJetty(this.serverProperties,
this.environment, jettyFactory));
map.from(() -> factory).whenInstanceOf(UndertowServletWebServerFactory.class)
.to((undertowFactory) -> UndertowCustomizer.customizeUndertow(
this.serverProperties, this.environment, undertowFactory));
map.from(this.serverProperties.getServlet()::getContextParameters) map.from(this.serverProperties.getServlet()::getContextParameters)
.to(factory::setInitParameters); .to(factory::setInitParameters);
} }
private static class TomcatServletCustomizer {
public static void customizeTomcat(ServerProperties serverProperties,
Environment environment, TomcatServletWebServerFactory factory) {
ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();
if (!ObjectUtils.isEmpty(tomcatProperties.getAdditionalTldSkipPatterns())) {
factory.getTldSkipPatterns()
.addAll(tomcatProperties.getAdditionalTldSkipPatterns());
}
if (tomcatProperties.getRedirectContextRoot() != null) {
customizeRedirectContextRoot(factory,
tomcatProperties.getRedirectContextRoot());
}
if (tomcatProperties.getUseRelativeRedirects() != null) {
customizeUseRelativeRedirects(factory,
tomcatProperties.getUseRelativeRedirects());
}
}
private static void customizeRedirectContextRoot(
ConfigurableTomcatWebServerFactory factory, boolean redirectContextRoot) {
factory.addContextCustomizers((context) -> context
.setMapperContextRootRedirectEnabled(redirectContextRoot));
}
private static void customizeUseRelativeRedirects(
ConfigurableTomcatWebServerFactory factory,
boolean useRelativeRedirects) {
factory.addContextCustomizers(
(context) -> context.setUseRelativeRedirects(useRelativeRedirects));
}
}
} }
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.core.Ordered;
import org.springframework.util.ObjectUtils;
/**
* {@link WebServerFactoryCustomizer} to apply {@link ServerProperties} to Tomcat web
* servers.
*
* @author Brian Clozel
* @author Phillip Webb
* @since 2.0.0
*/
public class TomcatServletWebServerFactoryCustomizer
implements WebServerFactoryCustomizer<TomcatServletWebServerFactory>, Ordered {
private final ServerProperties serverProperties;
public TomcatServletWebServerFactoryCustomizer(ServerProperties serverProperties) {
this.serverProperties = serverProperties;
}
@Override
public int getOrder() {
return 0;
}
@Override
public void customize(TomcatServletWebServerFactory factory) {
ServerProperties.Tomcat tomcatProperties = this.serverProperties.getTomcat();
if (!ObjectUtils.isEmpty(tomcatProperties.getAdditionalTldSkipPatterns())) {
factory.getTldSkipPatterns()
.addAll(tomcatProperties.getAdditionalTldSkipPatterns());
}
if (tomcatProperties.getRedirectContextRoot() != null) {
customizeRedirectContextRoot(factory,
tomcatProperties.getRedirectContextRoot());
}
if (tomcatProperties.getUseRelativeRedirects() != null) {
customizeUseRelativeRedirects(factory,
tomcatProperties.getUseRelativeRedirects());
}
}
private void customizeRedirectContextRoot(ConfigurableTomcatWebServerFactory factory,
boolean redirectContextRoot) {
factory.addContextCustomizers((context) -> context
.setMapperContextRootRedirectEnabled(redirectContextRoot));
}
private void customizeUseRelativeRedirects(ConfigurableTomcatWebServerFactory factory,
boolean useRelativeRedirects) {
factory.addContextCustomizers(
(context) -> context.setUseRelativeRedirects(useRelativeRedirects));
}
}
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl ...@@ -30,7 +30,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* to choose from redundant MVC components. * to choose from redundant MVC components.
* *
* @author Brian Clozel * @author Brian Clozel
* @since 1.4.0 * @since 2.0.0
* @see org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.EnableWebMvcConfiguration * @see org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.EnableWebMvcConfiguration
*/ */
public interface WebMvcRegistrations { public interface WebMvcRegistrations {
......
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
/**
* An implementation of {@link WebMvcRegistrations} with empty methods allowing
* sub-classes to override only the methods they're interested in.
*
* @author Brian Clozel
* @since 1.4.0
* @deprecated as of 2.0.0 {@link WebMvcRegistrations} has default methods (made possible
* by a Java 8 baseline) and can be implemented directly without the need for this adapter
*/
@Deprecated
public class WebMvcRegistrationsAdapter implements WebMvcRegistrations {
}
...@@ -110,6 +110,7 @@ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, ...@@ -110,6 +110,7 @@ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\ org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\ org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\ org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration,\ org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,\ org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\ org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\
......
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.embedded;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.TimeZone;
import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.RequestLog;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyWebServer;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link JettyWebServerFactoryCustomizer}.
*
* @author Brian Clozel
* @author Phillip Webb
*/
public class JettyWebServerFactoryCustomizerTests {
private MockEnvironment environment;
private ServerProperties serverProperties;
private JettyWebServerFactoryCustomizer customizer;
@Before
public void setup() {
this.environment = new MockEnvironment();
this.serverProperties = new ServerProperties();
ConfigurationPropertySources.attach(this.environment);
this.customizer = new JettyWebServerFactoryCustomizer(this.environment,
this.serverProperties);
}
@Test
public void deduceUseForwardHeaders() {
this.environment.setProperty("DYNO", "-");
ConfigurableJettyWebServerFactory factory = mock(
ConfigurableJettyWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void defaultUseForwardHeaders() {
ConfigurableJettyWebServerFactory factory = mock(
ConfigurableJettyWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(false);
}
@Test
public void accessLogCanBeCustomized() throws IOException {
File logFile = File.createTempFile("jetty_log", ".log");
String timezone = TimeZone.getDefault().getID();
bind("server.jetty.accesslog.enabled=true",
"server.jetty.accesslog.filename=" + logFile.getAbsolutePath(),
"server.jetty.accesslog.file-date-format=yyyy-MM-dd",
"server.jetty.accesslog.retention-period=42",
"server.jetty.accesslog.append=true",
"server.jetty.accesslog.extended-format=true",
"server.jetty.accesslog.date-format=HH:mm:ss",
"server.jetty.accesslog.locale=en_BE",
"server.jetty.accesslog.time-zone=" + timezone,
"server.jetty.accesslog.log-cookies=true",
"server.jetty.accesslog.log-server=true",
"server.jetty.accesslog.log-latency=true");
JettyWebServer server = customizeAndGetServer();
NCSARequestLog requestLog = getNCSARequestLog(server);
assertThat(requestLog.getFilename()).isEqualTo(logFile.getAbsolutePath());
assertThat(requestLog.getFilenameDateFormat()).isEqualTo("yyyy-MM-dd");
assertThat(requestLog.getRetainDays()).isEqualTo(42);
assertThat(requestLog.isAppend()).isTrue();
assertThat(requestLog.isExtended()).isTrue();
assertThat(requestLog.getLogDateFormat()).isEqualTo("HH:mm:ss");
assertThat(requestLog.getLogLocale()).isEqualTo(new Locale("en", "BE"));
assertThat(requestLog.getLogTimeZone()).isEqualTo(timezone);
assertThat(requestLog.getLogCookies()).isTrue();
assertThat(requestLog.getLogServer()).isTrue();
assertThat(requestLog.getLogLatency()).isTrue();
}
@Test
public void accessLogCanBeEnabled() {
bind("server.jetty.accesslog.enabled=true");
JettyWebServer server = customizeAndGetServer();
NCSARequestLog requestLog = getNCSARequestLog(server);
assertThat(requestLog.getFilename()).isNull();
assertThat(requestLog.isAppend()).isFalse();
assertThat(requestLog.isExtended()).isFalse();
assertThat(requestLog.getLogCookies()).isFalse();
assertThat(requestLog.getLogServer()).isFalse();
assertThat(requestLog.getLogLatency()).isFalse();
}
private NCSARequestLog getNCSARequestLog(JettyWebServer server) {
RequestLog requestLog = server.getServer().getRequestLog();
assertThat(requestLog).isInstanceOf(NCSARequestLog.class);
return (NCSARequestLog) requestLog;
}
@Test
public void setUseForwardHeaders() {
this.serverProperties.setUseForwardHeaders(true);
ConfigurableJettyWebServerFactory factory = mock(
ConfigurableJettyWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
private void bind(String... inlinedProperties) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
inlinedProperties);
new Binder(ConfigurationPropertySources.get(this.environment)).bind("server",
Bindable.ofInstance(this.serverProperties));
}
private JettyWebServer customizeAndGetServer() {
JettyServletWebServerFactory factory = customizeAndGetFactory();
return (JettyWebServer) factory.getWebServer();
}
private JettyServletWebServerFactory customizeAndGetFactory() {
JettyServletWebServerFactory factory = new JettyServletWebServerFactory(0);
this.customizer.customize(factory);
return factory;
}
}
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.embedded;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link UndertowWebServerFactoryCustomizer}.
*
* @author Brian Clozel
* @author Phillip Webb
*/
public class UndertowWebServerFactoryCustomizerTests {
private MockEnvironment environment;
private ServerProperties serverProperties;
private UndertowWebServerFactoryCustomizer customizer;
@Before
public void setup() {
this.environment = new MockEnvironment();
this.serverProperties = new ServerProperties();
ConfigurationPropertySources.attach(this.environment);
this.customizer = new UndertowWebServerFactoryCustomizer(this.environment,
this.serverProperties);
}
@Test
public void customizeUndertowAccessLog() {
bind("server.undertow.accesslog.enabled=true",
"server.undertow.accesslog.pattern=foo",
"server.undertow.accesslog.prefix=test_log",
"server.undertow.accesslog.suffix=txt",
"server.undertow.accesslog.dir=test-logs",
"server.undertow.accesslog.rotate=false");
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
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
public void deduceUseForwardHeadersUndertow() {
this.environment.setProperty("DYNO", "-");
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void defaultUseForwardHeadersUndertow() {
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(false);
}
@Test
public void setUseForwardHeadersUndertow() {
this.serverProperties.setUseForwardHeaders(true);
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setUseForwardHeaders(true);
}
@Test
public void skipNullElementsForUndertow() {
ConfigurableUndertowWebServerFactory factory = mock(
ConfigurableUndertowWebServerFactory.class);
this.customizer.customize(factory);
verify(factory, never()).setAccessLogEnabled(anyBoolean());
}
private void bind(String... inlinedProperties) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
inlinedProperties);
new Binder(ConfigurationPropertySources.get(this.environment)).bind("server",
Bindable.ofInstance(this.serverProperties));
}
}
...@@ -55,7 +55,7 @@ public class ReactiveWebServerFactoryAutoConfigurationTests { ...@@ -55,7 +55,7 @@ public class ReactiveWebServerFactoryAutoConfigurationTests {
assertThat(this.context.getBeansOfType(WebServerFactoryCustomizer.class)) assertThat(this.context.getBeansOfType(WebServerFactoryCustomizer.class))
.hasSize(1); .hasSize(1);
assertThat(this.context assertThat(this.context
.getBeansOfType(DefaultReactiveWebServerFactoryCustomizer.class)) .getBeansOfType(ReactiveWebServerFactoryCustomizer.class))
.hasSize(1); .hasSize(1);
} }
......
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.reactive;
import java.net.InetAddress;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
import org.springframework.boot.web.server.Ssl;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link ReactiveWebServerFactoryCustomizer}.
*
* @author Brian Clozel
* @author Yunkun Huang
*/
public class ReactiveWebServerFactoryCustomizerTests {
private ServerProperties properties = new ServerProperties();
private ReactiveWebServerFactoryCustomizer customizer;
@Before
public void setup() {
this.customizer = new ReactiveWebServerFactoryCustomizer(
this.properties);
}
@Test
public void testCustomizeServerPort() {
ConfigurableReactiveWebServerFactory factory = mock(
ConfigurableReactiveWebServerFactory.class);
this.properties.setPort(9000);
this.customizer.customize(factory);
verify(factory).setPort(9000);
}
@Test
public void testCustomizeServerAddress() {
ConfigurableReactiveWebServerFactory factory = mock(
ConfigurableReactiveWebServerFactory.class);
InetAddress address = mock(InetAddress.class);
this.properties.setAddress(address);
this.customizer.customize(factory);
verify(factory).setAddress(address);
}
@Test
public void testCustomizeServerSsl() {
ConfigurableReactiveWebServerFactory factory = mock(
ConfigurableReactiveWebServerFactory.class);
Ssl ssl = mock(Ssl.class);
this.properties.setSsl(ssl);
this.customizer.customize(factory);
verify(factory).setSsl(ssl);
}
}
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import java.io.File;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.Jsp;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.boot.web.servlet.server.Session.Cookie;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link ServletWebServerFactoryCustomizer}.
*
* @author Brian Clozel
* @author Yunkun Huang
*/
public class ServletWebServerFactoryCustomizerTests {
private final ServerProperties properties = new ServerProperties();
private ServletWebServerFactoryCustomizer customizer;
@Captor
private ArgumentCaptor<ServletContextInitializer[]> initializersCaptor;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
this.customizer = new ServletWebServerFactoryCustomizer(
this.properties);
}
@Test
public void testDefaultDisplayName() {
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setDisplayName("application");
}
@Test
public void testCustomizeDisplayName() {
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.properties.getServlet().setApplicationDisplayName("TestName");
this.customizer.customize(factory);
verify(factory).setDisplayName("TestName");
}
@Test
public void testCustomizeSsl() {
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
Ssl ssl = mock(Ssl.class);
this.properties.setSsl(ssl);
this.customizer.customize(factory);
verify(factory).setSsl(ssl);
}
@Test
public void testCustomizeJsp() {
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setJsp(any(Jsp.class));
}
@Test
public void customizeSessionProperties() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.timeout", "123");
map.put("server.servlet.session.tracking-modes", "cookie,url");
map.put("server.servlet.session.cookie.name", "testname");
map.put("server.servlet.session.cookie.domain", "testdomain");
map.put("server.servlet.session.cookie.path", "/testpath");
map.put("server.servlet.session.cookie.comment", "testcomment");
map.put("server.servlet.session.cookie.http-only", "true");
map.put("server.servlet.session.cookie.secure", "true");
map.put("server.servlet.session.cookie.max-age", "60");
bindProperties(map);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
ArgumentCaptor<Session> sessionCaptor = ArgumentCaptor.forClass(Session.class);
verify(factory).setSession(sessionCaptor.capture());
assertThat(sessionCaptor.getValue().getTimeout())
.isEqualTo(Duration.ofSeconds(123));
Cookie cookie = sessionCaptor.getValue().getCookie();
assertThat(cookie.getName()).isEqualTo("testname");
assertThat(cookie.getDomain()).isEqualTo("testdomain");
assertThat(cookie.getPath()).isEqualTo("/testpath");
assertThat(cookie.getComment()).isEqualTo("testcomment");
assertThat(cookie.getHttpOnly()).isTrue();
assertThat(cookie.getMaxAge()).isEqualTo(Duration.ofSeconds(60));
}
@Test
public void testCustomizeTomcatPort() {
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.properties.setPort(8080);
this.customizer.customize(factory);
verify(factory).setPort(8080);
}
@Test
public void customizeServletDisplayName() {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.application-display-name", "MyBootApp");
bindProperties(map);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setDisplayName("MyBootApp");
}
@Test
public void testCustomizeTomcatMinSpareThreads() {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.min-spare-threads", "10");
bindProperties(map);
assertThat(this.properties.getTomcat().getMinSpareThreads()).isEqualTo(10);
}
@Test
public void sessionStoreDir() {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.store-dir", "myfolder");
bindProperties(map);
ConfigurableServletWebServerFactory factory = mock(
ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
ArgumentCaptor<Session> sessionCaptor = ArgumentCaptor.forClass(Session.class);
verify(factory).setSession(sessionCaptor.capture());
assertThat(sessionCaptor.getValue().getStoreDir())
.isEqualTo(new File("myfolder"));
}
private void bindProperties(Map<String, String> map) {
ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
}
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import org.apache.catalina.Context;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link TomcatServletWebServerFactoryCustomizer}.
*
* @author Phillip Webb
*/
public class TomcatServletWebServerFactoryCustomizerTests {
private TomcatServletWebServerFactoryCustomizer customizer;
private MockEnvironment environment;
private ServerProperties serverProperties;
@Before
public void setup() {
this.environment = new MockEnvironment();
this.serverProperties = new ServerProperties();
ConfigurationPropertySources.attach(this.environment);
this.customizer = new TomcatServletWebServerFactoryCustomizer(
this.serverProperties);
}
@Test
public void customTldSkip() {
bind("server.tomcat.additional-tld-skip-patterns=foo.jar,bar.jar");
testCustomTldSkip("foo.jar", "bar.jar");
}
@Test
public void customTldSkipAsList() {
bind("server.tomcat.additional-tld-skip-patterns[0]=biz.jar",
"server.tomcat.additional-tld-skip-patterns[1]=bah.jar");
testCustomTldSkip("biz.jar", "bah.jar");
}
private void testCustomTldSkip(String... expectedJars) {
TomcatServletWebServerFactory factory = customizeAndGetFactory();
assertThat(factory.getTldSkipPatterns()).contains(expectedJars);
assertThat(factory.getTldSkipPatterns()).contains("junit-*.jar",
"spring-boot-*.jar");
}
@Test
public void redirectContextRootCanBeConfigured() {
bind("server.tomcat.redirect-context-root=false");
ServerProperties.Tomcat tomcat = this.serverProperties.getTomcat();
assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false);
TomcatWebServer server = customizeAndGetServer();
Context context = (Context) server.getTomcat().getHost().findChildren()[0];
assertThat(context.getMapperContextRootRedirectEnabled()).isFalse();
}
@Test
public void useRelativeRedirectsCanBeConfigured() {
bind("server.tomcat.use-relative-redirects=true");
assertThat(this.serverProperties.getTomcat().getUseRelativeRedirects()).isTrue();
TomcatWebServer server = customizeAndGetServer();
Context context = (Context) server.getTomcat().getHost().findChildren()[0];
assertThat(context.getUseRelativeRedirects()).isTrue();
}
private void bind(String... inlinedProperties) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
inlinedProperties);
new Binder(ConfigurationPropertySources.get(this.environment)).bind("server",
Bindable.ofInstance(this.serverProperties));
}
private TomcatWebServer customizeAndGetServer() {
TomcatServletWebServerFactory factory = customizeAndGetFactory();
return (TomcatWebServer) factory.getWebServer();
}
private TomcatServletWebServerFactory customizeAndGetFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
return factory;
}
}
...@@ -234,8 +234,7 @@ public class BasicErrorControllerIntegrationTests { ...@@ -234,8 +234,7 @@ public class BasicErrorControllerIntegrationTests {
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Import({ ServletWebServerFactoryAutoConfiguration.EmbeddedTomcat.class, @Import({ ServletWebServerFactoryAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class, DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class }) PropertyPlaceholderAutoConfiguration.class })
......
...@@ -129,8 +129,7 @@ public class BasicErrorControllerMockMvcTests { ...@@ -129,8 +129,7 @@ public class BasicErrorControllerMockMvcTests {
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Import({ ServletWebServerFactoryAutoConfiguration.EmbeddedTomcat.class, @Import({ ServletWebServerFactoryAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class, DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class }) PropertyPlaceholderAutoConfiguration.class })
......
...@@ -14,14 +14,8 @@ ...@@ -14,14 +14,8 @@
<subpackage name="client"> <subpackage name="client">
<allow pkg="org.springframework.boot.web.client" /> <allow pkg="org.springframework.boot.web.client" />
</subpackage> </subpackage>
<subpackage name="embedded.jetty"> <subpackage name="embedded">
<allow pkg="org.springframework.boot.web.embedded.jetty" /> <allow pkg="org.springframework.boot.web.embedded" />
</subpackage>
<subpackage name="embedded.tomcat">
<allow pkg="org.springframework.boot.web.embedded.tomcat" />
</subpackage>
<subpackage name="embedded.undertow">
<allow pkg="org.springframework.boot.web.embedded.undertow" />
</subpackage> </subpackage>
<subpackage name="servlet"> <subpackage name="servlet">
<allow pkg="javax.servlet" /> <allow pkg="javax.servlet" />
......
...@@ -18,15 +18,17 @@ package org.springframework.boot.web.embedded.jetty; ...@@ -18,15 +18,17 @@ package org.springframework.boot.web.embedded.jetty;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
/** /**
* Web Server Factory configuration for Jetty-specific features. * {@link ConfigurableWebServerFactory} for Jetty-specific features.
* *
* @author Brian Clozel * @author Brian Clozel
* @since 2.0.0 * @since 2.0.0
* @see JettyServletWebServerFactory * @see JettyServletWebServerFactory
* @see JettyReactiveWebServerFactory * @see JettyReactiveWebServerFactory
*/ */
public interface ConfigurableJettyWebServerFactory { public interface ConfigurableJettyWebServerFactory extends ConfigurableWebServerFactory {
/** /**
* Set the number of acceptor threads to use. * Set the number of acceptor threads to use.
......
...@@ -24,15 +24,17 @@ import org.apache.catalina.Engine; ...@@ -24,15 +24,17 @@ import org.apache.catalina.Engine;
import org.apache.catalina.Valve; import org.apache.catalina.Valve;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
/** /**
* Web Server Factory configuration for Tomcat-specific features. * {@link ConfigurableWebServerFactory} for Tomcat-specific features.
* *
* @author Brian Clozel * @author Brian Clozel
* @since 2.0.0 * @since 2.0.0
* @see TomcatServletWebServerFactory * @see TomcatServletWebServerFactory
* @see TomcatReactiveWebServerFactory * @see TomcatReactiveWebServerFactory
*/ */
public interface ConfigurableTomcatWebServerFactory { public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServerFactory {
/** /**
* Set the Tomcat base directory. If not specified a temporary directory will be used. * Set the Tomcat base directory. If not specified a temporary directory will be used.
......
...@@ -21,15 +21,18 @@ import java.io.File; ...@@ -21,15 +21,18 @@ import java.io.File;
import io.undertow.Undertow.Builder; import io.undertow.Undertow.Builder;
import io.undertow.servlet.api.DeploymentInfo; import io.undertow.servlet.api.DeploymentInfo;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
/** /**
* Web Server Factory configuration for Undertow-specific features. * {@link ConfigurableWebServerFactory} for Undertow-specific features.
* *
* @author Brian Clozel * @author Brian Clozel
* @since 2.0.0 * @since 2.0.0
* @see UndertowServletWebServerFactory * @see UndertowServletWebServerFactory
* @see UndertowReactiveWebServerFactory * @see UndertowReactiveWebServerFactory
*/ */
public interface ConfigurableUndertowWebServerFactory { public interface ConfigurableUndertowWebServerFactory
extends ConfigurableWebServerFactory {
/** /**
* Add {@link UndertowBuilderCustomizer}s that should be used to customize the * Add {@link UndertowBuilderCustomizer}s that should be used to customize the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment