Skip to content

Commit b44f7a1

Browse files
wilkinsonaphilwebb
authored andcommitted
Invert dependency between actuator-autoconfigure and webmvc
1 parent eca4219 commit b44f7a1

File tree

11 files changed

+157
-41
lines changed

11 files changed

+157
-41
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dependencies {
1515
optional(project(":spring-boot-project:spring-boot-jersey"))
1616
optional(project(":spring-boot-project:spring-boot-tomcat"))
1717
optional(project(":spring-boot-project:spring-boot-web-server"))
18-
optional(project(":spring-boot-project:spring-boot-webmvc"))
1918

2019
optional("io.micrometer:micrometer-core")
2120
optional("io.projectreactor:reactor-core")

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
2828
import org.springframework.boot.jersey.autoconfigure.JerseyApplicationPath;
29-
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath;
3029
import org.springframework.context.annotation.Bean;
3130
import org.springframework.context.annotation.Configuration;
32-
import org.springframework.web.servlet.DispatcherServlet;
3331

3432
/**
3533
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for servlet
@@ -54,23 +52,6 @@ public IncludeExcludeEndpointFilter<org.springframework.boot.actuate.endpoint.we
5452
exposure.getExclude());
5553
}
5654

57-
@Configuration(proxyBeanMethods = false)
58-
@ConditionalOnClass(DispatcherServlet.class)
59-
public static class WebMvcServletEndpointManagementContextConfiguration {
60-
61-
@Bean
62-
@SuppressWarnings({ "deprecation", "removal" })
63-
public org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar servletEndpointRegistrar(
64-
WebEndpointProperties properties,
65-
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
66-
DispatcherServletPath dispatcherServletPath, EndpointAccessResolver endpointAccessResolver) {
67-
return new org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar(
68-
dispatcherServletPath.getRelativePath(properties.getBasePath()),
69-
servletEndpointsSupplier.getEndpoints(), endpointAccessResolver);
70-
}
71-
72-
}
73-
7455
@Configuration(proxyBeanMethods = false)
7556
@ConditionalOnClass(ResourceConfig.class)
7657
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapperTests.java renamed to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapperTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java renamed to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.Collections;
2020

21-
import org.glassfish.jersey.server.ResourceConfig;
2221
import org.junit.jupiter.api.Test;
2322

2423
import org.springframework.boot.actuate.endpoint.Access;
@@ -30,7 +29,6 @@
3029
import org.springframework.boot.test.context.FilteredClassLoader;
3130
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3231
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
33-
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath;
3432
import org.springframework.context.annotation.Bean;
3533
import org.springframework.context.annotation.Configuration;
3634
import org.springframework.context.annotation.Import;
@@ -50,16 +48,6 @@ class ServletEndpointManagementContextConfigurationTests {
5048
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
5149
.withUserConfiguration(TestConfig.class);
5250

53-
@Test
54-
void contextShouldContainServletEndpointRegistrar() {
55-
FilteredClassLoader classLoader = new FilteredClassLoader(ResourceConfig.class);
56-
this.contextRunner.withClassLoader(classLoader).run((context) -> {
57-
assertThat(context).hasSingleBean(ServletEndpointRegistrar.class);
58-
ServletEndpointRegistrar bean = context.getBean(ServletEndpointRegistrar.class);
59-
assertThat(bean).hasFieldOrPropertyWithValue("basePath", "/test/actuator");
60-
});
61-
}
62-
6351
@Test
6452
void contextWhenJerseyShouldContainServletEndpointRegistrar() {
6553
FilteredClassLoader classLoader = new FilteredClassLoader(DispatcherServlet.class);
@@ -71,7 +59,7 @@ void contextWhenJerseyShouldContainServletEndpointRegistrar() {
7159
}
7260

7361
@Test
74-
void contextWhenNoServletBasedShouldNotContainServletEndpointRegistrar() {
62+
void contextWhenNotServletBasedShouldNotContainServletEndpointRegistrar() {
7563
new ApplicationContextRunner().withUserConfiguration(TestConfig.class)
7664
.run((context) -> assertThat(context).doesNotHaveBean(ServletEndpointRegistrar.class));
7765
}
@@ -86,11 +74,6 @@ ServletEndpointsSupplier servletEndpointsSupplier() {
8674
return Collections::emptyList;
8775
}
8876

89-
@Bean
90-
DispatcherServletPath dispatcherServletPath() {
91-
return () -> "/test";
92-
}
93-
9477
@Bean
9578
JerseyApplicationPath jerseyApplicationPath() {
9679
return () -> "/jersey";

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java renamed to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java renamed to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java

File renamed without changes.

spring-boot-project/spring-boot-webmvc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies {
1717

1818
implementation(project(":spring-boot-project:spring-boot-http-converter"))
1919

20-
optional(project(":spring-boot-project:spring-boot-actuator"))
20+
optional(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
2121
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
2222
optional(project(":spring-boot-project:spring-boot-tomcat"))
2323
optional(project(":spring-boot-project:spring-boot-undertow"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.webmvc.actuate.autoconfigure.endpoint.web;
18+
19+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
20+
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
21+
import org.springframework.boot.actuate.endpoint.EndpointAccessResolver;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
25+
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath;
26+
import org.springframework.context.annotation.Bean;
27+
import org.springframework.web.servlet.DispatcherServlet;
28+
29+
@ManagementContextConfiguration(proxyBeanMethods = false)
30+
@ConditionalOnWebApplication(type = Type.SERVLET)
31+
@ConditionalOnClass(DispatcherServlet.class)
32+
class WebMvcEndpointManagementContextConfiguration {
33+
34+
@Bean
35+
@SuppressWarnings({ "deprecation", "removal" })
36+
org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar servletEndpointRegistrar(
37+
WebEndpointProperties properties,
38+
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
39+
DispatcherServletPath dispatcherServletPath, EndpointAccessResolver endpointAccessResolver) {
40+
return new org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar(
41+
dispatcherServletPath.getRelativePath(properties.getBasePath()),
42+
servletEndpointsSupplier.getEndpoints(), endpointAccessResolver);
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
/**
18+
* Auto-configuration for Spring MVC-based actuator infrastructure.
19+
*/
20+
package org.springframework.boot.webmvc.actuate.autoconfigure.endpoint.web;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.springframework.boot.webmvc.actuate.autoconfigure.endpoint.web.WebMvcEndpointManagementContextConfiguration

0 commit comments

Comments
 (0)