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

Closes gh-3124
pull/3211/head
Stephane Nicoll 10 years ago
parent 18c65f6e63
commit e0787cbaf0

@ -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);

@ -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());

@ -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

@ -44,7 +44,7 @@ import org.springframework.util.Assert;
public class SpringApplicationAdminMXBeanRegistrar implements ApplicationContextAware,
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;
@ -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() {

@ -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);
}
Loading…
Cancel
Save