INT-2434 Fix How input-channels are auto-created

Channel creation logic for channels that are not explicitly defined but identified via an 'input-channel' attribute on the corresponding endpoint is now done by ChannelInitializer - an InitializingBean implementation.

This bean plays a role of pre-instantiator since it is instantiated and initialized as the very first bean of all SI beans using AbstractIntegrationNamespaceHandler

INT-2434-v3 polishing

INT-2434-v3 polishing, changed ChannelCreatingFactoryBean from BeanFactoryPostProcessor to BeanFactoryAware

INT-2434 polishing

fix the test

changed the default name of the CHANNEL_CREATOR_BEAN_NAME to a simple name

added additional test

changed ChannelCreatingFactoryBean from FactoryBean to InitializingBean and renamed it to ChannelInitializer

INT-2434 added test validating how automatic channel creation can be disabled

INT-2434 polished based on the latest PR comments

INT-2434-v3 polishing based on comments and discussions with @markfisher and @garyrussell. Added support for disabling aut-creatioin of channels

INT-2434-v3 polished based on @garyrussell last comments

INT-2434-v3 final polishing
This commit is contained in:
Oleg Zhurakousky
2012-02-09 17:56:27 -05:00
committed by Gary Russell
parent 93c0f6592d
commit 458eac43da
16 changed files with 456 additions and 66 deletions

View File

@@ -34,9 +34,10 @@ import org.springframework.jmx.export.MBeanExporter;
*/
public class Int2307Tests {
@SuppressWarnings("unchecked")
@Test
public void testInt2307_DefaultMBeanExporter() throws Exception{
new ClassPathXmlApplicationContext("single-config.xml", this.getClass());
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("single-config.xml", this.getClass());
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
assertEquals(1, servers.size());
MBeanServer server = servers.get(0);
@@ -61,6 +62,11 @@ public class Int2307Tests {
assertEquals(0xf, bits);
assertEquals(4, count);
Class<?> clazz = Class.forName("org.springframework.integration.jmx.config.MBeanExporterHelper");
Object mBeanExporterHelper = context.getBean(clazz);
assertTrue(((Set<String>)TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames")).contains("z"));
assertTrue(((Set<String>)TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames")).contains("zz"));
// make sure there are no duplicate MBean ObjectNames if 2 contexts loaded from same config
new ClassPathXmlApplicationContext("single-config.xml", this.getClass());
}
@@ -76,7 +82,10 @@ public class Int2307Tests {
assertTrue(excludedBeanNames.contains("x"));
assertTrue(excludedBeanNames.contains("y"));
assertTrue(excludedBeanNames.contains("foo")); // non SI bean
Class<?> clazz = Class.forName("org.springframework.integration.jmx.config.MBeanExporterHelper");
Object mBeanExporterHelper = context.getBean(clazz);
assertTrue(((Set<String>)TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames")).contains("z"));
}
public static class Foo{}
}

View File

@@ -24,18 +24,20 @@
<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" />
<int:service-activator input-channel="z" expression="''"/>
</beans>

View File

@@ -22,16 +22,26 @@
</util:properties>
<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" />
<int:service-activator input-channel="z" expression="''"/>
<int:service-activator input-channel="${zz}" expression="''"/>
<util:properties id="placeholders">
<prop key="zz">zz</prop>
</util:properties>
<context:property-placeholder properties-ref="placeholders"/>
</beans>