Refactored CheckpointAlgorithmAdapter to be stateful

This commit is contained in:
Michael Minella
2013-12-12 14:36:21 -06:00
parent 17b680f31d
commit b985c52b4d
2 changed files with 7 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ import org.springframework.util.Assert;
public class CheckpointAlgorithmAdapter implements CompletionPolicy {
private CheckpointAlgorithm policy;
private boolean isComplete = false;
public CheckpointAlgorithmAdapter(CheckpointAlgorithm policy) {
Assert.notNull(policy, "A CheckpointAlgorithm is required");
@@ -47,7 +48,8 @@ public class CheckpointAlgorithmAdapter implements CompletionPolicy {
@Override
public boolean isComplete(RepeatContext context, RepeatStatus result) {
try {
return policy.isReadyToCheckpoint();
isComplete = policy.isReadyToCheckpoint();
return isComplete;
} catch (Exception e) {
throw new BatchRuntimeException(e);
}
@@ -59,7 +61,8 @@ public class CheckpointAlgorithmAdapter implements CompletionPolicy {
@Override
public boolean isComplete(RepeatContext context) {
try {
return policy.isReadyToCheckpoint();
isComplete = policy.isReadyToCheckpoint();
return isComplete;
} catch (Exception e) {
throw new BatchRuntimeException(e);
}
@@ -88,7 +91,7 @@ public class CheckpointAlgorithmAdapter implements CompletionPolicy {
@Override
public void update(RepeatContext context) {
try {
if(policy.isReadyToCheckpoint()) {
if(isComplete) {
policy.endCheckpoint();
}
} catch (Exception e) {