Skip to content

Commit 46abccd

Browse files
committed
Move mapping description auto-configuration into appropriate modules
1 parent 00f6a84 commit 46abccd

File tree

20 files changed

+482
-172
lines changed

20 files changed

+482
-172
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java

Lines changed: 0 additions & 96 deletions
This file was deleted.

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ org.springframework.boot.actuate.autoconfigure.tracing.prometheus.PrometheusExem
1414
org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinTracingAutoConfiguration
1515
org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesAutoConfiguration
1616
org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesEndpointAutoConfiguration
17-
org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointAutoConfiguration

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfigurationTests.java

Lines changed: 0 additions & 74 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.mappings;
18+
19+
import org.springframework.beans.factory.ObjectProvider;
20+
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
21+
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
22+
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
23+
import org.springframework.boot.autoconfigure.AutoConfiguration;
24+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
25+
import org.springframework.context.ApplicationContext;
26+
import org.springframework.context.annotation.Bean;
27+
28+
/**
29+
* {@link EnableAutoConfiguration Auto-configuration} for {@link MappingsEndpoint}.
30+
*
31+
* @author Andy Wilkinson
32+
* @since 2.0.0
33+
*/
34+
@AutoConfiguration
35+
@ConditionalOnAvailableEndpoint(MappingsEndpoint.class)
36+
public class MappingsEndpointAutoConfiguration {
37+
38+
@Bean
39+
MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext,
40+
ObjectProvider<MappingDescriptionProvider> descriptionProviders) {
41+
return new MappingsEndpoint(descriptionProviders.orderedStream().toList(), applicationContext);
42+
}
43+
44+
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ org.springframework.boot.actuate.autoconfigure.sbom.SbomEndpointAutoConfiguratio
2323
org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpointAutoConfiguration
2424
org.springframework.boot.actuate.autoconfigure.startup.StartupEndpointAutoConfiguration
2525
org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthContributorAutoConfiguration
26+
org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointAutoConfiguration
2627
org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.mappings;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
22+
import org.springframework.boot.autoconfigure.AutoConfigurations;
23+
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link MappingsEndpointAutoConfiguration}.
29+
*
30+
* @author Andy Wilkinson
31+
*/
32+
class MappingsEndpointAutoConfigurationTests {
33+
34+
@Test
35+
void whenEndpointIsUnavailableThenEndpointIsNotCreated() {
36+
new WebApplicationContextRunner()
37+
.withConfiguration(AutoConfigurations.of(MappingsEndpointAutoConfiguration.class))
38+
.run((context) -> assertThat(context).doesNotHaveBean(MappingsEndpoint.class));
39+
}
40+
41+
@Test
42+
void whenEndpointIsAvailableThenEndpointIsCreated() {
43+
new WebApplicationContextRunner()
44+
.withConfiguration(AutoConfigurations.of(MappingsEndpointAutoConfiguration.class))
45+
.withPropertyValues("management.endpoints.web.exposure.include=mappings")
46+
.run((context) -> assertThat(context).hasSingleBean(MappingsEndpoint.class));
47+
}
48+
49+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies {
1818
optional("jakarta.servlet:jakarta.servlet-api")
1919
optional("org.springframework.security:spring-security-config")
2020

21+
testImplementation(project(":spring-boot-project:spring-boot-test"))
2122
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
2223

2324
testRuntimeOnly("ch.qos.logback:logback-classic")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.servlet.actuate.autoconfigure.mappings;
18+
19+
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
20+
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
21+
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
22+
import org.springframework.boot.autoconfigure.AutoConfiguration;
23+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
26+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
27+
import org.springframework.boot.servlet.actuate.mappings.FiltersMappingDescriptionProvider;
28+
import org.springframework.boot.servlet.actuate.mappings.ServletsMappingDescriptionProvider;
29+
import org.springframework.context.annotation.Bean;
30+
31+
/**
32+
* {@link EnableAutoConfiguration Auto-configuration} to describe Servlet-related
33+
* {@link MappingDescriptionProvider mappings}.
34+
*
35+
* @author Andy Wilkinson
36+
* @since 4.0.0
37+
*/
38+
@AutoConfiguration
39+
@ConditionalOnClass({ ConditionalOnAvailableEndpoint.class, MappingsEndpoint.class })
40+
@ConditionalOnAvailableEndpoint(MappingsEndpoint.class)
41+
@ConditionalOnWebApplication(type = Type.SERVLET)
42+
public class ServletMappingsAutoConfiguration {
43+
44+
@Bean
45+
ServletsMappingDescriptionProvider servletMappingDescriptionProvider() {
46+
return new ServletsMappingDescriptionProvider();
47+
}
48+
49+
@Bean
50+
FiltersMappingDescriptionProvider filterMappingDescriptionProvider() {
51+
return new FiltersMappingDescriptionProvider();
52+
}
53+
54+
}
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 Servlet-based integration with Actuator's mappings support.
19+
*/
20+
package org.springframework.boot.servlet.actuate.autoconfigure.mappings;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
org.springframework.boot.servlet.actuate.autoconfigure.ServletManagementContextAutoConfiguration
2+
org.springframework.boot.servlet.actuate.autoconfigure.mappings.ServletMappingsAutoConfiguration
23
org.springframework.boot.servlet.autoconfigure.MultipartAutoConfiguration

0 commit comments

Comments
 (0)