Commit e0787cba authored by Stephane Nicoll's avatar Stephane Nicoll

Polish

Review 105039cd that still refer to "lifecycle" instead of "admin". In
particular, harmonized the configuration properties.

Closes gh-3124
parent 18c65f6e
...@@ -30,8 +30,8 @@ import org.springframework.core.env.Environment; ...@@ -30,8 +30,8 @@ import org.springframework.core.env.Environment;
import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.MBeanExporter;
/** /**
* Register a JMX component that allows to manage the lifecycle of the current * Register a JMX component that allows to administer the current application. Intended
* application. Intended for internal use only. * for internal use only.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.3.0 * @since 1.3.0
...@@ -39,19 +39,19 @@ import org.springframework.jmx.export.MBeanExporter; ...@@ -39,19 +39,19 @@ import org.springframework.jmx.export.MBeanExporter;
*/ */
@Configuration @Configuration
@AutoConfigureAfter(JmxAutoConfiguration.class) @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 { public class SpringApplicationAdminJmxAutoConfiguration {
/** /**
* The property to use to customize the {@code ObjectName} of the application * 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"; 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) @Autowired(required = false)
private MBeanExporter mbeanExporter; private MBeanExporter mbeanExporter;
...@@ -60,7 +60,7 @@ public class SpringApplicationAdminJmxAutoConfiguration { ...@@ -60,7 +60,7 @@ public class SpringApplicationAdminJmxAutoConfiguration {
private Environment environment; private Environment environment;
@Bean @Bean
public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycleRegistrar() public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
throws MalformedObjectNameException { throws MalformedObjectNameException {
String jmxName = this.environment String jmxName = this.environment
.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME); .getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);
......
...@@ -43,11 +43,11 @@ import static org.junit.Assert.fail; ...@@ -43,11 +43,11 @@ import static org.junit.Assert.fail;
*/ */
public class SpringApplicationLifecycleAutoConfigurationTests { 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 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 @Rule
public final ExpectedException thrown = ExpectedException.none(); public final ExpectedException thrown = ExpectedException.none();
...@@ -94,7 +94,7 @@ public class SpringApplicationLifecycleAutoConfigurationTests { ...@@ -94,7 +94,7 @@ public class SpringApplicationLifecycleAutoConfigurationTests {
this.mBeanServer.getObjectInstance(createObjectName(customJmxName)); this.mBeanServer.getObjectInstance(createObjectName(customJmxName));
} }
catch (InstanceNotFoundException ex) { 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.thrown.expect(InstanceNotFoundException.class); // Should not be exposed
this.mBeanServer.getObjectInstance(createDefaultObjectName()); this.mBeanServer.getObjectInstance(createDefaultObjectName());
......
...@@ -50,9 +50,9 @@ import org.springframework.boot.loader.tools.RunProcess; ...@@ -50,9 +50,9 @@ import org.springframework.boot.loader.tools.RunProcess;
@Mojo(name = "start", requiresProject = true, defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST) @Mojo(name = "start", requiresProject = true, defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST)
public class StartMojo extends AbstractRunMojo { 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 * The JMX name of the automatically deployed MBean managing the lifecycle of the
......
...@@ -44,7 +44,7 @@ import org.springframework.util.Assert; ...@@ -44,7 +44,7 @@ import org.springframework.util.Assert;
public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContextAware, public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContextAware,
InitializingBean, DisposableBean, ApplicationListener<ApplicationReadyEvent> { InitializingBean, DisposableBean, ApplicationListener<ApplicationReadyEvent> {
private static final Log logger = LogFactory.getLog(SpringApplicationLifecycle.class); private static final Log logger = LogFactory.getLog(SpringApplicationAdmin.class);
private ConfigurableApplicationContext applicationContext; private ConfigurableApplicationContext applicationContext;
...@@ -73,9 +73,9 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext ...@@ -73,9 +73,9 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); MBeanServer server = ManagementFactory.getPlatformMBeanServer();
server.registerMBean(new SpringApplicationLifecycle(), this.objectName); server.registerMBean(new SpringApplicationAdmin(), this.objectName);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Application lifecycle MBean registered with name '" logger.debug("Application Admin MBean registered with name '"
+ this.objectName + "'"); + this.objectName + "'");
} }
} }
...@@ -85,7 +85,7 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext ...@@ -85,7 +85,7 @@ public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContext
ManagementFactory.getPlatformMBeanServer().unregisterMBean(this.objectName); ManagementFactory.getPlatformMBeanServer().unregisterMBean(this.objectName);
} }
private class SpringApplicationLifecycle implements SpringApplicationAdminMXBean { private class SpringApplicationAdmin implements SpringApplicationAdminMXBean {
@Override @Override
public boolean isReady() { public boolean isReady() {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.context; package org.springframework.boot.admin;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
...@@ -44,9 +44,9 @@ import static org.junit.Assert.assertTrue; ...@@ -44,9 +44,9 @@ import static org.junit.Assert.assertTrue;
* *
* @author Stephane Nicoll * @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 @Rule
public final ExpectedException thrown = ExpectedException.none(); public final ExpectedException thrown = ExpectedException.none();
...@@ -81,7 +81,7 @@ public class SpringApplicationLifecycleRegistrarTests { ...@@ -81,7 +81,7 @@ public class SpringApplicationLifecycleRegistrarTests {
} }
catch (Exception ex) { catch (Exception ex) {
throw new IllegalStateException( 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 { ...@@ -134,7 +134,7 @@ public class SpringApplicationLifecycleRegistrarTests {
static class Config { static class Config {
@Bean @Bean
public SpringApplicationAdminMXBeanRegistrar springApplicationLifecycle() public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar()
throws MalformedObjectNameException { throws MalformedObjectNameException {
return new SpringApplicationAdminMXBeanRegistrar(OBJECT_NAME); return new SpringApplicationAdminMXBeanRegistrar(OBJECT_NAME);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment