The batch job is:
Reading from a csv file
Create an xml file for every record(line) in the csv with name Patent.ID.xml(where ID is a field i
I couldn't find a way to make Luca's solution to work, so I extended MultiResourceItemWriter this way:
public class MyMultipleItemWriter extends MultiResourceItemWriter<MyBeanXml>
{
@Override
public void write(List<? extends MyBeanXml> items) throws Exception
{
this.setResourceSuffixCreator(new MySuffixCreator(items.get(0).getField()));
super.write(items);
}
}
Create a ItemWriteListener, inject the multiResourceItemWriter bean and bound the listener to your step.
In ItemWriteListener.beforeWrite() create a new ResourceSuffixCreator object using the item your are going to write as base to create resource extension (suffix).
MultiResourceItemWriter.resource probably need to be changed as file:xml/ because 1.xml, 2.xml and so on will be appended using custom ResourceSuffixCreator dinamically created for every item you are writing.
This solution is dirty and (probably) works due to commit-interval=1; if you change my answer (probably) will fail.
I hope I was clear, English is not my native language.