Answer: I ended up extending MongoItemReader
and adding a getter/setter for collection
. This allowed me to delegate the stuff I didn't care about, and modify doPageRead()
to set the collection in my custom query:
@Scope("step")
public class MyMongoItemReader extends MongoItemReader<Object> {
public void setCollection(String collection) {
this.collection = collection;
}
@Override
protected Iterator<Object> doPageRead() {
...
Query mongoQuery = // set query
...
return (Iterator<Object>) //
template.find(mongoQuery, Object.class, this.collection).iterator();
}
}