From 535fd28f9149060f136bdf66373b5fa8b9886860 Mon Sep 17 00:00:00 2001 From: lucasward Date: Tue, 26 Feb 2008 21:23:08 +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/sample/dao/FlatFileCustomerCreditWriter.java | 2 +- .../batch/sample/item/reader/GeneratingItemReader.java | 4 ++-- .../batch/sample/item/reader/StagingItemReader.java | 6 +++--- .../batch/sample/tasklet/SimpleTradeWriter.java | 4 ++-- .../batch/sample/dao/FlatFileCustomerCreditWriterTests.java | 2 +- .../batch/sample/item/reader/StagingItemReaderTests.java | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriter.java index c21150951..8b53edb0d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriter.java @@ -66,7 +66,7 @@ public class FlatFileCustomerCreditWriter implements CustomerCreditDao, public void close() throws Exception { if (outputSource instanceof ItemStream) { - ((ItemStream) outputSource).close(); + ((ItemStream) outputSource).close(null); } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java index ad93341cf..9925bdece 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java @@ -61,7 +61,7 @@ public class GeneratingItemReader extends AbstractItemReaderRecoverer implements /* (non-Javadoc) * @see org.springframework.batch.item.ItemStream#close() */ - public void close() throws StreamException { + public void close(ExecutionContext executionContext) throws StreamException { // TODO Auto-generated method stub } @@ -89,7 +89,7 @@ public class GeneratingItemReader extends AbstractItemReaderRecoverer implements /* (non-Javadoc) * @see org.springframework.batch.item.ExecutionContextProvider#getExecutionContext() */ - public void update() { + public void update(ExecutionContext executionContext) { } public void open(ExecutionContext context) throws StreamException { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java index fedff752a..e8dc857d1 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/StagingItemReader.java @@ -43,9 +43,9 @@ public class StagingItemReader extends JdbcDaoSupport implements ItemStream, Key /** * - * @see org.springframework.batch.io.driving.DrivingQueryItemReader#close() + * @see org.springframework.batch.io.driving.DrivingQueryItemReader#close(ExecutionContext) */ - public void close() { + public void close(ExecutionContext executionContext) { initialized = false; keys = null; if (TransactionSynchronizationManager.hasResource(BUFFER_KEY)) { @@ -223,7 +223,7 @@ public class StagingItemReader extends JdbcDaoSupport implements ItemStream, Key * * @see org.springframework.batch.item.ExecutionContextProvider#getExecutionContext() */ - public void update() { + public void update(ExecutionContext executionContext) { } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeWriter.java index 251a03d1f..bb5e6d7ca 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeWriter.java @@ -76,10 +76,10 @@ public class SimpleTradeWriter extends AbstractItemWriter implements ItemStream /* (non-Javadoc) * @see org.springframework.batch.item.ExecutionContextProvider#getExecutionContext() */ - public void update() { + public void update(ExecutionContext executionContext) { executionContext.putLong("trade.count", tradeCount); } - public void close() throws StreamException { + public void close(ExecutionContext executionContext) throws StreamException { } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriterTests.java index 0a4fb13d4..37f9d3177 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/FlatFileCustomerCreditWriterTests.java @@ -44,7 +44,7 @@ public class FlatFileCustomerCreditWriterTests extends TestCase { public void testClose() throws Exception{ //set-up outputSource mock - output.close(); + output.close(null); outputControl.replay(); //call tested method diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java index ea8594e19..6d8fcab67 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/reader/StagingItemReaderTests.java @@ -54,7 +54,7 @@ public class StagingItemReaderTests extends AbstractTransactionalDataSourceSprin } protected void onTearDownAfterTransaction() throws Exception { - provider.close(); + provider.close(null); getJdbcTemplate().update("DELETE FROM BATCH_STAGING"); }