Skip to content

Commit e0787cb

Browse files
committed
Polish
Review 105039c that still refer to "lifecycle" instead of "admin". In particular, harmonized the configuration properties. Closes gh-3124
1 parent 18c65f6 commit e0787cb

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@
3030
import org.springframework.jmx.export.MBeanExporter;
3131

3232
/**
33-
* Register a JMX component that allows to manage the lifecycle of the current
34-
* application. Intended for internal use only.
33+
* Register a JMX component that allows to administer the current application. Intended
34+
* for internal use only.
3535
*
3636
* @author Stephane Nicoll
3737
* @since 1.3.0
3838
* @see SpringApplicationAdminMXBean
3939
*/
4040
@Configuration
4141
@AutoConfigureAfter(JmxAutoConfiguration.class)
42-
@ConditionalOnProperty(value = "spring.context.lifecycle.enabled", havingValue = "true", matchIfMissing = false)
42+
@ConditionalOnProperty(prefix = "spring.application.admin", value = "enabled", havingValue = "true", matchIfMissing = false)
4343
public class SpringApplicationAdminJmxAutoConfiguration {
4444

4545
/**
4646
* The property to use to customize the {@code ObjectName} of the application
47-
* lifecycle mbean.
47+
* admin mbean.
4848
*/
4949
private static final String JMX_NAME_PROPERTY = "spring.application.admin.jmx-name";
5050

5151
/**
52-
* The default {@code ObjectName} of the application lifecycle mbean.
52+
* The default {@code ObjectName} of the application admin mbean.
5353
*/
54-
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=SpringApplicationAdmin,name=springApplicationAdmin";
54+
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
5555

5656
@Autowired(required = false)
5757
private MBeanExporter mbeanExporter;
@@ -60,7 +60,7 @@ public class SpringApplicationAdminJmxAutoConfiguration {
6060
private Environment environment;
6161

6262
@Bean
63-
public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycleRegistrar()
63+
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
6464
throws MalformedObjectNameException {
6565
String jmxName = this.environment
6666
.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationLifecycleAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
*/
4444
public class SpringApplicationLifecycleAutoConfigurationTests {
4545

46-
private static final String ENABLE_LIFECYCLE_PROP = "spring.context.lifecycle.enabled=true";
46+
private static final String ENABLE_LIFECYCLE_PROP = "spring.application.admin.enabled=true";
4747

4848
private static final String JMX_NAME_PROPERTY = "spring.application.admin.jmx-name";
4949

50-
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=SpringApplicationAdmin,name=springApplicationAdmin";
50+
private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication";
5151

5252
@Rule
5353
public final ExpectedException thrown = ExpectedException.none();
@@ -94,7 +94,7 @@ public void registerWithCustomJmxName() throws InstanceNotFoundException {
9494
this.mBeanServer.getObjectInstance(createObjectName(customJmxName));
9595
}
9696
catch (InstanceNotFoundException ex) {
97-
fail("lifecycle MBean should have been exposed with custom name");
97+
fail("Admin MBean should have been exposed with custom name");
9898
}
9999
this.thrown.expect(InstanceNotFoundException.class); // Should not be exposed
100100
this.mBeanServer.getObjectInstance(createDefaultObjectName());

spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
@Mojo(name = "start", requiresProject = true, defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST)
5151
public class StartMojo extends AbstractRunMojo {
5252

53-
private static final String ENABLE_MBEAN_PROPERTY = "--spring.context.lifecycle.enabled=true";
53+
private static final String ENABLE_MBEAN_PROPERTY = "--spring.application.admin.enabled=true";
5454

55-
private static final String JMX_NAME_PROPERTY_PREFIX = "--spring.context.lifecycle.jmx-name=";
55+
private static final String JMX_NAME_PROPERTY_PREFIX = "--spring.application.admin.jmx-name=";
5656

5757
/**
5858
* The JMX name of the automatically deployed MBean managing the lifecycle of the

spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrar.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContextAware,
4545
InitializingBean, DisposableBean, ApplicationListener<ApplicationReadyEvent> {
4646

47-
private static final Log logger = LogFactory.getLog(SpringApplicationLifecycle.class);
47+
private static final Log logger = LogFactory.getLog(SpringApplicationAdmin.class);
4848

4949
private ConfigurableApplicationContext applicationContext;
5050

@@ -73,9 +73,9 @@ public void onApplicationEvent(ApplicationReadyEvent event) {
7373
@Override
7474
public void afterPropertiesSet() throws Exception {
7575
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
76-
server.registerMBean(new SpringApplicationLifecycle(), this.objectName);
76+
server.registerMBean(new SpringApplicationAdmin(), this.objectName);
7777
if (logger.isDebugEnabled()) {
78-
logger.debug("Application lifecycle MBean registered with name '"
78+
logger.debug("Application Admin MBean registered with name '"
7979
+ this.objectName + "'");
8080
}
8181
}
@@ -85,7 +85,7 @@ public void destroy() throws Exception {
8585
ManagementFactory.getPlatformMBeanServer().unregisterMBean(this.objectName);
8686
}
8787

88-
private class SpringApplicationLifecycle implements SpringApplicationAdminMXBean {
88+
private class SpringApplicationAdmin implements SpringApplicationAdminMXBean {
8989

9090
@Override
9191
public boolean isReady() {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.context;
17+
package org.springframework.boot.admin;
1818

1919
import java.lang.management.ManagementFactory;
2020

@@ -44,9 +44,9 @@
4444
*
4545
* @author Stephane Nicoll
4646
*/
47-
public class SpringApplicationLifecycleRegistrarTests {
47+
public class SpringApplicationAdminMXBeanRegistrarTests {
4848

49-
private static final String OBJECT_NAME = "org.springframework.boot:type=Test,name=springApplicationLifecycle";
49+
private static final String OBJECT_NAME = "org.springframework.boot:type=Test,name=SpringApplication";
5050

5151
@Rule
5252
public final ExpectedException thrown = ExpectedException.none();
@@ -81,7 +81,7 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
8181
}
8282
catch (Exception ex) {
8383
throw new IllegalStateException(
84-
"Could not contact spring application lifecycle bean", ex);
84+
"Could not contact spring application admin bean", ex);
8585
}
8686
}
8787
});
@@ -134,7 +134,7 @@ private ObjectName createObjectName(String jmxName) {
134134
static class Config {
135135

136136
@Bean
137-
public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycle()
137+
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
138138
throws MalformedObjectNameException {
139139
return new SpringApplicationAdminMXBeanRegistrar(OBJECT_NAME);
140140
}

0 commit comments

Comments
 (0)