From ed2bbf96e631758a26acafe8f4147d11bf567351 Mon Sep 17 00:00:00 2001 From: lucasward Date: Tue, 26 Feb 2008 21:22:54 +0000 Subject: [PATCH] BATCH-365: ItemStream#Update and ItemStream#close now accept an ExecutionContext as an argument. I removed the local ExecutionContexts in the readers and readers, and had them use the passed in ones instead. --- .../batch/execution/step/ItemOrientedStep.java | 4 ++-- .../batch/execution/step/ItemOrientedStepTests.java | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java index c2239cc24..975eabd43 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/ItemOrientedStep.java @@ -279,7 +279,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean { // only if chunk was successful stepExecution.apply(contribution); - streamManager.update(); + streamManager.update(stepExecution.getExecutionContext()); jobRepository.saveOrUpdate(stepExecution); } @@ -359,7 +359,7 @@ public class ItemOrientedStep extends AbstractStep implements InitializingBean { stepExecution.setEndTime(new Date(System.currentTimeMillis())); try { jobRepository.saveOrUpdate(stepExecution); - streamManager.close(); + streamManager.close(stepExecution.getExecutionContext()); } catch (Exception e) { logger diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java index 5b6ee0a4a..d2a1e49f3 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/ItemOrientedStepTests.java @@ -378,16 +378,12 @@ public class ItemOrientedStepTests extends TestCase { assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); itemOrientedStep.setStreamManager(new SimpleStreamManager(new ResourcelessTransactionManager()) { - ExecutionContext executionContext; - public void update() { + public void update(ExecutionContext executionContext) { // TODO Auto-generated method stub executionContext.putString("foo", "bar"); } - public void open(ExecutionContext executionContext) throws StreamException { - this.executionContext = executionContext; - } }); itemOrientedStep.execute(stepExecution); @@ -416,7 +412,7 @@ public class ItemOrientedStepTests extends TestCase { return restoreFromCalledWithSomeContext; } - public void update() { + public void update(ExecutionContext executionContext) { getExecutionAttributesCalled = true; executionContext.putString("spam", "bucket"); } @@ -433,7 +429,7 @@ public class ItemOrientedStepTests extends TestCase { this.executionContext = executionContext; } - public void close() throws StreamException { + public void close(ExecutionContext executionContext) throws StreamException { } public void mark() throws MarkFailedException {