Introduce "server.servlet" configuration prefix

This commit refactors the `ServerProperties` property keys and
introduces a separate "server.servlet" namespace to isolate
servlet-specific properties from the rest.

Closes gh-8066
This commit is contained in:
Brian Clozel
2017-01-26 21:43:04 +01:00
parent a31a792192
commit 12d883f6b9
37 changed files with 239 additions and 195 deletions

View File

@@ -95,8 +95,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper((this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
return new UrlHandlerMapper((this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
+ this.properties.getRemote().getContextPath(), handler);
}
@@ -136,8 +136,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
String url = (this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
String url = (this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
+ this.properties.getRemote().getContextPath() + "/restart";
logger.warn("Listening for remote restart updates on " + url);
Handler handler = new HttpRestartServerHandler(server);
@@ -162,8 +162,8 @@ public class RemoteDevToolsAutoConfiguration {
@ConditionalOnMissingBean(name = "remoteDebugHandlerMapper")
public UrlHandlerMapper remoteDebugHandlerMapper(
@Qualifier("remoteDebugHttpTunnelServer") HttpTunnelServer server) {
String url = (this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
String url = (this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
+ this.properties.getRemote().getContextPath() + "/debug";
logger.warn("Listening for remote debug traffic on " + url);
Handler handler = new HttpTunnelServerHandler(server);

View File

@@ -56,7 +56,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
properties.put("spring.resources.chain.cache", "false");
properties.put("spring.template.provider.cache", "false");
properties.put("spring.mvc.log-resolved-exception", "true");
properties.put("server.jsp-servlet.init-parameters.development", "true");
properties.put("server.servlet.jsp.init-parameters.development", "true");
properties.put("spring.reactor.stacktrace-mode.enabled", "true");
PROPERTIES = Collections.unmodifiableMap(properties);
}

View File

@@ -138,7 +138,7 @@ public class RemoteDevToolsAutoConfigurationTests {
@Test
public void invokeRestartWithCustomServerContextPath() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret",
"server.context-path:/test");
"server.servlet.context-path:/test");
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI("/test" + DEFAULT_CONTEXT_PATH + "/restart");
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
@@ -167,7 +167,7 @@ public class RemoteDevToolsAutoConfigurationTests {
@Test
public void invokeTunnelWithCustomServerContextPath() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret",
"server.context-path:/test");
"server.servlet.context-path:/test");
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI("/test" + DEFAULT_CONTEXT_PATH + "/debug");
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
@@ -208,7 +208,7 @@ public class RemoteDevToolsAutoConfigurationTests {
@Test
public void devToolsHealthWithCustomServerContextPathReturns200() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret",
"server.context-path:/test");
"server.servlet.context-path:/test");
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI("/test" + DEFAULT_CONTEXT_PATH);
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");