Commit a4ba8f61 authored by Stephane Nicoll's avatar Stephane Nicoll

Backport 6dd84159

While working on gh-5309, a regression was introduced and fixed right the
way on master. Unfortunately, the fix wasn't applied to `1.3.x` as it
should have been.

This commit applies 6dd84159 to `1.3.x`

Closes gh-5901
parent 3891b242
...@@ -39,7 +39,6 @@ import org.springframework.integration.monitor.IntegrationMBeanExporter; ...@@ -39,7 +39,6 @@ import org.springframework.integration.monitor.IntegrationMBeanExporter;
@Configuration @Configuration
@ConditionalOnClass(EnableIntegration.class) @ConditionalOnClass(EnableIntegration.class)
@AutoConfigureAfter(JmxAutoConfiguration.class) @AutoConfigureAfter(JmxAutoConfiguration.class)
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
public class IntegrationAutoConfiguration { public class IntegrationAutoConfiguration {
@Configuration @Configuration
...@@ -50,6 +49,7 @@ public class IntegrationAutoConfiguration { ...@@ -50,6 +49,7 @@ public class IntegrationAutoConfiguration {
@Configuration @Configuration
@ConditionalOnClass(EnableIntegrationMBeanExport.class) @ConditionalOnClass(EnableIntegrationMBeanExport.class)
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT) @ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
@EnableIntegrationMBeanExport(defaultDomain = "${spring.jmx.default-domain:}", server = "${spring.jmx.server:mbeanServer}") @EnableIntegrationMBeanExport(defaultDomain = "${spring.jmx.default-domain:}", server = "${spring.jmx.server:mbeanServer}")
protected static class IntegrationJmxConfiguration { protected static class IntegrationJmxConfiguration {
} }
......
...@@ -30,6 +30,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext ...@@ -30,6 +30,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.integration.support.channel.HeaderChannelRegistry; import org.springframework.integration.support.channel.HeaderChannelRegistry;
import org.springframework.test.context.support.TestPropertySourceUtils; import org.springframework.test.context.support.TestPropertySourceUtils;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
...@@ -94,6 +95,29 @@ public class IntegrationAutoConfigurationTests { ...@@ -94,6 +95,29 @@ public class IntegrationAutoConfigurationTests {
this.context.close(); this.context.close();
} }
@Test
public void jmxIntegrationEnabledByDefault() {
load();
MBeanServer mBeanServer = this.context.getBean(MBeanServer.class);
assertDomains(mBeanServer, true, "org.springframework.integration",
"org.springframework.integration.monitor");
}
@Test
public void disableJmxIntegration() {
load("spring.jmx.enabled=false");
assertEquals(this.context.getBeansOfType(MBeanServer.class), hasSize(0));
}
@Test
public void customizeJmxDomain() {
load("spring.jmx.default-domain=org.foo");
MBeanServer mBeanServer = this.context.getBean(MBeanServer.class);
assertDomains(mBeanServer, true, "org.foo");
assertDomains(mBeanServer, false, "org.springframework.integration",
"org.springframework.integration.monitor");
}
private static void assertDomains(MBeanServer mBeanServer, boolean expected, private static void assertDomains(MBeanServer mBeanServer, boolean expected,
String... domains) { String... domains) {
List<String> actual = Arrays.asList(mBeanServer.getDomains()); List<String> actual = Arrays.asList(mBeanServer.getDomains());
......
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