diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java index 41831df446..5ade73787b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java @@ -30,8 +30,8 @@ import org.springframework.core.env.Environment; import org.springframework.jmx.export.MBeanExporter; /** - * Register a JMX component that allows to manage the lifecycle of the current - * application. Intended for internal use only. + * Register a JMX component that allows to administer the current application. Intended + * for internal use only. * * @author Stephane Nicoll * @since 1.3.0 @@ -39,19 +39,19 @@ import org.springframework.jmx.export.MBeanExporter; */ @Configuration @AutoConfigureAfter(JmxAutoConfiguration.class) -@ConditionalOnProperty(value = "spring.context.lifecycle.enabled", havingValue = "true", matchIfMissing = false) +@ConditionalOnProperty(prefix = "spring.application.admin", value = "enabled", havingValue = "true", matchIfMissing = false) public class SpringApplicationAdminJmxAutoConfiguration { /** * The property to use to customize the {@code ObjectName} of the application - * lifecycle mbean. + * admin mbean. */ private static final String JMX_NAME_PROPERTY = "spring.application.admin.jmx-name"; /** - * The default {@code ObjectName} of the application lifecycle mbean. + * The default {@code ObjectName} of the application admin mbean. */ - private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=SpringApplicationAdmin,name=springApplicationAdmin"; + private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication"; @Autowired(required = false) private MBeanExporter mbeanExporter; @@ -60,7 +60,7 @@ public class SpringApplicationAdminJmxAutoConfiguration { private Environment environment; @Bean - public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycleRegistrar() + public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar() throws MalformedObjectNameException { String jmxName = this.environment .getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationLifecycleAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationLifecycleAutoConfigurationTests.java index 1d9929131c..c952b49e4b 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationLifecycleAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationLifecycleAutoConfigurationTests.java @@ -43,11 +43,11 @@ import static org.junit.Assert.fail; */ public class SpringApplicationLifecycleAutoConfigurationTests { - private static final String ENABLE_LIFECYCLE_PROP = "spring.context.lifecycle.enabled=true"; + private static final String ENABLE_LIFECYCLE_PROP = "spring.application.admin.enabled=true"; private static final String JMX_NAME_PROPERTY = "spring.application.admin.jmx-name"; - private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=SpringApplicationAdmin,name=springApplicationAdmin"; + private static final String DEFAULT_JMX_NAME = "org.springframework.boot:type=Admin,name=SpringApplication"; @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -94,7 +94,7 @@ public class SpringApplicationLifecycleAutoConfigurationTests { this.mBeanServer.getObjectInstance(createObjectName(customJmxName)); } catch (InstanceNotFoundException ex) { - fail("lifecycle MBean should have been exposed with custom name"); + fail("Admin MBean should have been exposed with custom name"); } this.thrown.expect(InstanceNotFoundException.class); // Should not be exposed this.mBeanServer.getObjectInstance(createDefaultObjectName()); diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java index 904d314d74..949648c88e 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java @@ -50,9 +50,9 @@ import org.springframework.boot.loader.tools.RunProcess; @Mojo(name = "start", requiresProject = true, defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST) public class StartMojo extends AbstractRunMojo { - private static final String ENABLE_MBEAN_PROPERTY = "--spring.context.lifecycle.enabled=true"; + private static final String ENABLE_MBEAN_PROPERTY = "--spring.application.admin.enabled=true"; - private static final String JMX_NAME_PROPERTY_PREFIX = "--spring.context.lifecycle.jmx-name="; + private static final String JMX_NAME_PROPERTY_PREFIX = "--spring.application.admin.jmx-name="; /** * The JMX name of the automatically deployed MBean managing the lifecycle of the diff --git a/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrar.java b/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrar.java index e97528682e..602c45b4d6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrar.java +++ b/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrar.java @@ -44,7 +44,7 @@ import org.springframework.util.Assert; public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContextAware, InitializingBean, DisposableBean, ApplicationListener { - private static final Log logger = LogFactory.getLog(SpringApplicationLifecycle.class); + private static final Log logger = LogFactory.getLog(SpringApplicationAdmin.class); private ConfigurableApplicationContext applicationContext; @@ -73,9 +73,9 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext @Override public void afterPropertiesSet() throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - server.registerMBean(new SpringApplicationLifecycle(), this.objectName); + server.registerMBean(new SpringApplicationAdmin(), this.objectName); if (logger.isDebugEnabled()) { - logger.debug("Application lifecycle MBean registered with name '" + logger.debug("Application Admin MBean registered with name '" + this.objectName + "'"); } } @@ -85,7 +85,7 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext ManagementFactory.getPlatformMBeanServer().unregisterMBean(this.objectName); } - private class SpringApplicationLifecycle implements SpringApplicationAdminMXBean { + private class SpringApplicationAdmin implements SpringApplicationAdminMXBean { @Override public boolean isReady() { diff --git a/spring-boot/src/test/java/org/springframework/boot/context/SpringApplicationLifecycleRegistrarTests.java b/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java similarity index 94% rename from spring-boot/src/test/java/org/springframework/boot/context/SpringApplicationLifecycleRegistrarTests.java rename to spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java index 974512bdcb..df5dece21e 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/SpringApplicationLifecycleRegistrarTests.java +++ b/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.context; +package org.springframework.boot.admin; import java.lang.management.ManagementFactory; @@ -44,9 +44,9 @@ import static org.junit.Assert.assertTrue; * * @author Stephane Nicoll */ -public class SpringApplicationLifecycleRegistrarTests { +public class SpringApplicationAdminMXBeanRegistrarTests { - private static final String OBJECT_NAME = "org.springframework.boot:type=Test,name=springApplicationLifecycle"; + private static final String OBJECT_NAME = "org.springframework.boot:type=Test,name=SpringApplication"; @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -81,7 +81,7 @@ public class SpringApplicationLifecycleRegistrarTests { } catch (Exception ex) { throw new IllegalStateException( - "Could not contact spring application lifecycle bean", ex); + "Could not contact spring application admin bean", ex); } } }); @@ -134,7 +134,7 @@ public class SpringApplicationLifecycleRegistrarTests { static class Config { @Bean - public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycle() + public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar() throws MalformedObjectNameException { return new SpringApplicationAdminMXBeanRegistrar(OBJECT_NAME); }