10.3 Configuring a Splitter using XML

A splitter can be configured through XML as follows:

<channel id="inputChannel"/>

<splitter id="splitter" 1
  ref="splitterBean" 2
  method="split" 3
  input-channel="inputChannel" 4
  output-channel="outputChannel" 5/>

<channel id="outputChannel"/>

<beans:bean id="splitterBean" class="sample.PojoSplitter"/>

1

The id of the splitter is optional.

2

A reference to a bean defined in the application context. The bean must implement the splitting logic as described in the section above. Optional. If reference to a bean is not provided, then it is assumed that the payload of the Message that arrived on the input-channel is an implementation of java.util.Collection and the default splitting logic will be applied on such Collection, incorporating each individual element into a Message and depositing it on the output-channel.

3

The method (defined on the bean specified above) that implements the splitting logic. Optional.

4

The input channel of the splitter. Required.

5

The channel where the splitter will send the results of splitting the incoming message. Optional (because incoming messages can specify a reply channel themselves).

Using a "ref" attribute is generally recommended if the custom splitter handler implementation can be reused in other <splitter> definitions. However if the custom splitter handler implementation should be scoped to a single definition of the <splitter>, you can configure an inner bean definition:

<splitter id="testSplitter" input-channel="inChannel" method="split"
								output-channel="outChannel">
	<beans:bean class="org.foo.TestSplitter"/>
</spliter>

[Note]Note

Using both a "ref" attribute and an inner handler definition in the same <splitter> configuration is not allowed, as it creates an ambiguous condition and will result in an Exception being thrown.