Commit 32102c69 authored by Andy Wilkinson's avatar Andy Wilkinson

Avoid using classes from spring-web in core web endpoint infrastructure

Closes gh-10358
parent 3fcaa976
...@@ -63,7 +63,7 @@ public class EndpointAutoConfiguration { ...@@ -63,7 +63,7 @@ public class EndpointAutoConfiguration {
static class EndpointWebConfiguration { static class EndpointWebConfiguration {
private static final List<String> MEDIA_TYPES = Arrays private static final List<String> MEDIA_TYPES = Arrays
.asList(ActuatorMediaType.V2_JSON_VALUE, "application/json"); .asList(ActuatorMediaType.V2_JSON, "application/json");
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
package org.springframework.boot.actuate.endpoint.http; package org.springframework.boot.actuate.endpoint.http;
import org.springframework.http.MediaType;
/** /**
* {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints. * Media types that can be consumed and produced by Actuator endpoints.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Madhura Bhave * @author Madhura Bhave
...@@ -28,24 +26,14 @@ import org.springframework.http.MediaType; ...@@ -28,24 +26,14 @@ import org.springframework.http.MediaType;
public final class ActuatorMediaType { public final class ActuatorMediaType {
/** /**
* {@link String} equivalent of {@link #V1_JSON}. * Constant for the Actuator V1 media type.
*/
public static final String V1_JSON_VALUE = "application/vnd.spring-boot.actuator.v1+json";
/**
* {@link String} equivalent of {@link #V2_JSON}.
*/
public static final String V2_JSON_VALUE = "application/vnd.spring-boot.actuator.v2+json";
/**
* The {@code application/vnd.spring-boot.actuator.v1+json} media type.
*/ */
public static final MediaType V1_JSON = MediaType.valueOf(V1_JSON_VALUE); public static final String V1_JSON = "application/vnd.spring-boot.actuator.v1+json";
/** /**
* The {@code application/vnd.spring-boot.actuator.v2+json} media type. * Constant for the Actuator V2 media type.
*/ */
public static final MediaType V2_JSON = MediaType.valueOf(V2_JSON_VALUE); public static final String V2_JSON = "application/vnd.spring-boot.actuator.v2+json";
private ActuatorMediaType() { private ActuatorMediaType() {
} }
......
...@@ -91,7 +91,7 @@ class JerseyEndpointsRunner extends AbstractWebEndpointRunner { ...@@ -91,7 +91,7 @@ class JerseyEndpointsRunner extends AbstractWebEndpointRunner {
private void customize(ResourceConfig config) { private void customize(ResourceConfig config) {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE, List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE); ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer( WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext, this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null, new ConversionServiceOperationParameterMapper(), (id) -> null,
......
...@@ -98,7 +98,7 @@ class WebFluxEndpointsRunner extends AbstractWebEndpointRunner { ...@@ -98,7 +98,7 @@ class WebFluxEndpointsRunner extends AbstractWebEndpointRunner {
@Bean @Bean
public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping() { public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping() {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE, List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE); ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer( WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext, this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null, new ConversionServiceOperationParameterMapper(), (id) -> null,
......
...@@ -81,7 +81,7 @@ class WebMvcEndpointRunner extends AbstractWebEndpointRunner { ...@@ -81,7 +81,7 @@ class WebMvcEndpointRunner extends AbstractWebEndpointRunner {
@Bean @Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping() { public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping() {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE, List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE); ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer( WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext, this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null, new ConversionServiceOperationParameterMapper(), (id) -> null,
......
...@@ -116,7 +116,7 @@ public class LoggersEndpointWebIntegrationTests { ...@@ -116,7 +116,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test @Test
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception { public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT") client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange() .syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
.expectStatus().isNoContent(); .expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
...@@ -134,7 +134,7 @@ public class LoggersEndpointWebIntegrationTests { ...@@ -134,7 +134,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test @Test
public void setLoggerWithNullLogLevel() throws Exception { public void setLoggerWithNullLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT") client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", null)).exchange() .syncBody(Collections.singletonMap("configuredLevel", null)).exchange()
.expectStatus().isNoContent(); .expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
...@@ -143,8 +143,8 @@ public class LoggersEndpointWebIntegrationTests { ...@@ -143,8 +143,8 @@ public class LoggersEndpointWebIntegrationTests {
@Test @Test
public void setLoggerWithNoLogLevel() throws Exception { public void setLoggerWithNoLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT") client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON).syncBody(Collections.emptyMap()) .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.exchange().expectStatus().isNoContent(); .syncBody(Collections.emptyMap()).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
} }
......
...@@ -30,17 +30,19 @@ ...@@ -30,17 +30,19 @@
</subpackage> </subpackage>
<!-- Endpoint infrastructure --> <!-- Endpoint infrastructure -->
<subpackage name="endpoint"> <subpackage name="actuate.endpoint">
<disallow pkg="org.springframework.http" /> <disallow pkg="org.springframework.http" />
<disallow pkg="org.springframework.web" /> <disallow pkg="org.springframework.web" />
<subpackage name="web"> <subpackage name="web">
<subpackage name="servlet">
<disallow pkg="org.springframework.web.reactive" />
<allow pkg="org.springframework.http" /> <allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" /> <allow pkg="org.springframework.web" />
<subpackage name="mvc">
<disallow pkg="org.springframework.web.reactive" />
</subpackage> </subpackage>
<subpackage name="reactive"> <subpackage name="reactive">
<disallow pkg="org.springframework.web.servlet" /> <disallow pkg="org.springframework.web.servlet" />
<allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" />
</subpackage> </subpackage>
</subpackage> </subpackage>
</subpackage> </subpackage>
......
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