BATCH-365: There should now be one ExecutionContext per step. All itemStreams will be opened with an execution context, and will be notified before it is saved, to ensure they have all state in the context. Most ItemReader/Writers should now have the logic for whether or not to put their state in the context, but a few have likely been missed.

This commit is contained in:
lucasward
2008-02-26 08:29:59 +00:00
parent 38c486e449
commit d24f0af439
8 changed files with 33 additions and 44 deletions

View File

@@ -23,6 +23,7 @@ import java.sql.SQLException;
import org.springframework.batch.io.file.FlatFileItemReader;
import org.springframework.batch.io.file.transform.LineTokenizer;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.sample.domain.Trade;
import org.springframework.batch.sample.mapping.TradeFieldSetMapper;
import org.springframework.core.io.ClassPathResource;
@@ -61,7 +62,7 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch
*/
protected void validatePostConditions() throws Exception {
inputSource.open();
inputSource.open(new ExecutionContext());
jdbcTemplate.query("SELECT ID, ISIN, QUANTITY, PRICE, CUSTOMER FROM trade ORDER BY id", new RowCallbackHandler() {

View File

@@ -5,6 +5,7 @@ import java.math.BigDecimal;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.sample.domain.CustomerCredit;
@@ -28,13 +29,13 @@ public class FlatFileCustomerCreditWriterTests extends TestCase {
}
public void testOpen() throws Exception {
ExecutionContext executionContext = new ExecutionContext();
//set-up outputSource mock
output.open();
output.open(executionContext);
outputControl.replay();
//call tested method
writer.open();
writer.open(executionContext);
//verify method calls
outputControl.verify();
@@ -65,7 +66,7 @@ public class FlatFileCustomerCreditWriterTests extends TestCase {
//set-up OutputSource mock
output.write("testName;1");
output.open();
output.open(new ExecutionContext());
outputControl.replay();
//call tested method

View File

@@ -9,6 +9,7 @@ import org.springframework.batch.core.domain.StepSupport;
import org.springframework.batch.execution.scope.SimpleStepContext;
import org.springframework.batch.execution.scope.StepContext;
import org.springframework.batch.execution.scope.StepSynchronizationManager;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;
import org.springframework.batch.sample.item.writer.StagingItemWriter;
@@ -49,7 +50,7 @@ public class StagingItemReaderTests extends AbstractTransactionalDataSourceSprin
writer.write("BAR");
writer.write("SPAM");
writer.write("BUCKET");
provider.open();
provider.open(new ExecutionContext());
}
protected void onTearDownAfterTransaction() throws Exception {