Spring batch : MultiResourceItemReader
I want to use a org.springframework.batch.item.file.MultiResourceI temReader to read multiple XML files in a directory.
When I declare my bean of type MultiResourceItemReader, I have to reference a "ressources" property. So I reference the folder where my XML are stored with a wildcard to include all files, this is OK. But I also have to reference a ItemReader, which I do be referencing a StaxEventItemReader. Here is my problem: When I declare my StaxEventItemReader bean, I have to reference a "ressource" property, if not Spring won't instantiate the bean. Is there a way to reference a ItemReader prototype without "resource" attribute that will be assigned by the MultiResourceItemReader when iterating over his "ressources" attribute?
Here's a snippet:
<bean id="multiResourceReader" class="org.springframework.batch.item.file.MultiRe sourceItemReader">
<property name="resources" value="file:///mydata/data/*.xml" />
<property name="delegate" ref="xmlFileReader" />
</bean>
<bean id="xmlFileReader" class="org.springframework.batch.item.xml.StaxEven tItemReader">
<property name="fragmentRootElementName" value="orderNotification"/>
<!--<property name="resource" ref="iDontKnow"/>-->
<property name="fragmentDeserializer">
<bean class="org.springframework.batch.item.xml.oxm.Unma rshallingEventReaderDeserializer">
<constructor-arg>
<bean class="org.springframework.oxm.xmlbeans.XmlBeansMa rshaller"/>
</constructor-arg>
</bean>
</property>
</bean>