spring-batch
spring-batch copied to clipboard
MongoItemWriter - Add protected getters for "delete" and "collection" properties. Fixes #3973
trafficstars
This PR provides protected getter methods for MongoItemWriter's delete and collection properties. Thus, any custom implementation of MongoItemWriter will be able to extend it's doWrite logic regards to these two properties.
Properties itself are still have private access modifier, but they become accessible from subclass via getters as previously did for template in cae2cabdce41ae9a67d4e469fb8b82ff4945a7d9
This PR is related to #3973.
Without this change, developers are not be able to write custom implementation something like
public class CustomMongoItemWriter<T> extends MongoItemWriter<T> {
@Override
protected void doWrite(List<? extends T> items) {
if (isDelete()) {
super.doWrite(items);
} else {
if(getCollection().contains("archive")) {
// Batch insert without checking existence
} else {
super.doWrite(items);
}
}
}
}