RESOLVED - BATCH-554: *StepFactoryBeans should have a list of exceptions that do and don't cause rollback.
added sample for noRollbackForExceptionClasses (2nd step in skipSample)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package org.springframework.batch.sample.item.writer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.AbstractItemWriter;
|
||||
import org.springframework.batch.item.validator.ValidationException;
|
||||
|
||||
/**
|
||||
* Remembers all items written - useful for testing.
|
||||
*/
|
||||
public class ItemTrackingItemWriter extends AbstractItemWriter {
|
||||
|
||||
private List items = new ArrayList();
|
||||
|
||||
private int failure = -1;
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
public void write(Object item) throws Exception {
|
||||
|
||||
items.add(item);
|
||||
if (++counter == failure) {
|
||||
throw new ValidationException("validation failed");
|
||||
}
|
||||
}
|
||||
|
||||
public List getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setValidationFailure(int failure) {
|
||||
this.failure = failure;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user