Ensure Weblogic and Websphere JMX are covered

To ensure an MBeanServer is available when needed you have to
look in JNDI before resorting to the JDK platform factory.

I had to copy some private code from Spring, but it seems
worth it.

Fixes gh-1092
This commit is contained in:
Dave Syer
2014-06-13 11:27:41 +01:00
parent 2c691e5ae5
commit 1bf256dd58
4 changed files with 107 additions and 14 deletions

View File

@@ -29,7 +29,6 @@ import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.util.StringUtils;
/**
@@ -65,9 +64,7 @@ public class EndpointMBeanExportAutoConfiguration {
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServerFactoryBean mbeanServer() {
MBeanServerFactoryBean factory = new MBeanServerFactoryBean();
factory.setLocateExistingServerIfPossible(true);
return factory;
public MBeanServer mbeanServer() {
return new JmxAutoConfiguration().mbeanServer();
}
}