Skip to content

Commit ab36a45

Browse files
committed
Move WebServer-specific properties out of ManagementServerProperties
Issue: 44324
1 parent d0d75f1 commit ab36a45

17 files changed

+286
-100
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java

-65
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ public class ManagementServerProperties {
5858
@NestedConfigurationProperty
5959
private Ssl ssl;
6060

61-
private final Jetty jetty = new Jetty();
62-
63-
private final Tomcat tomcat = new Tomcat();
64-
65-
private final Undertow undertow = new Undertow();
66-
6761
/**
6862
* Returns the management port or {@code null} if the
6963
* {@link ServerProperties#getPort() server port} should be used.
@@ -108,18 +102,6 @@ public void setSsl(Ssl ssl) {
108102
this.ssl = ssl;
109103
}
110104

111-
public Jetty getJetty() {
112-
return this.jetty;
113-
}
114-
115-
public Tomcat getTomcat() {
116-
return this.tomcat;
117-
}
118-
119-
public Undertow getUndertow() {
120-
return this.undertow;
121-
}
122-
123105
private String cleanBasePath(String basePath) {
124106
String candidate = null;
125107
if (StringUtils.hasLength(basePath)) {
@@ -136,51 +118,4 @@ private String cleanBasePath(String basePath) {
136118
return candidate;
137119
}
138120

139-
public static class Jetty {
140-
141-
private final Accesslog accesslog = new Accesslog();
142-
143-
public Accesslog getAccesslog() {
144-
return this.accesslog;
145-
}
146-
147-
}
148-
149-
public static class Tomcat {
150-
151-
private final Accesslog accesslog = new Accesslog();
152-
153-
public Accesslog getAccesslog() {
154-
return this.accesslog;
155-
}
156-
157-
}
158-
159-
public static class Undertow {
160-
161-
private final Accesslog accesslog = new Accesslog();
162-
163-
public Accesslog getAccesslog() {
164-
return this.accesslog;
165-
}
166-
167-
}
168-
169-
public static class Accesslog {
170-
171-
/**
172-
* Management log file name prefix.
173-
*/
174-
private String prefix = "management_";
175-
176-
public String getPrefix() {
177-
return this.prefix;
178-
}
179-
180-
public void setPrefix(String prefix) {
181-
this.prefix = prefix;
182-
}
183-
184-
}
185-
186121
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyAccessLogCustomizer.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.eclipse.jetty.server.Server;
2525

2626
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer;
27-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2827
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
2928
import org.springframework.boot.web.server.jetty.ConfigurableJettyWebServerFactory;
3029
import org.springframework.util.StringUtils;
@@ -37,8 +36,8 @@
3736
class JettyAccessLogCustomizer extends AccessLogCustomizer<ConfigurableJettyWebServerFactory>
3837
implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> {
3938

40-
JettyAccessLogCustomizer(ManagementServerProperties properties) {
41-
super(properties.getJetty().getAccesslog().getPrefix());
39+
JettyAccessLogCustomizer(JettyManagementServerProperties properties) {
40+
super(properties.getAccesslog().getPrefix());
4241
}
4342

4443
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.web.server.jetty;
18+
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
/**
22+
* Properties for a Jetty-based management server.
23+
*
24+
* @author Moritz Halbritter
25+
* @since 4.0.0
26+
*/
27+
@ConfigurationProperties("management.server.jetty")
28+
public class JettyManagementServerProperties {
29+
30+
private final Accesslog accesslog = new Accesslog();
31+
32+
public Accesslog getAccesslog() {
33+
return this.accesslog;
34+
}
35+
36+
public static class Accesslog {
37+
38+
/**
39+
* Management log file name prefix.
40+
*/
41+
private String prefix = "management_";
42+
43+
public String getPrefix() {
44+
return this.prefix;
45+
}
46+
47+
public void setPrefix(String prefix) {
48+
this.prefix = prefix;
49+
}
50+
51+
}
52+
53+
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyReactiveManagementChildContextConfiguration.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
2222
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
23-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2524
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
@@ -36,12 +35,12 @@
3635
*/
3736
@ConditionalOnClass(Server.class)
3837
@ConditionalOnWebApplication(type = Type.REACTIVE)
39-
@EnableConfigurationProperties(ManagementServerProperties.class)
38+
@EnableConfigurationProperties(JettyManagementServerProperties.class)
4039
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false)
4140
class JettyReactiveManagementChildContextConfiguration {
4241

4342
@Bean
44-
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) {
43+
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(JettyManagementServerProperties properties) {
4544
return new JettyAccessLogCustomizer(properties);
4645
}
4746

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyServletManagementChildContextConfiguration.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
2222
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
23-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2524
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
@@ -36,12 +35,12 @@
3635
*/
3736
@ConditionalOnClass(Server.class)
3837
@ConditionalOnWebApplication(type = Type.SERVLET)
39-
@EnableConfigurationProperties(ManagementServerProperties.class)
38+
@EnableConfigurationProperties(JettyManagementServerProperties.class)
4039
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false)
4140
class JettyServletManagementChildContextConfiguration {
4241

4342
@Bean
44-
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) {
43+
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(JettyManagementServerProperties properties) {
4544
return new JettyAccessLogCustomizer(properties);
4645
}
4746

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatAccessLogCustomizer.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.catalina.valves.AccessLogValve;
2424

2525
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer;
26-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2726
import org.springframework.boot.web.server.tomcat.ConfigurableTomcatWebServerFactory;
2827

2928
/**
@@ -36,9 +35,9 @@ class TomcatAccessLogCustomizer<T extends ConfigurableTomcatWebServerFactory> ex
3635

3736
private final Function<T, Collection<Valve>> engineValvesExtractor;
3837

39-
TomcatAccessLogCustomizer(ManagementServerProperties properties,
38+
TomcatAccessLogCustomizer(TomcatManagementServerProperties properties,
4039
Function<T, Collection<Valve>> engineValvesExtractor) {
41-
super(properties.getTomcat().getAccesslog().getPrefix());
40+
super(properties.getAccesslog().getPrefix());
4241
this.engineValvesExtractor = engineValvesExtractor;
4342
}
4443

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.web.server.tomcat;
18+
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
/**
22+
* Properties for a Tomcat-based management server.
23+
*
24+
* @author Moritz Halbritter
25+
* @since 4.0.0
26+
*/
27+
@ConfigurationProperties("management.server.tomcat")
28+
public class TomcatManagementServerProperties {
29+
30+
private final Accesslog accesslog = new Accesslog();
31+
32+
public Accesslog getAccesslog() {
33+
return this.accesslog;
34+
}
35+
36+
public static class Accesslog {
37+
38+
/**
39+
* Management log file name prefix.
40+
*/
41+
private String prefix = "management_";
42+
43+
public String getPrefix() {
44+
return this.prefix;
45+
}
46+
47+
public void setPrefix(String prefix) {
48+
this.prefix = prefix;
49+
}
50+
51+
}
52+
53+
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatReactiveManagementChildContextConfiguration.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
2222
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
23-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2524
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
@@ -37,13 +36,13 @@
3736
*/
3837
@ConditionalOnClass(Tomcat.class)
3938
@ConditionalOnWebApplication(type = Type.REACTIVE)
40-
@EnableConfigurationProperties(ManagementServerProperties.class)
39+
@EnableConfigurationProperties(TomcatManagementServerProperties.class)
4140
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false)
4241
class TomcatReactiveManagementChildContextConfiguration {
4342

4443
@Bean
4544
TomcatAccessLogCustomizer<TomcatReactiveWebServerFactory> tomcatManagementAccessLogCustomizer(
46-
ManagementServerProperties properties) {
45+
TomcatManagementServerProperties properties) {
4746
return new TomcatAccessLogCustomizer<>(properties, TomcatReactiveWebServerFactory::getEngineValves);
4847
}
4948

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatServletManagementChildContextConfiguration.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
2222
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
23-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2524
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
@@ -37,13 +36,13 @@
3736
*/
3837
@ConditionalOnClass(Tomcat.class)
3938
@ConditionalOnWebApplication(type = Type.SERVLET)
40-
@EnableConfigurationProperties(ManagementServerProperties.class)
39+
@EnableConfigurationProperties(TomcatManagementServerProperties.class)
4140
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false)
4241
class TomcatServletManagementChildContextConfiguration {
4342

4443
@Bean
4544
TomcatAccessLogCustomizer<TomcatServletWebServerFactory> tomcatManagementAccessLogCustomizer(
46-
ManagementServerProperties properties) {
45+
TomcatManagementServerProperties properties) {
4746
return new TomcatAccessLogCustomizer<>(properties, TomcatServletWebServerFactory::getEngineValves);
4847
}
4948

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowAccessLogCustomizer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.function.Function;
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer;
22-
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2322
import org.springframework.boot.web.server.undertow.ConfigurableUndertowWebServerFactory;
2423

2524
/**
@@ -32,8 +31,9 @@ class UndertowAccessLogCustomizer<T extends ConfigurableUndertowWebServerFactory
3231

3332
private final Function<T, String> accessLogPrefixExtractor;
3433

35-
UndertowAccessLogCustomizer(ManagementServerProperties properties, Function<T, String> accessLogPrefixExtractor) {
36-
super(properties.getUndertow().getAccesslog().getPrefix());
34+
UndertowAccessLogCustomizer(UndertowManagementServerProperties properties,
35+
Function<T, String> accessLogPrefixExtractor) {
36+
super(properties.getAccesslog().getPrefix());
3737
this.accessLogPrefixExtractor = accessLogPrefixExtractor;
3838
}
3939

0 commit comments

Comments
 (0)