This commit is contained in:
Phillip Webb 2014-06-15 09:09:06 -07:00
parent 2f12dc823c
commit a374929c90
4 changed files with 30 additions and 30 deletions

View File

@ -20,6 +20,7 @@ import javax.management.MBeanServer;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -87,7 +88,15 @@ public class JmxAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(MBeanServer.class) @ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() { public MBeanServer mbeanServer() {
return SpecificPlatform.get().getMBeanServer(); SpecificPlatform platform = SpecificPlatform.get();
if (platform != null) {
return platform.getMBeanServer();
}
MBeanServerFactoryBean factory = new MBeanServerFactoryBean();
factory.setLocateExistingServerIfPossible(true);
factory.afterPropertiesSet();
return factory.getObject();
} }
@EnableMBeanExport(defaultDomain = "${spring.jmx.default_domain:}", server = "${spring.jmx.server:mbeanServer}") @EnableMBeanExport(defaultDomain = "${spring.jmx.default_domain:}", server = "${spring.jmx.server:mbeanServer}")
@ -112,16 +121,6 @@ public class JmxAutoConfiguration {
public FactoryBean<MBeanServer> getMBeanServerFactory() { public FactoryBean<MBeanServer> getMBeanServerFactory() {
return new WebSphereMBeanServerFactoryBean(); return new WebSphereMBeanServerFactoryBean();
} }
},
GENERIC("org.springframework.jmx.support.MBeanServerFactoryBean") {
@Override
public FactoryBean<MBeanServer> getMBeanServerFactory() {
MBeanServerFactoryBean factory = new MBeanServerFactoryBean();
factory.setLocateExistingServerIfPossible(true);
factory.afterPropertiesSet();
return factory;
}
}; };
private final String identifyingClass; private final String identifyingClass;
@ -131,9 +130,12 @@ public class JmxAutoConfiguration {
} }
public MBeanServer getMBeanServer() { public MBeanServer getMBeanServer() {
Object server;
try { try {
server = getMBeanServerFactory().getObject(); FactoryBean<?> factory = getMBeanServerFactory();
if (factory instanceof InitializingBean) {
((InitializingBean) factory).afterPropertiesSet();
}
Object server = factory.getObject();
Assert.isInstanceOf(MBeanServer.class, server); Assert.isInstanceOf(MBeanServer.class, server);
return (MBeanServer) server; return (MBeanServer) server;
} }

View File

@ -169,9 +169,10 @@ public class CommandRunner implements Iterable<Command> {
try { try {
ExitStatus result = run(argsWithoutDebugFlags); ExitStatus result = run(argsWithoutDebugFlags);
// The caller will hang up if it gets a non-zero status // The caller will hang up if it gets a non-zero status
return result == null ? 0 if (result != null && result.isHangup()) {
: result.isHangup() ? (result.getCode() > 0 ? result.getCode() : 0) return (result.getCode() > 0 ? result.getCode() : 0);
: 0; }
return 0;
} }
catch (NoArgumentsException ex) { catch (NoArgumentsException ex) {
showUsage(); showUsage();

View File

@ -27,12 +27,12 @@ package org.springframework.boot.cli.command.status;
public final class ExitStatus { public final class ExitStatus {
/** /**
* Generic "OK" exit status with zero exit code and hangup=fa;se * Generic "OK" exit status with zero exit code and {@literal hangup=false}
*/ */
public static ExitStatus OK = new ExitStatus(0, "OK"); public static ExitStatus OK = new ExitStatus(0, "OK");
/** /**
* Generic "not OK" exit status with non-zero exit code and hangup=true * Generic "not OK" exit status with non-zero exit code and {@literal hangup=true}
*/ */
public static ExitStatus ERROR = new ExitStatus(-1, "ERROR", true); public static ExitStatus ERROR = new ExitStatus(-1, "ERROR", true);
@ -44,7 +44,6 @@ public final class ExitStatus {
/** /**
* Create a new ExitStatus with an exit code and name as specified. * Create a new ExitStatus with an exit code and name as specified.
*
* @param code the exit code * @param code the exit code
* @param name the name * @param name the name
*/ */
@ -90,7 +89,6 @@ public final class ExitStatus {
/** /**
* Convert the existing code to a hangup. * Convert the existing code to a hangup.
*
* @return a new ExitStatus with hangup=true * @return a new ExitStatus with hangup=true
*/ */
public ExitStatus hangup() { public ExitStatus hangup() {

View File

@ -265,13 +265,12 @@ executable jar file. For example:
$ spring jar my-app.jar *.groovy $ spring jar my-app.jar *.groovy
---- ----
The resulting jar will contain the classes produced by compiling the The resulting jar will contain the classes produced by compiling the application and all
application and all of the application's dependencies so that it can of the application's dependencies so that it can then be run using `java -jar`. The jar
then be run using `java -jar`. The jar file will also contain entries file will also contain entries from the application's classpath. You can add explicit
from the application's classpath. You can add explicit paths to the paths to the jar using `--include` and `--exclude` (both are comma separated, and both
jar using `--include` and `--exclude` (both are comma separated, and accept prefixes to the values ``+'' and ``-'' to signify that they should be removed from
both accept prefixes to the values "+" and "-" to signify that they the defaults). The default includes are
shoudl be removed from the defaults). The default includes are
[indent=0] [indent=0]
---- ----