From 2dbceb9053cdba3938918eafc42f2c617f2288a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 25 Sep 2020 19:59:56 +0200 Subject: [PATCH] Deprecate LiveBeansView This commit deprecates LiveBeansView and related classes in order to allow a future removal in order to increase the separation of concerns between Spring Framework and Spring Boot, and the consistency between JVM and native. Closes gh-25820 --- .../context/support/AbstractApplicationContext.java | 2 ++ .../context/support/LiveBeansView.java | 7 +++---- .../context/support/LiveBeansViewMBean.java | 4 +++- .../web/context/support/LiveBeansViewServlet.java | 11 ++++++----- .../context/support/ServletContextLiveBeansView.java | 7 ++++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index b954d56159e..2a2aa818e2b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -930,6 +930,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * onRefresh() method and publishing the * {@link org.springframework.context.event.ContextRefreshedEvent}. */ + @SuppressWarnings("deprecation") protected void finishRefresh() { // Clear context-level resource caches (such as ASM metadata from scanning). clearResourceCaches(); @@ -1047,6 +1048,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * @see #close() * @see #registerShutdownHook() */ + @SuppressWarnings("deprecation") protected void doClose() { // Check whether an actual close attempt is necessary... if (this.active.get() && this.closed.compareAndSet(false, true)) { diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java index d2089eba848..f6177a35b01 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java +++ b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -42,15 +42,14 @@ import org.springframework.util.StringUtils; * local {@code LiveBeansView} bean definition) or all registered ApplicationContexts * (driven by the {@value #MBEAN_DOMAIN_PROPERTY_NAME} environment property). * - *

Note: This feature is still in beta and primarily designed for use with - * Spring Tool Suite 3.1 and higher. - * * @author Juergen Hoeller * @author Stephane Nicoll * @since 3.2 * @see #getSnapshotAsJson() * @see org.springframework.web.context.support.LiveBeansViewServlet + * @deprecated as of 5.3, in favor of using Spring Boot actuators for such need. */ +@Deprecated public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAware { /** diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java index b6a04868f04..9eb2c322092 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java +++ b/spring-context/src/main/java/org/springframework/context/support/LiveBeansViewMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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. @@ -21,7 +21,9 @@ package org.springframework.context.support; * * @author Juergen Hoeller * @since 3.2 + * @deprecated as of 5.3, in favor of using Spring Boot actuators for such need. */ +@Deprecated public interface LiveBeansViewMBean { /** diff --git a/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java b/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java index 4302e05d329..5d3e8bc8f7f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -23,12 +23,11 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.springframework.context.support.LiveBeansView; import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** - * Servlet variant of {@link LiveBeansView}'s MBean exposure. + * Servlet variant of {@link org.springframework.context.support.LiveBeansView}'s MBean exposure. * *

Generates a JSON snapshot for current beans and their dependencies in * all ApplicationContexts that live within the current web application. @@ -36,12 +35,14 @@ import org.springframework.util.Assert; * @author Juergen Hoeller * @since 3.2 * @see org.springframework.context.support.LiveBeansView#getSnapshotAsJson() + * @deprecated as of 5.3, in favor of using Spring Boot actuators for such need. */ +@Deprecated @SuppressWarnings("serial") public class LiveBeansViewServlet extends HttpServlet { @Nullable - private LiveBeansView liveBeansView; + private org.springframework.context.support.LiveBeansView liveBeansView; @Override @@ -49,7 +50,7 @@ public class LiveBeansViewServlet extends HttpServlet { this.liveBeansView = buildLiveBeansView(); } - protected LiveBeansView buildLiveBeansView() { + protected org.springframework.context.support.LiveBeansView buildLiveBeansView() { return new ServletContextLiveBeansView(getServletContext()); } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java index 89cf33fb973..d8dc9367b6b 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java @@ -23,17 +23,18 @@ import java.util.Set; import javax.servlet.ServletContext; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.LiveBeansView; import org.springframework.util.Assert; /** - * {@link LiveBeansView} subclass which looks for all ApplicationContexts + * {@link org.springframework.context.support.LiveBeansView} subclass which looks for all ApplicationContexts * in the web application, as exposed in ServletContext attributes. * * @author Juergen Hoeller * @since 3.2 + * @deprecated as of 5.3, in favor of using Spring Boot actuators for such need. */ -public class ServletContextLiveBeansView extends LiveBeansView { +@Deprecated +public class ServletContextLiveBeansView extends org.springframework.context.support.LiveBeansView { private final ServletContext servletContext;