Skip to content

Commit 52c1927

Browse files
committed
Deprecate MBeanExporter's AUTODETECT constants
Closes gh-30874
1 parent 0d5a7db commit 52c1927

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,31 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
105105

106106
/**
107107
* Autodetection mode indicating that no autodetection should be used.
108+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
108109
*/
110+
@Deprecated(since = "6.1")
109111
public static final int AUTODETECT_NONE = 0;
110112

111113
/**
112114
* Autodetection mode indicating that only valid MBeans should be autodetected.
115+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
113116
*/
117+
@Deprecated(since = "6.1")
114118
public static final int AUTODETECT_MBEAN = 1;
115119

116120
/**
117121
* Autodetection mode indicating that only the {@link MBeanInfoAssembler} should be able
118122
* to autodetect beans.
123+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
119124
*/
125+
@Deprecated(since = "6.1")
120126
public static final int AUTODETECT_ASSEMBLER = 2;
121127

122128
/**
123129
* Autodetection mode indicating that all autodetection mechanisms should be used.
130+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
124131
*/
132+
@Deprecated(since = "6.1")
125133
public static final int AUTODETECT_ALL = AUTODETECT_MBEAN | AUTODETECT_ASSEMBLER;
126134

127135

@@ -236,7 +244,9 @@ public void setAutodetect(boolean autodetect) {
236244
* @see #AUTODETECT_ASSEMBLER
237245
* @see #AUTODETECT_MBEAN
238246
* @see #AUTODETECT_NONE
247+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
239248
*/
249+
@Deprecated(since = "6.1")
240250
public void setAutodetectModeName(String constantName) {
241251
Assert.hasText(constantName, "'constantName' must not be null or blank");
242252
Integer mode = constants.get(constantName);
@@ -253,7 +263,9 @@ public void setAutodetectModeName(String constantName) {
253263
* @see #AUTODETECT_ASSEMBLER
254264
* @see #AUTODETECT_MBEAN
255265
* @see #AUTODETECT_NONE
266+
* @deprecated as of 6.1, in favor of the {@link #setAutodetect "autodetect" flag}
256267
*/
268+
@Deprecated(since = "6.1")
257269
public void setAutodetectMode(int autodetectMode) {
258270
Assert.isTrue(constants.containsValue(autodetectMode),
259271
"Only values of autodetect constants allowed");

spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationMBeanExporter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,11 +27,13 @@
2727
* {@link ManagedResource}, {@link ManagedAttribute}, {@link ManagedOperation}, etc.
2828
*
2929
* <p>Sets a {@link MetadataNamingStrategy} and a {@link MetadataMBeanInfoAssembler}
30-
* with an {@link AnnotationJmxAttributeSource}, and activates the
31-
* {@link #AUTODETECT_ALL} mode by default.
30+
* with an {@link AnnotationJmxAttributeSource}, and activates
31+
* {@link #setAutodetect autodetection} by default.
3232
*
3333
* @author Juergen Hoeller
3434
* @since 2.5
35+
* @see #setAutodetect
36+
* @see AnnotationJmxAttributeSource
3537
*/
3638
public class AnnotationMBeanExporter extends MBeanExporter {
3739

@@ -48,7 +50,7 @@ public class AnnotationMBeanExporter extends MBeanExporter {
4850
public AnnotationMBeanExporter() {
4951
setNamingStrategy(this.metadataNamingStrategy);
5052
setAssembler(this.metadataAssembler);
51-
setAutodetectMode(AUTODETECT_ALL);
53+
setAutodetect(true);
5254
}
5355

5456

0 commit comments

Comments
 (0)