Dec 14th, 2011, 11:25 AM
Generalize MutiResourceItemReader to take an Iterator<Resource>
I've got a situation where I want to batch process records coming from a web service in a "paged" fashion, e.g. the first request returns a few records, then I request the next page which returns the next few records.
It seems the best way to batch process data coming from such a source would be to use something like the MultiResourceItemReader with a delegate doing the actual reading of records. Instead of passing a Resource to the MultiResourceItemReader, it might take something that implements java.util.Iterator<Resource>, for instance and that produces Resources until it determines that last Resource has been served (at which point hasNext() returns false, as with any iterator).
Is this something new? Would the gurus here recommend generalizing MultiResourceItemReader, or making a new ItemReader instead (or simply adding an Iterator<Resource> property and asserting that either that or the Resource one is set)? I'd be happy to do the work and submit a patch, just want to make sure it fits within the Spring Batch philosophy