BATCH-220: Half way to rename StepHandler -> Tasklet
This commit is contained in:
@@ -12,16 +12,22 @@ import org.springframework.batch.item.validator.ValidationException;
|
||||
public class ItemTrackingItemWriter<T> implements ItemWriter<T> {
|
||||
|
||||
private List<T> items = new ArrayList<T>();
|
||||
|
||||
private T failed = null;
|
||||
|
||||
private int failure = -1;
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
public void write(List<? extends T> item) throws Exception {
|
||||
items.addAll(item);
|
||||
public void write(List<? extends T> items) throws Exception {
|
||||
if (failed!=null && items.contains(failed)) {
|
||||
throw new ValidationException("validation failed");
|
||||
}
|
||||
this.items.addAll(items);
|
||||
int current = counter;
|
||||
counter += item.size();
|
||||
counter += items.size();
|
||||
if (current < failure && counter >= failure) {
|
||||
failed = items.get(failure-current-1);
|
||||
throw new ValidationException("validation failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.handler.StepHandler;
|
||||
import org.springframework.batch.core.step.tasklet.StepHandler;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.handler.StepHandler;
|
||||
import org.springframework.batch.core.step.tasklet.StepHandler;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.springframework.batch.sample.tasklet;
|
||||
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.step.handler.StepHandler;
|
||||
import org.springframework.batch.core.step.tasklet.StepHandler;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
|
||||
Reference in New Issue
Block a user