INT-3295 Add Doc For Global MessageConverter

JIRA: https://jira.springsource.org/browse/INT-3295

Plus test.
This commit is contained in:
Gary Russell
2014-02-12 14:12:27 -05:00
parent 25489adaa3
commit ccb0b8aa8e
3 changed files with 30 additions and 0 deletions

View File

@@ -166,6 +166,15 @@ public class ChannelParserTests {
assertTrue(TestUtils.getPropertyValue(channel, "messageConverter") instanceof UselessMessageConverter);
}
@Test
public void testDatatypeChannelGlobalConverter() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("channelParserGlobalConverterTests.xml", this
.getClass());
MessageChannel channel = context.getBean("integerChannel", MessageChannel.class);
context.close();
assertTrue(TestUtils.getPropertyValue(channel, "messageConverter") instanceof UselessMessageConverter);
}
@Test
public void testDatatypeChannelWithAssignableSubTypes() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("channelParserTests.xml", this

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd">
<channel id="integerChannel" datatype="java.lang.Integer">
<queue capacity="10" />
</channel>
<beans:bean id="datatypeChannelMessageConverter"
class="org.springframework.integration.channel.config.ChannelParserTests$UselessMessageConverter" />
</beans:beans>

View File

@@ -521,6 +521,11 @@ payload to an Integer.
payload, or a full <classname>Message</classname> object. If the latter, the converter must
be careful to copy all the headers from the inbound message.
</para>
<para>
Alternatively, declare a <code>&lt;bean/&gt;</code> of type <interfacename>MessageConverter</interfacename>
with an id <code>"datatypeChannelMessageConverter"</code> and that converter will be used by
all channels with a <code>datatype</code>.
</para>
</section>
<section id="channel-configuration-queuechannel">