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:
Brian Clozel
2024-04-15 13:43:32 +02:00
parent 34c60751e9
commit 647a5ec6be
44 changed files with 91 additions and 47 deletions

View File

@@ -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;

View File

@@ -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 {
/**

View File

@@ -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);

View File

@@ -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 {
/**

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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 {
/**

View File

@@ -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 {
/**

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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> {
}