mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Deprecate framework-specific @*Endpoint annotations
Prior to this commit, applications could declare Actuator Endpoints using web framework-specific annotations, such as `@ServletEndpoint`, @ControllerEndpoint and @RestControllerEndpoint. Such annotations are closely tied to the programming model of specific web technologies, such as Servlet or Spring MVC. Unlike other `@Endpoint` support, they are not portable and will not work transparently over blocking/reactive and transports. Because of the strong adherence of this support with the underlying infrastructure, it makes it impossible to evolve the implementation of Actuator support without breaking this use case. The reference documentation has been advocating for using `@Endpoint` and `@*Operation` for custom endpoints for a long time now. This commit deprecates this specific support in favor of the recommended approach. Closes gh-31768
This commit is contained in:
parent
34c60751e9
commit
647a5ec6be
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -111,6 +111,7 @@ public class CloudFoundryActuatorAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("removal")
|
||||
public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServletHandlerMapping(
|
||||
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
|
||||
RestTemplateBuilder restTemplateBuilder, ServletEndpointsSupplier servletEndpointsSupplier,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -47,6 +47,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||
public class ServletEndpointManagementContextConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("removal")
|
||||
public IncludeExcludeEndpointFilter<ExposableServletEndpoint> servletExposeExcludePropertyEndpointFilter(
|
||||
WebEndpointProperties properties) {
|
||||
WebEndpointProperties.Exposure exposure = properties.getExposure();
|
||||
@ -56,6 +57,7 @@ public class ServletEndpointManagementContextConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(DispatcherServlet.class)
|
||||
@SuppressWarnings("removal")
|
||||
public static class WebMvcServletEndpointManagementContextConfiguration {
|
||||
|
||||
@Bean
|
||||
@ -70,6 +72,7 @@ public class ServletEndpointManagementContextConfiguration {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ResourceConfig.class)
|
||||
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")
|
||||
@SuppressWarnings("removal")
|
||||
public static class JerseyServletEndpointManagementContextConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -96,6 +96,7 @@ public class WebEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ControllerEndpointsSupplier.class)
|
||||
@SuppressWarnings("removal")
|
||||
public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider<PathMapper> endpointPathMappers,
|
||||
ObjectProvider<Collection<EndpointFilter<ExposableControllerEndpoint>>> filters) {
|
||||
return new ControllerEndpointDiscoverer(this.applicationContext, endpointPathMappers.orderedStream().toList(),
|
||||
@ -124,6 +125,7 @@ public class WebEndpointAutoConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
@SuppressWarnings("removal")
|
||||
static class WebEndpointServletConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -84,6 +84,7 @@ class JerseyWebEndpointManagementContextConfiguration {
|
||||
private static final EndpointId HEALTH_ENDPOINT_ID = EndpointId.of("health");
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("removal")
|
||||
JerseyWebEndpointsResourcesRegistrar jerseyWebEndpointsResourcesRegistrar(Environment environment,
|
||||
WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier,
|
||||
EndpointMediaTypes endpointMediaTypes, WebEndpointProperties webEndpointProperties) {
|
||||
@ -124,6 +125,7 @@ class JerseyWebEndpointManagementContextConfiguration {
|
||||
/**
|
||||
* Register endpoints with the {@link ResourceConfig} for the management context.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
static class JerseyWebEndpointsResourcesRegistrar implements ManagementContextResourceConfigCustomizer {
|
||||
|
||||
private final WebEndpointsSupplier webEndpointsSupplier;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -82,6 +82,7 @@ public class WebMvcEndpointManagementContextConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@SuppressWarnings("removal")
|
||||
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier,
|
||||
ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier,
|
||||
EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties,
|
||||
|
@ -42,6 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Phillip Webb
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ServletEndpointManagementContextConfigurationTests {
|
||||
|
||||
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||
|
@ -95,6 +95,7 @@ class WebEndpointAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void webApplicationConfiguresEndpointDiscoverer() {
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
|
||||
@ -109,11 +110,13 @@ class WebEndpointAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void contextShouldConfigureServletEndpointDiscoverer() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ServletEndpointDiscoverer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void contextWhenNotServletShouldNotConfigureServletEndpointDiscoverer() {
|
||||
new ApplicationContextRunner().withConfiguration(CONFIGURATIONS)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(ServletEndpointDiscoverer.class));
|
||||
|
@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointWebFluxIntegrationTests {
|
||||
|
||||
private AnnotationConfigReactiveWebApplicationContext context;
|
||||
|
@ -121,6 +121,7 @@ class ControllerEndpointWebMvcIntegrationTests {
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "example")
|
||||
@SuppressWarnings("removal")
|
||||
static class ExampleController {
|
||||
|
||||
@GetMapping("/")
|
||||
|
@ -161,11 +161,13 @@ class JerseyEndpointIntegrationTests {
|
||||
}
|
||||
|
||||
@ControllerEndpoint(id = "controller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "restcontroller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestRestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
@ -108,11 +108,13 @@ class WebFluxEndpointIntegrationTests {
|
||||
}
|
||||
|
||||
@ControllerEndpoint(id = "controller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "restcontroller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestRestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
@ -190,6 +190,7 @@ class WebMvcEndpointExposureIntegrationTests {
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "custommvc")
|
||||
@SuppressWarnings("removal")
|
||||
static class CustomMvcEndpoint {
|
||||
|
||||
@GetMapping("/")
|
||||
@ -200,6 +201,7 @@ class WebMvcEndpointExposureIntegrationTests {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "customservlet")
|
||||
@SuppressWarnings("removal")
|
||||
static class CustomServletEndpoint implements Supplier<EndpointServlet> {
|
||||
|
||||
@Override
|
||||
|
@ -198,6 +198,7 @@ class WebMvcEndpointIntegrationTests {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "servlet")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestServletEndpoint implements Supplier<EndpointServlet> {
|
||||
|
||||
@Override
|
||||
@ -209,11 +210,13 @@ class WebMvcEndpointIntegrationTests {
|
||||
}
|
||||
|
||||
@ControllerEndpoint(id = "controller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "restcontroller")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestRestControllerEndpoint {
|
||||
|
||||
}
|
||||
|
@ -355,6 +355,7 @@ class EndpointRequestTests {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "baz")
|
||||
@SuppressWarnings("removal")
|
||||
static class BazServletEndpoint {
|
||||
|
||||
}
|
||||
|
@ -178,6 +178,7 @@ abstract class AbstractEndpointRequestIntegrationTests {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "se1")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestServletEndpoint implements Supplier<EndpointServlet> {
|
||||
|
||||
@Override
|
||||
|
@ -354,6 +354,7 @@ class EndpointRequestTests {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "baz")
|
||||
@SuppressWarnings("removal")
|
||||
static class BazServletEndpoint {
|
||||
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
@RestControllerEndpoint(id = "failController")
|
||||
@SuppressWarnings("removal")
|
||||
static class FailingControllerEndpoint {
|
||||
|
||||
@GetMapping
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -33,7 +33,9 @@ import org.springframework.util.StringUtils;
|
||||
* @author Phillip Webb
|
||||
* @author Julio José Gómez Díaz
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
public final class EndpointServlet {
|
||||
|
||||
private final Servlet servlet;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,7 +24,10 @@ import org.springframework.boot.actuate.endpoint.Operation;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public interface ExposableServletEndpoint extends ExposableEndpoint<Operation>, PathMappedEndpoint {
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -35,7 +35,10 @@ import org.springframework.util.StringUtils;
|
||||
* @author Phillip Webb
|
||||
* @author Madhura Bhave
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint} support
|
||||
*/
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public class ServletEndpointRegistrar implements ServletContextInitializer {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ServletEndpointRegistrar.class);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -47,12 +47,14 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
* @since 2.0.0
|
||||
* @see WebEndpoint
|
||||
* @see RestControllerEndpoint
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Endpoint
|
||||
@FilteredEndpoint(ControllerEndpointFilter.class)
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
public @interface ControllerEndpoint {
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -31,7 +31,6 @@ import org.springframework.boot.actuate.endpoint.annotation.EndpointDiscoverer;
|
||||
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
||||
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
@ -43,8 +42,11 @@ import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint} support
|
||||
*/
|
||||
@ImportRuntimeHints(ControllerEndpointDiscovererRuntimeHints.class)
|
||||
@ImportRuntimeHints(ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints.class)
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableControllerEndpoint, Operation>
|
||||
implements ControllerEndpointsSupplier {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -25,6 +25,7 @@ import org.springframework.boot.actuate.endpoint.annotation.DiscovererEndpointFi
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointFilter extends DiscovererEndpointFilter {
|
||||
|
||||
ControllerEndpointFilter() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class DiscoveredServletEndpoint extends AbstractDiscoveredEndpoint<Operation> implements ExposableServletEndpoint {
|
||||
|
||||
private final String rootPath;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
* @since 2.0.0
|
||||
* @see WebEndpoint
|
||||
* @see ControllerEndpoint
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ -55,6 +56,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Endpoint
|
||||
@FilteredEndpoint(ControllerEndpointFilter.class)
|
||||
@ResponseBody
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
public @interface RestControllerEndpoint {
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -40,12 +40,14 @@ import org.springframework.core.annotation.AliasFor;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Endpoint
|
||||
@FilteredEndpoint(ServletEndpointFilter.class)
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
public @interface ServletEndpoint {
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -32,7 +32,6 @@ import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
||||
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
@ -43,8 +42,11 @@ import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@ImportRuntimeHints(ServletEndpointDiscovererRuntimeHints.class)
|
||||
@ImportRuntimeHints(ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints.class)
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServletEndpoint, Operation>
|
||||
implements ServletEndpointsSupplier {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,6 +24,7 @@ import org.springframework.boot.actuate.endpoint.annotation.DiscovererEndpointFi
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ServletEndpointFilter extends DiscovererEndpointFilter {
|
||||
|
||||
ServletEndpointFilter() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,8 +24,11 @@ import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public interface ServletEndpointsSupplier extends EndpointsSupplier<ExposableServletEndpoint> {
|
||||
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ class EndpointLinksResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void resolvedLinksContainsALinkForServletEndpoint() {
|
||||
ExposableServletEndpoint servletEndpoint = mock(ExposableServletEndpoint.class);
|
||||
given(servletEndpoint.getEndpointId()).willReturn(EndpointId.of("alpha"));
|
||||
|
@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class EndpointServletTests {
|
||||
|
||||
@Test
|
||||
|
@ -48,6 +48,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@SuppressWarnings("removal")
|
||||
class ServletEndpointRegistrarTests {
|
||||
|
||||
@Mock
|
||||
|
@ -30,7 +30,6 @@ import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.DiscoveredEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
||||
@ -50,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Stephane Nicoll
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointDiscovererTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
@ -132,7 +132,8 @@ class ControllerEndpointDiscovererTests {
|
||||
@Test
|
||||
void shouldRegisterHints() {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new ControllerEndpointDiscovererRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
new ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints().registerHints(runtimeHints,
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ControllerEndpointFilter.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
|
@ -38,7 +38,6 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.boot.actuate.endpoint.web.EndpointServlet;
|
||||
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
||||
@ -58,6 +57,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Stephane Nicoll
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ServletEndpointDiscovererTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
@ -135,7 +135,8 @@ class ServletEndpointDiscovererTests {
|
||||
@Test
|
||||
void shouldRegisterHints() {
|
||||
RuntimeHints runtimeHints = new RuntimeHints();
|
||||
new ServletEndpointDiscovererRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
|
||||
new ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints().registerHints(runtimeHints,
|
||||
getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onType(ServletEndpointFilter.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||
|
@ -58,6 +58,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointHandlerMappingIntegrationTests {
|
||||
|
||||
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner(
|
||||
|
@ -46,6 +46,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointHandlerMappingTests {
|
||||
|
||||
private final StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
@ -57,6 +57,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointHandlerMappingIntegrationTests {
|
||||
|
||||
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner(
|
||||
|
@ -43,6 +43,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ControllerEndpointHandlerMappingTests {
|
||||
|
||||
private final StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
@ -726,10 +726,8 @@
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.health.writing-custom-health-indicators[#actuator.endpoints.health.writing-custom-health-indicators]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.hypermedia[#actuator.endpoints.hypermedia]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom[#actuator.endpoints.implementing-custom]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.controller[#actuator.endpoints.implementing-custom.controller]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.input[#actuator.endpoints.implementing-custom.input]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.input.conversion[#actuator.endpoints.implementing-custom.input.conversion]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.servlet[#actuator.endpoints.implementing-custom.servlet]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.web[#actuator.endpoints.implementing-custom.web]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.web.consumes-predicates[#actuator.endpoints.implementing-custom.web.consumes-predicates]
|
||||
* xref:reference:actuator/endpoints.adoc#actuator.endpoints.implementing-custom.web.method-predicates[#actuator.endpoints.implementing-custom.web.method-predicates]
|
||||
|
@ -536,26 +536,6 @@ The latter is typically used to perform authorization checks by using its `isUse
|
||||
|
||||
|
||||
|
||||
[[actuator.endpoints.implementing-custom.servlet]]
|
||||
=== Servlet Endpoints
|
||||
|
||||
A servlet can be exposed as an endpoint by implementing a class annotated with `@ServletEndpoint` that also implements `Supplier<EndpointServlet>`.
|
||||
Servlet endpoints provide deeper integration with the servlet container but at the expense of portability.
|
||||
They are intended to be used to expose an existing servlet as an endpoint.
|
||||
For new endpoints, the `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible.
|
||||
|
||||
|
||||
|
||||
[[actuator.endpoints.implementing-custom.controller]]
|
||||
=== Controller Endpoints
|
||||
|
||||
You can use `@ControllerEndpoint` and `@RestControllerEndpoint` to implement an endpoint that is exposed only by Spring MVC or Spring WebFlux.
|
||||
Methods are mapped by using the standard annotations for Spring MVC and Spring WebFlux, such as `@RequestMapping` and `@GetMapping`, with the endpoint's ID being used as a prefix for the path.
|
||||
Controller endpoints provide deeper integration with Spring's web frameworks but at the expense of portability.
|
||||
The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible.
|
||||
|
||||
|
||||
|
||||
[[actuator.endpoints.health]]
|
||||
== Health Information
|
||||
|
||||
|
@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
@RestControllerEndpoint(id = "example")
|
||||
@SuppressWarnings("removal")
|
||||
public class ExampleRestControllerEndpoint {
|
||||
|
||||
@GetMapping("/echo")
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@SuppressWarnings("removal")
|
||||
public class SampleActuatorCustomSecurityApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
*/
|
||||
@Component
|
||||
@RestControllerEndpoint(id = "exception")
|
||||
@SuppressWarnings("removal")
|
||||
public class SampleRestControllerEndpointWithException {
|
||||
|
||||
@GetMapping("/")
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@SuppressWarnings("removal")
|
||||
public class SampleSecureJerseyApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -43,6 +44,7 @@ public class SampleSecureJerseyApplication {
|
||||
}
|
||||
|
||||
@ServletEndpoint(id = "se1")
|
||||
@SuppressWarnings("removal")
|
||||
static class TestServletEndpoint implements Supplier<EndpointServlet> {
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user