diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java index f003b8400..fa7f85566 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java @@ -37,6 +37,6 @@ public interface Chunker extends ItemStream { * @return the {@link Chunk} that has been read. * @throws IllegalArgumentException if chunkSize is less than zero. */ - public ChunkingResult chunk(int chunkSize, StepExecution stepExecution) throws ReadFailureException; + public ChunkingResult chunk(int chunkSize, StepContribution stepContribution) throws ReadFailureException; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java index cb93f3f07..efde754bd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java @@ -35,11 +35,11 @@ public interface Dechunker extends ItemStream{ * discretion of various implementations. * * @param chunk to be 'dechunked' - * @param stepExecution the chunk belongs to. + * @param stepContribution the chunk belongs to. * @return a Dechunking result detailing whether or not dechunking was successful, and * if any items were skipped. * @throws Exception, specifically throws IllegalArgumentException if either the chunk * or StepExecution is null. */ - DechunkingResult dechunk(Chunk chunk, StepExecution stepExecution) throws Exception; + DechunkingResult dechunk(Chunk chunk, StepContribution stepContribution) throws Exception; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/SkippedItemHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemFailureHandler.java similarity index 65% rename from spring-batch-core/src/main/java/org/springframework/batch/core/domain/SkippedItemHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemFailureHandler.java index 9c5547843..8f7d97b52 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/SkippedItemHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemFailureHandler.java @@ -15,30 +15,32 @@ */ package org.springframework.batch.core.domain; -import java.util.List; - -import org.springframework.batch.io.exception.WriteFailureException; - /** * Interface for defining the contract to log out read and write - * failures encountered during batch processing. It is expected - * that any failures encountered while writing will be - * represented as {@link WriteFailureException}s, which contain - * the items which caused the exception. + * failures encountered during batch processing. * * @author Lucas Ward - * */ -public interface SkippedItemHandler { +public interface ItemFailureHandler { /** - * Handler the list of exceptions. This will usually be done + * Handle read failure. This will usually be done * by logging out the details of the exception to either a * file or database table. It is expected that any implementors of this * of this method will not throw an exception. * - * @param exceptions + * @param ex */ - void handle(List exceptions); + void handleReadFailure(Exception ex); + + /** + * Handle read failure. This will usually be done + * by logging out the details of the exception to either a + * file or database table. It is expected that any implementors of this + * of this method will not throw an exception. + * + * @param ex + */ + void handleWriteFailure(Object item, Exception ex); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java index 36698d16b..6a47a4764 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/ItemSkipPolicy.java @@ -15,7 +15,6 @@ */ package org.springframework.batch.core.domain; -import org.springframework.batch.core.domain.StepExecution; /** * Policy for determining whether or not an item should be skipped. @@ -29,9 +28,9 @@ public interface ItemSkipPolicy { * continue for the current step execution with the given throwable. * * @param ex throwable encountered while reading - * @param stepExecution currently running execution + * @param stepContribution currently running execution * @return true if reading should continue, false otherwise. * @throws IllegalArgumentException if t or stepExecution is null */ - boolean shouldSkip(Exception ex, StepExecution stepExecution); + boolean shouldSkip(Exception ex, StepContribution stepContribution); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepContribution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepContribution.java index 804f84e90..5938284fe 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepContribution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepContribution.java @@ -33,6 +33,8 @@ public class StepContribution { private ExecutionContext executionContext; private int commitCount; + + private int skipCount; /** * @param execution @@ -96,5 +98,13 @@ public class StepContribution { public boolean isTerminateOnly() { return execution.isTerminateOnly(); } + + public int getSkipCount() { + return skipCount + execution.getSkipCount(); + } + + public void incrementSkipCount(){ + skipCount++; + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepExecution.java index 56d68ee5f..2b8ede1ba 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepExecution.java @@ -330,6 +330,7 @@ public class StepExecution extends Entity { // TODO: this should not be necessary - the step decides // executionContext = contribution.getExecutionContext(); commitCount += contribution.getCommitCount(); + skipCount += contribution.getSkipCount(); } /**