INT-2307
added MBeanExporterHelper to avoid conflicts with core MBeanExporter INT-2307 polishing INT-2307 polishing
This commit is contained in:
committed by
Mark Fisher
parent
6e6e972e35
commit
1a56747a8a
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration_.mbeanexporterhelper;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class Int2307Tests {
|
||||
|
||||
@Test
|
||||
public void testInt2307_DefaultMBeanExporter() throws Exception{
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("single-config.xml", this.getClass());
|
||||
context.destroy();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testInt2307_CustomMBeanExporter() throws Exception{
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("single-config-custom-exporter.xml", this.getClass());
|
||||
MBeanExporter exporter = context.getBean("myExporter", MBeanExporter.class);
|
||||
Set<String> excludedBeanNames = TestUtils.getPropertyValue(exporter, "excludedBeans", Set.class);
|
||||
assertTrue(excludedBeanNames.contains("rlr"));
|
||||
assertTrue(excludedBeanNames.contains("hvr"));
|
||||
assertTrue(excludedBeanNames.contains("x"));
|
||||
assertTrue(excludedBeanNames.contains("y"));
|
||||
assertTrue(excludedBeanNames.contains("foo")); // non SI bean
|
||||
context.destroy();
|
||||
}
|
||||
|
||||
public static class Foo{}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:mbean-server/>
|
||||
|
||||
<int-jmx:mbean-export/>
|
||||
|
||||
<bean id="myExporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="excludedBeans" value="foo"/>
|
||||
</bean>
|
||||
|
||||
<bean id="foo" class="org.springframework.integration_.mbeanexporterhelper.Int2307Tests.Foo"/>
|
||||
|
||||
<int:recipient-list-router id="rlr" input-channel="x">
|
||||
<int:recipient channel="y"/>
|
||||
</int:recipient-list-router>
|
||||
|
||||
<int:header-value-router id="hvr" input-channel="x" header-name="ghgf">
|
||||
<int:mapping value="foo" channel="y"/>
|
||||
</int:header-value-router>
|
||||
|
||||
<int:channel id="x" />
|
||||
<int:channel id="y" />
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,27 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:mbean-server />
|
||||
|
||||
<int-jmx:mbean-export />
|
||||
<context:mbean-export/>
|
||||
|
||||
<int:recipient-list-router id="rlr" input-channel="x">
|
||||
<int:recipient channel="y"/>
|
||||
</int:recipient-list-router>
|
||||
|
||||
<int:header-value-router id="hvr" input-channel="x" header-name="ghgf">
|
||||
<int:mapping value="foo" channel="y"/>
|
||||
</int:header-value-router>
|
||||
|
||||
<int:channel id="x" />
|
||||
<int:channel id="y" />
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user