Deprecate MBeanExporter's AUTODETECT constants

Closes gh-30874
This commit is contained in:
Juergen Hoeller 2023-07-14 14:12:39 +02:00
parent 0d5a7db238
commit 52c19272c6
2 changed files with 18 additions and 4 deletions

View File

@ -105,23 +105,31 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
/**
* Autodetection mode indicating that no autodetection should be used.
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public static final int AUTODETECT_NONE = 0;
/**
* Autodetection mode indicating that only valid MBeans should be autodetected.
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public static final int AUTODETECT_MBEAN = 1;
/**
* Autodetection mode indicating that only the {@link MBeanInfoAssembler} should be able
* to autodetect beans.
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public static final int AUTODETECT_ASSEMBLER = 2;
/**
* Autodetection mode indicating that all autodetection mechanisms should be used.
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public static final int AUTODETECT_ALL = AUTODETECT_MBEAN | AUTODETECT_ASSEMBLER;
@ -236,7 +244,9 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
* @see #AUTODETECT_ASSEMBLER
* @see #AUTODETECT_MBEAN
* @see #AUTODETECT_NONE
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public void setAutodetectModeName(String constantName) {
Assert.hasText(constantName, "'constantName' must not be null or blank");
Integer mode = constants.get(constantName);
@ -253,7 +263,9 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
* @see #AUTODETECT_ASSEMBLER
* @see #AUTODETECT_MBEAN
* @see #AUTODETECT_NONE
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
*/
@Deprecated(since = "6.1")
public void setAutodetectMode(int autodetectMode) {
Assert.isTrue(constants.containsValue(autodetectMode),
"Only values of autodetect constants allowed");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -27,11 +27,13 @@ import org.springframework.jmx.export.naming.MetadataNamingStrategy;
* {@link ManagedResource}, {@link ManagedAttribute}, {@link ManagedOperation}, etc.
*
* <p>Sets a {@link MetadataNamingStrategy} and a {@link MetadataMBeanInfoAssembler}
* with an {@link AnnotationJmxAttributeSource}, and activates the
* {@link #AUTODETECT_ALL} mode by default.
* with an {@link AnnotationJmxAttributeSource}, and activates
* {@link #setAutodetect autodetection} by default.
*
* @author Juergen Hoeller
* @since 2.5
* @see #setAutodetect
* @see AnnotationJmxAttributeSource
*/
public class AnnotationMBeanExporter extends MBeanExporter {
@ -48,7 +50,7 @@ public class AnnotationMBeanExporter extends MBeanExporter {
public AnnotationMBeanExporter() {
setNamingStrategy(this.metadataNamingStrategy);
setAssembler(this.metadataAssembler);
setAutodetectMode(AUTODETECT_ALL);
setAutodetect(true);
}