Commit 08bc306a authored by Stephane Nicoll's avatar Stephane Nicoll

Guard IntegrationJmxConfiguration if no mBeanServer is available

Closes gh-12966
parent 4585bc84
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
......@@ -70,6 +71,7 @@ public class IntegrationAutoConfiguration {
@Configuration
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
@ConditionalOnBean(MBeanServer.class)
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
protected static class IntegrationJmxConfiguration
implements EnvironmentAware, BeanFactoryAware {
......
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -82,6 +82,16 @@ public class IntegrationAutoConfigurationTests {
.isEmpty();
}
@Test
public void noMBeanServerAvailable() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(IntegrationAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(TestGateway.class)).isNotNull();
assertThat(this.context.getBean(IntegrationComponentScanAutoConfiguration.class))
.isNotNull();
}
@Test
public void parentContext() {
load();
......
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