diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java index 90966c0b1..62d488b3e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java @@ -43,7 +43,7 @@ public interface Step { * Flag to indicate if restart data needs to be saved for this step. * @return true if restart data should be saved */ - boolean isSaveStreamContext(); + boolean isSaveExecutionAttributes(); /** * @return the number of times a job can be started with the same 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 5efacb03c..dc929997a 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 @@ -30,7 +30,7 @@ public class StepContribution { private StepExecution execution; - private ExecutionAttributes streamContext; + private ExecutionAttributes executionAttributes; private int commitCount; @@ -67,18 +67,18 @@ public class StepContribution { /** * Set the statistics properties. * - * @param streamContext + * @param executionAttributes */ - public void setStreamContext(ExecutionAttributes streamContext) { - this.streamContext = streamContext; + public void setExecutionAttributes(ExecutionAttributes executionAttributes) { + this.executionAttributes = executionAttributes; } /** * Public getter for the {@link ExecutionAttributes}. * @return the stream context */ - public ExecutionAttributes getStreamContext() { - return streamContext; + public ExecutionAttributes getExecutionAttributes() { + return executionAttributes; } /** 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 b8b26cc49..240590538 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 @@ -51,7 +51,7 @@ public class StepExecution extends Entity { private Date endTime = null; - private ExecutionAttributes streamContext = new ExecutionAttributes(); + private ExecutionAttributes executionAttributes = new ExecutionAttributes(); private ExitStatus exitStatus = ExitStatus.UNKNOWN; @@ -88,12 +88,12 @@ public class StepExecution extends Entity { taskCount++; } - public ExecutionAttributes getStreamContext() { - return streamContext; + public ExecutionAttributes getExecutionAttributes() { + return executionAttributes; } - public void setStreamContext(ExecutionAttributes statistics) { - this.streamContext = statistics; + public void setExecutionAttributes(ExecutionAttributes executionAttributes) { + this.executionAttributes = executionAttributes; } public Integer getCommitCount() { @@ -249,7 +249,7 @@ public class StepExecution extends Entity { */ public synchronized void apply(StepContribution contribution) { taskCount += contribution.getTaskCount(); - streamContext = contribution.getStreamContext(); + executionAttributes = contribution.getExecutionAttributes(); commitCount += contribution.getCommitCount(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepInstance.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepInstance.java index ed2495c29..35b5932bd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepInstance.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepInstance.java @@ -49,7 +49,7 @@ public class StepInstance extends Entity { private BatchStatus status; - private ExecutionAttributes streamContext = new ExecutionAttributes(); + private ExecutionAttributes executionAttributes = new ExecutionAttributes(); private int stepExecutionCount = 0; @@ -84,12 +84,12 @@ public class StepInstance extends Entity { this.stepExecutionCount = stepExecutionCount; } - public ExecutionAttributes getStreamContext() { - return streamContext; + public ExecutionAttributes getExecutionAttributes() { + return executionAttributes; } - public void setStreamContext(ExecutionAttributes streamContext) { - this.streamContext = streamContext; + public void setExecutionAttributes(ExecutionAttributes executionAttributes) { + this.executionAttributes = executionAttributes; } public BatchStatus getStatus() { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java index 157c981d9..a04b51157 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java @@ -34,7 +34,7 @@ public class StepSupport implements Step, BeanNameAware { private boolean allowStartIfComplete; - private boolean saveStreamContext = false; + private boolean saveExecutionAttributes = false; /** * Default constructor for {@link StepSupport}. @@ -121,12 +121,12 @@ public class StepSupport implements Step, BeanNameAware { this.allowStartIfComplete = allowStartIfComplete; } - public void setSaveExecutionAttributes(boolean saveStreamContext) { - this.saveStreamContext = saveStreamContext; + public void setSaveExecutionAttributes(boolean saveExecutionAttributes) { + this.saveExecutionAttributes = saveExecutionAttributes; } - public boolean isSaveStreamContext() { - return saveStreamContext; + public boolean isSaveExecutionAttributes() { + return saveExecutionAttributes; } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepContributionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepContributionTests.java index b214d29f5..ed004fc98 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepContributionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepContributionTests.java @@ -41,14 +41,14 @@ public class StepContributionTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.core.domain.StepContribution#setStreamContext(ExecutionAttributes)}. + * {@link org.springframework.batch.core.domain.StepContribution#setExecutionAttributes(ExecutionAttributes)}. */ - public void testSetStreamContext() { - assertEquals(null, contribution.getStreamContext()); + public void testSetExecutionAttributes() { + assertEquals(null, contribution.getExecutionAttributes()); ExecutionAttributes context = new ExecutionAttributes(); context.putString("foo", "bar"); - contribution.setStreamContext(context); - assertEquals(1, contribution.getStreamContext().getProperties().size()); + contribution.setExecutionAttributes(context); + assertEquals(1, contribution.getExecutionAttributes().getProperties().size()); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java index 96145ab2f..d2585050c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepExecutionTests.java @@ -198,12 +198,12 @@ public class StepExecutionTests extends TestCase { execution.toString().indexOf("rollback") >= 0); } - public void testStreamContext() throws Exception { - assertNotNull(execution.getStreamContext()); + public void testExecutionAttributes() throws Exception { + assertNotNull(execution.getExecutionAttributes()); ExecutionAttributes context = new ExecutionAttributes(); context.putString("foo", "bar"); - execution.setStreamContext(context ); - assertEquals("bar", execution.getStreamContext().getString("foo")); + execution.setExecutionAttributes(context ); + assertEquals("bar", execution.getExecutionAttributes().getString("foo")); } public void testEqualsWithSameIdentifier() throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java index 11e9c912c..bccaed383 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java @@ -44,15 +44,15 @@ public class StepInstanceTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.core.domain.StepInstance#getStreamContext()}. + * Test method for {@link org.springframework.batch.core.domain.StepInstance#getExecutionAttributes()}. */ - public void testGetStreamContext() { - assertNotNull(instance.getStreamContext()); - assertTrue(instance.getStreamContext().getProperties().isEmpty()); + public void testGetExecutionAttributes() { + assertNotNull(instance.getExecutionAttributes()); + assertTrue(instance.getExecutionAttributes().getProperties().isEmpty()); ExecutionAttributes executionAttributes = new ExecutionAttributes(); executionAttributes.putString("foo", "bar"); - instance.setStreamContext(executionAttributes); - assertEquals("bar", instance.getStreamContext().getProperties().getProperty("foo")); + instance.setExecutionAttributes(executionAttributes); + assertEquals("bar", instance.getExecutionAttributes().getProperties().getProperty("foo")); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java index e91ca2434..c7f135e17 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java @@ -64,9 +64,9 @@ public class StepSupportTests extends TestCase { } public void testSaveRestartFlag() throws Exception { - assertEquals(false, configuration.isSaveStreamContext()); + assertEquals(false, configuration.isSaveExecutionAttributes()); configuration.setSaveExecutionAttributes(true); - assertEquals(true, configuration.isSaveStreamContext()); + assertEquals(true, configuration.isSaveExecutionAttributes()); } /** diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncher.java index 79795300c..168e1e1ce 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncher.java @@ -103,7 +103,7 @@ public class SimpleExportedJobLauncher implements ExportedJobLauncher, Initializ int i = 0; for (Iterator iterator = execution.getStepExecutions().iterator(); iterator.hasNext();) { StepExecution stepExecution = (StepExecution) iterator.next(); - Properties statistics = stepExecution.getStreamContext().getProperties(); + Properties statistics = stepExecution.getExecutionAttributes().getProperties(); for (Iterator iter = statistics.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); result.setProperty(prefix + "step" + i + "." + key, statistics.getProperty(key)); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index cd2411499..ca678e1b2 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -255,12 +255,12 @@ public class SimpleJobRepository implements JobRepository { if (stepExecution.getId() == null) { // new execution, obtain id and insert stepDao.save(stepExecution); - stepDao.save(stepExecution.getId(), stepExecution.getStreamContext()); + stepDao.save(stepExecution.getId(), stepExecution.getExecutionAttributes()); } else { // existing execution, update stepDao.update(stepExecution); - stepDao.update(stepExecution.getId(), stepExecution.getStreamContext()); + stepDao.update(stepExecution.getId(), stepExecution.getExecutionAttributes()); } } @@ -304,8 +304,8 @@ public class SimpleJobRepository implements JobRepository { Step step = (Step) i.next(); StepInstance stepInstance = stepDao.createStep(job, step.getName()); // Ensure valid restart data is being returned. - if (stepInstance.getStreamContext() == null || stepInstance.getStreamContext() == null) { - stepInstance.setStreamContext(new ExecutionAttributes()); + if (stepInstance.getExecutionAttributes() == null || stepInstance.getExecutionAttributes() == null) { + stepInstance.setExecutionAttributes(new ExecutionAttributes()); } stepInstances.add(stepInstance); } @@ -327,8 +327,8 @@ public class SimpleJobRepository implements JobRepository { step.setStepExecutionCount(stepDao.getStepExecutionCount(step)); // Ensure valid restart data is being returned. - if (step.getStreamContext() == null || step.getStreamContext() == null) { - step.setStreamContext(new ExecutionAttributes()); + if (step.getExecutionAttributes() == null || step.getExecutionAttributes() == null) { + step.setExecutionAttributes(new ExecutionAttributes()); } stepInstances.add(step); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepDao.java index 86bade7cb..2c5851e75 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepDao.java @@ -185,7 +185,7 @@ public class JdbcStepDao implements StepDao, InitializingBean { StepInstance step = new StepInstance(new Long(rs.getLong(1))); step.setStatus(BatchStatus.getStatus(rs.getString(2))); - step.setStreamContext(new ExecutionAttributes(PropertiesConverter.stringToProperties(rs.getString(3)))); + step.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties(rs.getString(3)))); return step; } @@ -235,7 +235,7 @@ public class JdbcStepDao implements StepDao, InitializingBean { stepExecution.setStatus(BatchStatus.getStatus(rs.getString(5))); stepExecution.setCommitCount(rs.getInt(6)); stepExecution.setTaskCount(rs.getInt(7)); - stepExecution.setStreamContext(new ExecutionAttributes(PropertiesConverter + stepExecution.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter .stringToProperties(rs.getString(8)))); stepExecution.setExitStatus(new ExitStatus("Y".equals(rs.getString(9)), rs.getString(10), rs .getString(11))); @@ -419,7 +419,7 @@ public class JdbcStepDao implements StepDao, InitializingBean { String status = rs.getString(3); step.setStatus(BatchStatus.getStatus(status)); step - .setStreamContext(new ExecutionAttributes(PropertiesConverter.stringToProperties(rs + .setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties(rs .getString(3)))); return step; } @@ -490,7 +490,7 @@ public class JdbcStepDao implements StepDao, InitializingBean { stepExecution.getStepId(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getTaskCount(), - PropertiesConverter.propertiesToString(stepExecution.getStreamContext().getProperties()), + PropertiesConverter.propertiesToString(stepExecution.getExecutionAttributes().getProperties()), stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), stepExecution.getExitStatus().getExitDescription() }; jdbcTemplate.update(getSaveStepExecutionQuery(), parameters, new int[] { Types.INTEGER, Types.INTEGER, @@ -569,7 +569,7 @@ public class JdbcStepDao implements StepDao, InitializingBean { Integer version = new Integer(stepExecution.getVersion().intValue() + 1); Object[] parameters = new Object[] { stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getTaskCount(), - PropertiesConverter.propertiesToString(stepExecution.getStreamContext().getProperties()), + PropertiesConverter.propertiesToString(stepExecution.getExecutionAttributes().getProperties()), stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), exitDescription, version, stepExecution.getId(), stepExecution.getVersion() }; @@ -636,9 +636,9 @@ public class JdbcStepDao implements StepDao, InitializingBean { Assert.notNull(step.getId(), "Step Id cannot be null."); Properties restartProps = null; - ExecutionAttributes streamContext = step.getStreamContext(); - if (streamContext != null) { - restartProps = streamContext.getProperties(); + ExecutionAttributes executionAttributes = step.getExecutionAttributes(); + if (executionAttributes != null) { + restartProps = executionAttributes.getProperties(); } Object[] parameters = new Object[] { step.getStatus().toString(), diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapStepDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapStepDao.java index 268166d20..db869610e 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapStepDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/MapStepDao.java @@ -80,7 +80,7 @@ public class MapStepDao implements StepDao { return new ArrayList(steps); } - public ExecutionAttributes getStreamContext(Long stepId) { + public ExecutionAttributes getExecutionAttributes(Long stepId) { return (ExecutionAttributes) restartsById.get(stepId); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java index 7b58bfe8a..428b33073 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java @@ -46,7 +46,7 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements private StreamManager streamManager; - private ExecutionAttributes streamContext; + private ExecutionAttributes executionAttributes; /** * Default constructor. @@ -82,7 +82,7 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements if (streamManager != null && (value instanceof ItemStream)) { ItemStream stream = (ItemStream) value; stream.open(); - streamManager.register(this, stream, streamContext); + streamManager.register(this, stream, executionAttributes); } } @@ -200,10 +200,10 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements } /* (non-Javadoc) - * @see org.springframework.batch.execution.scope.StepContext#restoreFrom(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.execution.scope.StepContext#restoreFrom(org.springframework.batch.item.ExecutionAttributes) */ - public void restoreFrom(ExecutionAttributes streamContext) { - this.streamContext = streamContext; + public void restoreFrom(ExecutionAttributes executionAttributes) { + this.executionAttributes = executionAttributes; } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java index 721b84fca..f3dc598ab 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java @@ -61,7 +61,7 @@ public interface StepContext extends AttributeAccessor, ExecutionAttributesProvi * streams will simply not be initialised and repositioned for restart * (which is sometimes desirable). * - * @param streamContext + * @param executionAttributes */ - void restoreFrom(ExecutionAttributes streamContext); + void restoreFrom(ExecutionAttributes executionAttributes); } \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java index 4443dc849..9259b3c3d 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java @@ -170,10 +170,10 @@ public class SimpleStepExecutor { // the conversation in StepScope stepContext.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution().getId()); - final boolean saveStreamContext = step.isSaveStreamContext(); + final boolean saveExecutionAttributes = step.isSaveExecutionAttributes(); - if (saveStreamContext && isRestart) { - stepContext.restoreFrom(stepInstance.getStreamContext()); + if (saveExecutionAttributes && isRestart) { + stepContext.restoreFrom(stepInstance.getExecutionAttributes()); } try { @@ -207,7 +207,7 @@ public class SimpleStepExecutor { // aggregate these contributions if they // come in asynchronously. ExecutionAttributes statistics = stepContext.getExecutionAttributes(); - contribution.setStreamContext(statistics); + contribution.setExecutionAttributes(statistics); contribution.incrementCommitCount(); // If the step operations are asynchronous then we need @@ -219,8 +219,8 @@ public class SimpleStepExecutor { // only if chunk was successful stepExecution.apply(contribution); - if (saveStreamContext) { - stepInstance.setStreamContext(stepContext.getExecutionAttributes()); + if (saveExecutionAttributes) { + stepInstance.setExecutionAttributes(stepContext.getExecutionAttributes()); jobRepository.update(stepInstance); } jobRepository.saveOrUpdate(stepExecution); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java index 2f2efe03e..0a88e8d3b 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java @@ -53,7 +53,7 @@ public class SimpleExportedJobLauncherTests extends TestCase { public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { JobExecution result = new JobExecution(null); StepExecution stepExecution = result.createStepExecution(new StepInstance(null, "step")); - stepExecution.setStreamContext(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); list.add(jobParameters); return result; } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index 0141ed2de..956bc5f6b 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -365,7 +365,7 @@ public class SimpleJobRepositoryTests extends TestCase { StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), null, new Long(1)); stepExecution.setId(new Long(11)); ExecutionAttributes executionAttributes = new ExecutionAttributes(); - stepExecution.setStreamContext(executionAttributes); + stepExecution.setExecutionAttributes(executionAttributes); stepDao.update(stepExecution); stepDao.update(stepExecution.getId(), executionAttributes); stepDaoControl.replay(); @@ -376,7 +376,7 @@ public class SimpleJobRepositoryTests extends TestCase { public void testSaveExistingStepExecution(){ StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), null, null); ExecutionAttributes executionAttributes = new ExecutionAttributes(); - stepExecution.setStreamContext(executionAttributes); + stepExecution.setExecutionAttributes(executionAttributes); stepDao.save(stepExecution); stepDao.save(stepExecution.getId(), executionAttributes); stepDaoControl.replay(); @@ -402,7 +402,7 @@ public class SimpleJobRepositoryTests extends TestCase { * Test to ensure that if a StepDao returns invalid * restart data, it is corrected. */ - public void testCreateStepsFixesInvalidStreamContext() throws Exception{ + public void testCreateStepsFixesInvalidExecutionAttributes() throws Exception{ List jobs = new ArrayList(); @@ -411,10 +411,10 @@ public class SimpleJobRepositoryTests extends TestCase { jobDao.createJobInstance(jobConfiguration.getName(), jobParameters); jobDaoControl.setReturnValue(databaseJob); stepDao.createStep(databaseJob, "TestStep1"); - databaseStep1.setStreamContext(null); + databaseStep1.setExecutionAttributes(null); stepDaoControl.setReturnValue(databaseStep1); stepDao.createStep(databaseJob, "TestStep2"); - databaseStep2.setStreamContext(new ExecutionAttributes()); + databaseStep2.setExecutionAttributes(new ExecutionAttributes()); stepDaoControl.setReturnValue(databaseStep2); jobDao.save(new JobExecution(databaseJob)); jobDaoControl.setMatcher(new ArgumentsMatcher(){ @@ -432,24 +432,24 @@ public class SimpleJobRepositoryTests extends TestCase { Iterator it = jobSteps.iterator(); StepInstance step = (StepInstance) it.next(); assertTrue(step.equals(databaseStep1)); - assertTrue(step.getStreamContext().getProperties().isEmpty()); + assertTrue(step.getExecutionAttributes().getProperties().isEmpty()); step = (StepInstance) it.next(); assertTrue(step.equals(databaseStep2)); - assertTrue(step.getStreamContext().getProperties().isEmpty()); + assertTrue(step.getExecutionAttributes().getProperties().isEmpty()); } - public void testFindStepsFixesInvalidStreamContext() throws Exception{ + public void testFindStepsFixesInvalidExecutionAttributes() throws Exception{ List jobs = new ArrayList(); jobDao.findJobInstances(jobConfiguration.getName(), jobParameters); jobs.add(databaseJob); jobDaoControl.setReturnValue(jobs); stepDao.findStep(databaseJob, "TestStep1"); - databaseStep1.setStreamContext(null); + databaseStep1.setExecutionAttributes(null); stepDaoControl.setReturnValue(databaseStep1); stepDao.getStepExecutionCount(databaseStep1); stepDaoControl.setReturnValue(1); stepDao.findStep(databaseJob, "TestStep2"); - databaseStep2.setStreamContext(new ExecutionAttributes()); + databaseStep2.setExecutionAttributes(new ExecutionAttributes()); stepDaoControl.setReturnValue(databaseStep2); stepDao.getStepExecutionCount(databaseStep2); stepDaoControl.setReturnValue(1); @@ -476,9 +476,9 @@ public class SimpleJobRepositoryTests extends TestCase { Iterator it = jobSteps.iterator(); StepInstance step = (StepInstance) it.next(); assertTrue(step.equals(databaseStep1)); - assertTrue(step.getStreamContext().getProperties().isEmpty()); + assertTrue(step.getExecutionAttributes().getProperties().isEmpty()); step = (StepInstance) it.next(); - assertTrue(step.getStreamContext().getProperties().isEmpty()); + assertTrue(step.getExecutionAttributes().getProperties().isEmpty()); assertTrue(step.equals(databaseStep2)); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java index 52b950459..d4d3738bf 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java @@ -149,7 +149,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour assertEquals(step3, tempStep); } - public void testUpdateStepWithoutStreamContext() { + public void testUpdateStepWithoutExecutionAttributes() { step1.setStatus(BatchStatus.COMPLETED); stepDao.update(step1); @@ -157,17 +157,17 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour assertEquals(tempStep, step1); } - public void testUpdateStepWithStreamContext() { + public void testUpdateStepWithExecutionAttributes() { step1.setStatus(BatchStatus.COMPLETED); Properties data = new Properties(); data.setProperty("restart.key1", "restartData"); - ExecutionAttributes streamContext = new ExecutionAttributes(data); - step1.setStreamContext(streamContext); + ExecutionAttributes executionAttributes = new ExecutionAttributes(data); + step1.setExecutionAttributes(executionAttributes); stepDao.update(step1); StepInstance tempStep = stepDao.findStep(jobInstance, step1.getName()); assertEquals(tempStep, step1); - assertEquals(tempStep.getStreamContext().getProperties().toString(), streamContext.getProperties().toString()); + assertEquals(tempStep.getExecutionAttributes().getProperties().toString(), executionAttributes.getProperties().toString()); } public void testSaveStepExecution() { @@ -175,7 +175,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour StepExecution execution = new StepExecution(step2, jobExecution, null); execution.setStatus(BatchStatus.STARTED); execution.setStartTime(new Date(System.currentTimeMillis())); - execution.setStreamContext(new ExecutionAttributes(PropertiesConverter.stringToProperties("key1=0,key2=5"))); + execution.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("key1=0,key2=5"))); execution.setExitStatus(new ExitStatus(false, ExitCodeExceptionClassifier.FATAL_EXCEPTION, "java.lang.Exception")); stepDao.save(execution); @@ -183,7 +183,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour assertEquals(1, executions.size()); StepExecution tempExecution = (StepExecution) executions.get(0); assertEquals(execution, tempExecution); - assertEquals(execution.getStreamContext().getString("key1"), tempExecution.getStreamContext().getString("key1")); + assertEquals(execution.getExecutionAttributes().getString("key1"), tempExecution.getExecutionAttributes().getString("key1")); assertEquals(execution.getExitStatus(), tempExecution.getExitStatus()); } @@ -193,7 +193,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour stepExecution.setEndTime(new Date(System.currentTimeMillis())); stepExecution.setCommitCount(5); stepExecution.setTaskCount(5); - stepExecution.setStreamContext(new ExecutionAttributes()); + stepExecution.setExecutionAttributes(new ExecutionAttributes()); stepExecution.setExitStatus(new ExitStatus(false, ExitCodeExceptionClassifier.FATAL_EXCEPTION, "java.lang.Exception")); stepDao.update(stepExecution); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java index d9269906f..c5c3a5b90 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java @@ -105,18 +105,18 @@ public class MapStepDaoTests extends TestCase { assertEquals(2, dao.getStepExecutionCount(step)); } - public void testSaveStreamContext() throws Exception { - assertEquals(null, dao.getStreamContext(step.getId())); + public void testSaveExecutionAttributes() throws Exception { + assertEquals(null, dao.getExecutionAttributes(step.getId())); step.setStatus(BatchStatus.COMPLETED); Properties data = new Properties(); data.setProperty("restart.key1", "restartData"); - ExecutionAttributes streamContext = new ExecutionAttributes(data); - step.setStreamContext(streamContext); + ExecutionAttributes executionAttributes = new ExecutionAttributes(data); + step.setExecutionAttributes(executionAttributes); dao.update(step); StepInstance tempStep = dao.findStep(job, step.getName()); assertEquals(tempStep, step); - assertEquals(tempStep.getStreamContext().getProperties().toString(), - streamContext.getProperties().toString()); + assertEquals(tempStep.getExecutionAttributes().getProperties().toString(), + executionAttributes.getProperties().toString()); } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java index 57d4eaa43..cc431d521 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java @@ -133,7 +133,7 @@ public class SimpleStepContextTests extends TestCase { assertTrue(list.contains("spam")); } - public void testStreamContextWithNotNullService() throws Exception { + public void testExecutionAttributesWithNotNullService() throws Exception { Map map = new HashMap(); context = new SimpleStepContext(null, null, new StubStreamManager(map)); assertEquals(1, context.getExecutionAttributes().getProperties().size()); @@ -171,7 +171,7 @@ public class SimpleStepContextTests extends TestCase { public void open(Object key) { } - public void register(Object key, ItemStream stream, ExecutionAttributes streamContext) { + public void register(Object key, ItemStream stream, ExecutionAttributes executionAttributes) { map.put(key, stream); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepConfigurationTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepConfigurationTests.java index 09a6d7369..b188dca71 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepConfigurationTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepConfigurationTests.java @@ -99,12 +99,12 @@ public class SimpleStepConfigurationTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveStreamContext()}. + * {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveExecutionAttributes()}. */ - public void testIsSaveStreamContext() { - assertEquals(false, configuration.isSaveStreamContext()); + public void testIsSaveExecutionAttributes() { + assertEquals(false, configuration.isSaveExecutionAttributes()); configuration.setSaveExecutionAttributes(true); - assertEquals(true, configuration.isSaveStreamContext()); + assertEquals(true, configuration.isSaveExecutionAttributes()); } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java index f59201cfa..e674c696a 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java @@ -284,7 +284,7 @@ public class SimpleStepExecutorTests extends TestCase { /* * make sure a job that has never been executed before, but does have - * saveStreamContext = true, doesn't have restoreFrom called on it. + * saveExecutionAttributes = true, doesn't have restoreFrom called on it. */ public void testNonRestartedJob() throws Exception { StepInstance step = new StepInstance(new Long(1)); @@ -297,7 +297,7 @@ public class SimpleStepExecutorTests extends TestCase { stepExecutor.execute(stepExecution); assertFalse(tasklet.isRestoreFromCalled()); - assertTrue(tasklet.isGetStreamContextCalled()); + assertTrue(tasklet.isGetExecutionAttributesCalled()); } /* @@ -313,21 +313,21 @@ public class SimpleStepExecutorTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecutionContext); - stepExecution.getStep().setStreamContext( + stepExecution.getStep().setExecutionAttributes( new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); stepExecutor.execute(stepExecution); assertTrue(tasklet.isRestoreFromCalled()); assertTrue(tasklet.isRestoreFromCalledWithSomeContext()); - assertTrue(tasklet.isGetStreamContextCalled()); + assertTrue(tasklet.isGetExecutionAttributesCalled()); } /* - * Test that a job that is being restarted, but has saveStreamContext set to - * false, doesn't have restore or getStreamContext called on it. + * Test that a job that is being restarted, but has saveExecutionAttributes set to + * false, doesn't have restore or getExecutionAttributes called on it. */ - public void testNoSaveStreamContextRestartableJob() { + public void testNoSaveExecutionAttributesRestartableJob() { StepInstance step = new StepInstance(new Long(1)); step.setStepExecutionCount(1); MockRestartableTasklet tasklet = new MockRestartableTasklet(); @@ -344,11 +344,11 @@ public class SimpleStepExecutorTests extends TestCase { } assertFalse(tasklet.isRestoreFromCalled()); - assertFalse(tasklet.isGetStreamContextCalled()); + assertFalse(tasklet.isGetExecutionAttributesCalled()); } /* - * Even though the job is restarted, and saveStreamContext is true, nothing + * Even though the job is restarted, and saveExecutionAttributes is true, nothing * will be restored because the Tasklet does not implement Restartable. */ public void testRestartJobOnNonRestartableTasklet() throws Exception { @@ -417,7 +417,7 @@ public class SimpleStepExecutorTests extends TestCase { JobExecution jobExecution = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecution); - assertEquals(false, stepExecution.getStreamContext().containsKey("foo")); + assertEquals(false, stepExecution.getExecutionAttributes().containsKey("foo")); final Map map = new HashMap(); stepExecutor.setStreamManager(new SimpleStreamManager(new ResourcelessTransactionManager()) { @@ -431,14 +431,14 @@ public class SimpleStepExecutorTests extends TestCase { // At least once in that process the statistics service was asked for // statistics... - assertEquals("bar", stepExecution.getStreamContext().getString("foo")); + assertEquals("bar", stepExecution.getExecutionAttributes().getString("foo")); // ...but nothing was registered because nothing with step scoped. assertEquals(0, map.size()); } private class MockRestartableTasklet extends ItemStreamAdapter implements Tasklet { - private boolean getStreamContextCalled = false; + private boolean getExecutionAttributesCalled = false; private boolean restoreFromCalled = false; @@ -454,7 +454,7 @@ public class SimpleStepExecutorTests extends TestCase { } public ExecutionAttributes getExecutionAttributes() { - getStreamContextCalled = true; + getExecutionAttributesCalled = true; return new ExecutionAttributes(PropertiesConverter.stringToProperties("spam=bucket")); } @@ -463,8 +463,8 @@ public class SimpleStepExecutorTests extends TestCase { restoreFromCalledWithSomeContext = data.getProperties().size() > 0; } - public boolean isGetStreamContextCalled() { - return getStreamContextCalled; + public boolean isGetExecutionAttributesCalled() { + return getExecutionAttributesCalled; } public boolean isRestoreFromCalled() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java index 65f9461e1..7789571a9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/HibernateCursorItemReader.java @@ -172,7 +172,7 @@ public class HibernateCursorItemReader extends AbstractItemStreamItemReader impl } /** - * @return the current row number wrapped as StreamContext + * @return the current row number wrapped as {@link ExecutionAttributes} */ public ExecutionAttributes getExecutionAttributes() { Properties props = new Properties(); @@ -232,22 +232,20 @@ public class HibernateCursorItemReader extends AbstractItemStreamItemReader impl return true; } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.stream.ItemStreamAdapter#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { lastCommitRowNumber = currentProcessedRow; if (!useStatelessSession) { statefulSession.clear(); } } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.stream.ItemStreamAdapter#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { currentProcessedRow = lastCommitRowNumber; if (lastCommitRowNumber == 0) { cursor.beforeFirst(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java index b487e0616..fcba0cf21 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java @@ -232,7 +232,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen * Mark the current row. Calling reset will cause the result set to be set * to the current row when mark was called. */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { lastCommittedRow = currentProcessedRow; skippedRows.clear(); } @@ -242,7 +242,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen * * @throws DataAccessException */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { try { currentProcessedRow = lastCommittedRow; if (currentProcessedRow > 0) { @@ -385,10 +385,8 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen } } - /* - * (non-Javadoc) - * - * @see org.springframework.batch.restart.Restartable#getStreamContext() + /* (non-Javadoc) + * @see org.springframework.batch.item.stream.ItemStreamAdapter#getExecutionAttributes() */ public ExecutionAttributes getExecutionAttributes() { String skipped = skippedRows.toString(); @@ -399,9 +397,8 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen return context; } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.stream.ItemStreamAdapter#restoreFrom(org.springframework.batch.item.ExecutionAttributes) */ public void restoreFrom(ExecutionAttributes data) { Assert.state(!initialized); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java index d25606ecb..a7844c068 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/DrivingQueryItemReader.java @@ -170,9 +170,9 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource */ public final void restoreFrom(ExecutionAttributes data) { - Assert.notNull(data, "StreamContext must not be null."); + Assert.notNull(data, "ExecutionAttributes must not be null."); Assert.notNull(data.getProperties(), - "StreamContext properties must not be null."); + "ExecutionAttributes properties must not be null."); Assert.state(!initialized, "Cannot restore when already intialized. Call" + " close() first before restore()"); @@ -190,7 +190,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource } public ExecutionAttributes getExecutionAttributes() { - return keyGenerator.getKeyAsStreamContext(getCurrentKey()); + return keyGenerator.getKeyAsExecutionAttributes(getCurrentKey()); } public void afterPropertiesSet() throws Exception { @@ -235,16 +235,16 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { lastCommitIndex = currentIndex; } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { keysIterator = keys.listIterator(lastCommitIndex); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/KeyGenerator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/KeyGenerator.java index 17effd4f8..ef04d45ef 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/KeyGenerator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/KeyGenerator.java @@ -20,19 +20,19 @@ public interface KeyGenerator { /** * Restore the keys list based on provided restart data. * - * @param streamContext, the restart data to restore the keys list from. + * @param executionAttributes, the restart data to restore the keys list from. * @return a list of keys. - * @throws IllegalArgumentException is streamContext is null. + * @throws IllegalArgumentException is executionAttributes is null. */ - List restoreKeys(ExecutionAttributes streamContext); + List restoreKeys(ExecutionAttributes executionAttributes); /** * Return the provided key as restart data. * * @param key to be converted to restart data. - * @return StreamContext representation of the key. + * @return {@link ExecutionAttributes} representation of the key. * @throws IllegalArgumentException if key is null. * @throws IllegalArgumentException if key is an incompatible type. */ - ExecutionAttributes getKeyAsStreamContext(Object key); + ExecutionAttributes getKeyAsExecutionAttributes(Object key); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapStreamContextRowMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java similarity index 81% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapStreamContextRowMapper.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java index d7b2d414e..e6391859e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapStreamContextRowMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java @@ -32,15 +32,15 @@ import org.springframework.util.ClassUtils; * * @author Lucas Ward * @author Dave Syer - * @see StreamContextRowMapper + * @see ExecutionAttributesRowMapper */ -public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implements StreamContextRowMapper{ +public class ColumnMapExecutionAttributesRowMapper extends ColumnMapRowMapper implements ExecutionAttributesRowMapper { - public static final String KEY_PREFIX = ClassUtils.getQualifiedName(ColumnMapStreamContextRowMapper.class) + ".KEY."; + public static final String KEY_PREFIX = ClassUtils.getQualifiedName(ColumnMapExecutionAttributesRowMapper.class) + ".KEY."; - public PreparedStatementSetter createSetter(ExecutionAttributes streamContext) { + public PreparedStatementSetter createSetter(ExecutionAttributes executionAttributes) { - ColumnMapStreamContext columnData = new ColumnMapStreamContext(streamContext.getProperties()); + ColumnMapExecutionAttributes columnData = new ColumnMapExecutionAttributes(executionAttributes.getProperties()); List columns = new ArrayList(); for (Iterator iterator = columnData.keys.entrySet().iterator(); iterator.hasNext();) { @@ -52,21 +52,21 @@ public class ColumnMapStreamContextRowMapper extends ColumnMapRowMapper implemen return new ArgPreparedStatementSetter(columns.toArray()); } - public ExecutionAttributes createStreamContext(Object key) { - Assert.isInstanceOf(Map.class, key, "Input to create StreamContext must be of type Map."); + public ExecutionAttributes createExecutionAttributes(Object key) { + Assert.isInstanceOf(Map.class, key, "Input to create ExecutionAttributes must be of type Map."); Map keys = (Map) key; - return new ColumnMapStreamContext(keys); + return new ColumnMapExecutionAttributes(keys); } - private static class ColumnMapStreamContext extends ExecutionAttributes { + private static class ColumnMapExecutionAttributes extends ExecutionAttributes { private final Map keys; - public ColumnMapStreamContext(Map keys) { + public ColumnMapExecutionAttributes(Map keys) { this.keys = keys; } - public ColumnMapStreamContext(Properties props) { + public ColumnMapExecutionAttributes(Properties props) { keys = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(props.size()); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/StreamContextRowMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java similarity index 86% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/StreamContextRowMapper.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java index 6afbed491..4a6b8ea9a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/StreamContextRowMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java @@ -31,23 +31,23 @@ import org.springframework.jdbc.core.RowMapper; * @see RowMapper * @since 1.0 */ -public interface StreamContextRowMapper extends RowMapper { +public interface ExecutionAttributesRowMapper extends RowMapper { /** * Given the provided composite key, return a RestartData representation. * * @param key - * @return ResartData representing the composite key. + * @return ExecutionAttributes representing the composite key. * @throws IllegalArgumentException if key is null or of an unsupported type. */ - public ExecutionAttributes createStreamContext(Object key); + public ExecutionAttributes createExecutionAttributes(Object key); /** * Given the provided restart data, return a PreparedStatementSeter that can * be used as parameters to a JdbcTemplate. * - * @param streamContext + * @param executionAttributes * @return an array of objects that can be used as arguments to a JdbcTemplate. */ - public PreparedStatementSetter createSetter(ExecutionAttributes streamContext); + public PreparedStatementSetter createSetter(ExecutionAttributes executionAttributes); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/IbatisKeyGenerator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/IbatisKeyGenerator.java index 84574b2dd..d3d555965 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/IbatisKeyGenerator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/IbatisKeyGenerator.java @@ -39,11 +39,10 @@ public class IbatisKeyGenerator implements KeyGenerator { return sqlMapClientTemplate.queryForList(drivingQuery); } - /* - * - * @see org.springframework.batch.restart.Restartable#getRestartData() + /* (non-Javadoc) + * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionAttributes(java.lang.Object) */ - public ExecutionAttributes getKeyAsStreamContext(Object key) { + public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { Properties props = new Properties(); props.setProperty(RESTART_KEY, key.toString()); ExecutionAttributes executionAttributes = new ExecutionAttributes(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGenerator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGenerator.java index 5359ef8d4..7e7c77d27 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGenerator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGenerator.java @@ -28,7 +28,7 @@ import org.springframework.util.StringUtils; /** *

Jdbc implementation of the {@link KeyGenerator} interface that works for composite keys. * (i.e. keys represented by multiple columns) A sql query to be used to return the keys and - * a {@link StreamContextRowMapper} to map each row in the resultset to an Object must be set in + * a {@link ExecutionAttributesRowMapper} to map each row in the resultset to an Object must be set in * order to work correctly. *

* @@ -43,7 +43,7 @@ public class MultipleColumnJdbcKeyGenerator implements private JdbcTemplate jdbcTemplate; - private StreamContextRowMapper keyMapper = new ColumnMapStreamContextRowMapper(); + private ExecutionAttributesRowMapper keyMapper = new ColumnMapExecutionAttributesRowMapper(); private String sql; @@ -78,27 +78,27 @@ public class MultipleColumnJdbcKeyGenerator implements } /* (non-Javadoc) - * @see org.springframework.batch.io.driving.KeyGenerator#restoreKeys(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.io.driving.KeyGenerator#restoreKeys(org.springframework.batch.item.ExecutionAttributes) */ - public List restoreKeys(ExecutionAttributes streamContext) { + public List restoreKeys(ExecutionAttributes executionAttributes) { Assert.state(keyMapper != null, "KeyMapper must not be null."); Assert.state(StringUtils.hasText(restartSql), "The RestartQuery must not be null or empty" + " in order to restart."); - if (streamContext.getProperties() != null) { - return jdbcTemplate.query(restartSql, keyMapper.createSetter(streamContext), keyMapper); + if (executionAttributes.getProperties() != null) { + return jdbcTemplate.query(restartSql, keyMapper.createSetter(executionAttributes), keyMapper); } return new ArrayList(); } /* (non-Javadoc) - * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsStreamContext(java.lang.Object) + * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionAttributes(java.lang.Object) */ - public ExecutionAttributes getKeyAsStreamContext(Object key) { + public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { Assert.state(keyMapper != null, "Kye mapper must not be null."); - return keyMapper.createStreamContext(key); + return keyMapper.createExecutionAttributes(key); } /** @@ -121,12 +121,12 @@ public class MultipleColumnJdbcKeyGenerator implements } /** - * Set the {@link StreamContextRowMapper} to be used to map a resultset + * Set the {@link ExecutionAttributesRowMapper} to be used to map a resultset * to keys. * * @param keyMapper */ - public void setKeyMapper(StreamContextRowMapper keyMapper) { + public void setKeyMapper(ExecutionAttributesRowMapper keyMapper) { this.keyMapper = keyMapper; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGenerator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGenerator.java index f0fdef3e4..abed9d80c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGenerator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGenerator.java @@ -95,10 +95,10 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator { /** * Get the restart data representing the last processed key. * - * @see KeyGenerator#getKeyAsStreamContext(Object) + * @see KeyGenerator#getKeyAsExecutionAttributes(Object) * @throws IllegalArgumentException if key is null. */ - public ExecutionAttributes getKeyAsStreamContext(Object key) { + public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { Assert.notNull(key, "The key must not be null."); ExecutionAttributes context = new ExecutionAttributes(); context.putString(RESTART_KEY, key.toString()); @@ -112,19 +112,19 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator { * KeyGenerationStrategy as the one being restored from otherwise * it is invalid. * - * @param ExecutionAttributes obtained by calling - * {@link #getKeyAsStreamContext(Object)} during a previous run. + * @param executionAttributes {@link ExecutionAttributes} obtained by calling + * {@link #getKeyAsExecutionAttributes(Object)} during a previous run. * @throws IllegalStateException if restart sql statement is null. * @throws IllegalArgumentException if restart data is null. * @see KeyGenerator#restoreKeys(org.springframework.batch.item.ExecutionAttributes) */ - public List restoreKeys(ExecutionAttributes streamContext) { + public List restoreKeys(ExecutionAttributes executionAttributes) { - Assert.notNull(streamContext, "The restart data must not be null."); + Assert.notNull(executionAttributes, "The restart data must not be null."); Assert.state(StringUtils.hasText(restartSql), "The RestartQuery must not be null or empty" + " in order to restart."); - String lastProcessedKey = streamContext.getProperties().getProperty(RESTART_KEY); + String lastProcessedKey = executionAttributes.getProperties().getProperty(RESTART_KEY); if (lastProcessedKey != null) { return jdbcTemplate.query(restartSql, new Object[] { lastProcessedKey }, keyMapper); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java index fde894e25..5ffcdbae2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java @@ -94,10 +94,10 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen if (reader == null) { throw new StreamException("ItemStream not open or already closed."); } - ExecutionAttributes streamContext = new ExecutionAttributes(); - streamContext.putLong(READ_STATISTICS_NAME, reader.getCurrentLineCount()); - streamContext.putLong(SKIPPED_STATISTICS_NAME, skippedLines.size()); - return streamContext; + ExecutionAttributes executionAttributes = new ExecutionAttributes(); + executionAttributes.putLong(READ_STATISTICS_NAME, reader.getCurrentLineCount()); + executionAttributes.putLong(SKIPPED_STATISTICS_NAME, skippedLines.size()); + return executionAttributes; } /** @@ -112,19 +112,17 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen return true; } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { getReader().mark(); } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { getReader().reset(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java index eef66ab57..7a8a31e07 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemWriter.java @@ -71,7 +71,7 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements private Resource resource; - private ExecutionAttributes streamContext = new ExecutionAttributes(); + private ExecutionAttributes executionAttributes = new ExecutionAttributes(); private OutputState state = null; @@ -250,10 +250,10 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements if (state == null) { throw new StreamException("ItemStream not open or already closed."); } - streamContext.putLong(RESTART_DATA_NAME, state.position()); - streamContext.putLong(WRITTEN_STATISTICS_NAME, state.linesWritten); - streamContext.putLong(RESTART_COUNT_STATISTICS_NAME, state.restartCount); - return streamContext; + executionAttributes.putLong(RESTART_DATA_NAME, state.position()); + executionAttributes.putLong(WRITTEN_STATISTICS_NAME, state.linesWritten); + executionAttributes.putLong(RESTART_COUNT_STATISTICS_NAME, state.restartCount); + return executionAttributes; } /** @@ -550,16 +550,16 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { getOutputState().mark(); } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { getOutputState().checkFileSize(); resetPositionForRestart(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/support/AbstractTransactionalIoSource.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/support/AbstractTransactionalIoSource.java index 55d3d55e5..d25fdecde 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/support/AbstractTransactionalIoSource.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/support/AbstractTransactionalIoSource.java @@ -39,14 +39,14 @@ public abstract class AbstractTransactionalIoSource extends ItemStreamAdapter { * * @see TransactionSynchronization#afterCompletion */ - public abstract void mark(ExecutionAttributes streamContext); + public abstract void mark(ExecutionAttributes executionAttributes); /* * Called when a transaction has been rolled back. * * @see TransactionSynchronization#afterCompletion */ - public abstract void reset(ExecutionAttributes streamContext); + public abstract void reset(ExecutionAttributes executionAttributes); /* (non-Javadoc) * @see org.springframework.batch.item.stream.ItemStreamAdapter#isMarkSupported() diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java index bb889e75a..97891d0ab 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemReader.java @@ -264,18 +264,18 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { lastCommitPointRecordCount = currentRecordCount; txReader.onCommit(); skipRecords = new ArrayList(); } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { currentRecordCount = lastCommitPointRecordCount; txReader.onRollback(); fragmentReader.reset(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java index 542536eeb..d6c397242 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/xml/StaxEventItemWriter.java @@ -448,17 +448,17 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { lastCommitPointPosition = getPosition(); lastCommitPointRecordCount = currentRecordCount; } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { currentRecordCount = lastCommitPointRecordCount; // close output close(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStream.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStream.java index bb099f778..149ae6f75 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStream.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStream.java @@ -75,7 +75,7 @@ public interface ItemStream extends ExecutionAttributesProvider { * * @throws UnsupportedOperationException if the operation is not supported */ - void mark(ExecutionAttributes streamContext); + void mark(ExecutionAttributes executionAttributes); /** * Reset the stream to the last mark. After a reset the stream state will be @@ -84,5 +84,5 @@ public interface ItemStream extends ExecutionAttributesProvider { * * @throws UnsupportedOperationException if the operation is not supported */ - void reset(ExecutionAttributes streamContext); + void reset(ExecutionAttributes executionAttributes); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java index 8d04ded6d..80887c2d9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/reader/DelegatingItemReader.java @@ -117,20 +117,20 @@ public class DelegatingItemReader extends AbstractItemReader implements Skippabl } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { if (inputSource instanceof ItemStream) { - ((ItemStream) inputSource).mark(streamContext); + ((ItemStream) inputSource).mark(executionAttributes); } } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { if (inputSource instanceof ItemStream) { - ((ItemStream) inputSource).reset(streamContext); + ((ItemStream) inputSource).reset(executionAttributes); } } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/ItemStreamAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/ItemStreamAdapter.java index 5fc8e9078..02034fb40 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/ItemStreamAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/ItemStreamAdapter.java @@ -62,16 +62,16 @@ public class ItemStreamAdapter implements ItemStream { } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { throw new UnsupportedOperationException("Mark operation not supported."); } /* (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { throw new UnsupportedOperationException("Reset operation not supported."); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java index 27fd0e0a6..875d3b63f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java @@ -66,7 +66,7 @@ public class SimpleStreamManager implements StreamManager { /** * Public setter for the flag. If this is true then the class name of the - * streams will be used as a prefix in the {@link StreamContext} in + * streams will be used as a prefix in the {@link ExecutionAttributes} in * {@link #getExecutionAttributes(Object)}. The default value is true, which * gives the best chance of unique key names in the context. * @@ -85,7 +85,7 @@ public class SimpleStreamManager implements StreamManager { } /** - * Simple aggregate {@link StreamContext} provider for the contributions + * Simple aggregate {@link ExecutionAttributes} provider for the contributions * registered under the given key. * * @see org.springframework.batch.item.stream.StreamManager#getExecutionAttributes(java.lang.Object) @@ -114,9 +114,9 @@ public class SimpleStreamManager implements StreamManager { * the provided key. * * @see org.springframework.batch.item.stream.StreamManager#register(java.lang.Object, - * org.springframework.batch.item.ItemStream, StreamContext) + * org.springframework.batch.item.ItemStream, ExecutionAttributes) */ - public void register(Object key, ItemStream stream, ExecutionAttributes streamContext) { + public void register(Object key, ItemStream stream, ExecutionAttributes executionAttributes) { synchronized (registry) { Set set = (Set) registry.get(key); if (set == null) { @@ -125,23 +125,23 @@ public class SimpleStreamManager implements StreamManager { } set.add(stream); } - if (streamContext != null) { - stream.restoreFrom(extract(stream, streamContext)); + if (executionAttributes != null) { + stream.restoreFrom(extract(stream, executionAttributes)); } } /** * @param stream - * @param streamContext + * @param executionAttributes * @return */ - private ExecutionAttributes extract(ItemStream stream, ExecutionAttributes context) { + private ExecutionAttributes extract(ItemStream stream, ExecutionAttributes executionAttributes) { ExecutionAttributes result = new ExecutionAttributes(); String prefix = ClassUtils.getQualifiedName(stream.getClass()) + "."; if (!useClassNameAsPrefix) { prefix = ""; } - for (Iterator iterator = context.entrySet().iterator(); iterator.hasNext();) { + for (Iterator iterator = executionAttributes.entrySet().iterator(); iterator.hasNext();) { Entry entry = (Entry) iterator.next(); String contextKey = (String) entry.getKey(); if (contextKey.startsWith(prefix)) { @@ -152,10 +152,8 @@ public class SimpleStreamManager implements StreamManager { } /** - * Broadcast the call to close from this {@link StreamContext}. + * Broadcast the call to close from this {@link StreamManager}. * @throws Exception - * - * @see StreamManager#restoreFrom(Object, StreamContext) */ public void close(Object key) throws StreamException { iterate(key, new Callback() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java index d89305d8e..5e55548df 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java @@ -15,8 +15,8 @@ */ package org.springframework.batch.item.stream; -import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.StreamException; import org.springframework.transaction.TransactionStatus; @@ -37,9 +37,9 @@ public interface StreamManager { * * @param key the key under which to add the provider * @param stream an {@link ItemStream} - * @param streamContext the context (may be null) to restore from on registration + * @param executionAttributes the context (may be null) to restore from on registration */ - void register(Object key, ItemStream stream, ExecutionAttributes streamContext); + void register(Object key, ItemStream stream, ExecutionAttributes executionAttributes); /** * Extract and aggregate the {@link ExecutionAttributes} from all streams under diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/writer/DelegatingItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/writer/DelegatingItemWriter.java index 11eca13ca..99ca1a98f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/writer/DelegatingItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/writer/DelegatingItemWriter.java @@ -1,15 +1,12 @@ package org.springframework.batch.item.writer; import org.springframework.batch.io.Skippable; -import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.ExecutionAttributes; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; /** - * Simple wrapper around {@link ItemWriter} providing {@link ItemStream} where - * the {@link ItemWriter} does. To make sure + * Simple wrapper around {@link ItemWriter}. * * @author Dave Syer * @author Robert Kasanicky @@ -46,34 +43,6 @@ public class DelegatingItemWriter implements ItemWriter, Skippable, Initializing this.writer = writer; } - /** - * @see ItemStream#getExecutionAttributes() - */ - public ExecutionAttributes getStreamContext() { - - Assert.state(writer != null, "Source must not be null."); - - if (writer instanceof ItemStream) { - return ((ItemStream) writer).getExecutionAttributes(); - } - else { - return new ExecutionAttributes(); - } - } - - /** - * @see ItemStream#restoreFrom(ExecutionAttributes) - */ - public void restoreFrom(ExecutionAttributes data) { - - Assert.state(writer != null, "Source must not be null."); - - if (writer instanceof ItemStream) { - ((ItemStream) writer).restoreFrom(data); - } - - } - public void skip() { if (writer instanceof Skippable) { ((Skippable) writer).skip(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java index 391636915..058155c40 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java @@ -191,7 +191,7 @@ public class DrivingQueryItemReaderTests extends TestCase { restartKeys.add(new Foo(5, "5", 5)); } - public ExecutionAttributes getKeyAsStreamContext(Object key) { + public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { return streamContext; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java index 6502a1372..4878b3206 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java @@ -20,9 +20,9 @@ import org.springframework.jdbc.core.PreparedStatementSetter; */ public class ColumnMapRestartDataRowMapperTests extends TestCase { - private static final String KEY = ColumnMapStreamContextRowMapper.KEY_PREFIX; + private static final String KEY = ColumnMapExecutionAttributesRowMapper.KEY_PREFIX; - private ColumnMapStreamContextRowMapper mapper; + private ColumnMapExecutionAttributesRowMapper mapper; private Map key; @@ -32,7 +32,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase { protected void setUp() throws Exception { super.setUp(); - mapper = new ColumnMapStreamContextRowMapper(); + mapper = new ColumnMapExecutionAttributesRowMapper(); key = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(2); key.put("1", new Integer(1)); @@ -42,7 +42,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase { public void testCreateRestartDataWithInvalidType() throws Exception { try{ - mapper.createStreamContext(new Object()); + mapper.createExecutionAttributes(new Object()); fail(); }catch(IllegalArgumentException ex){ //expected @@ -52,7 +52,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase { public void testCreateRestartDataWithNull(){ try{ - mapper.createStreamContext(null); + mapper.createExecutionAttributes(null); fail(); }catch(IllegalArgumentException ex){ //expected @@ -60,7 +60,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase { } public void testCreateRestartData() throws Exception { - ExecutionAttributes streamContext = mapper.createStreamContext(key); + ExecutionAttributes streamContext = mapper.createExecutionAttributes(key); Properties props = streamContext.getProperties(); assertEquals("1", props.getProperty(KEY + "0")); assertEquals("2", props.getProperty(KEY + "1")); @@ -68,7 +68,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase { public void testCreateRestartDataFromEmptyKeys() throws Exception { - ExecutionAttributes streamContext = mapper.createStreamContext(new HashMap()); + ExecutionAttributes streamContext = mapper.createExecutionAttributes(new HashMap()); assertEquals(0, streamContext.getProperties().size()); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java index 63dfdd3b7..629be9620 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java @@ -46,8 +46,8 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran public void testRestoreKeys(){ ExecutionAttributes streamContext = new ExecutionAttributes(); - streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0", "3"); - streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1", "3"); + streamContext.putString(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "0", "3"); + streamContext.putString(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "1", "3"); List keys = keyStrategy.restoreKeys(streamContext); @@ -66,18 +66,18 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran key.put("ID", new Long(3)); key.put("VALUE", new Integer(3)); - ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(key); + ExecutionAttributes streamContext = keyStrategy.getKeyAsExecutionAttributes(key); Properties props = streamContext.getProperties(); assertEquals(2, props.size()); - assertEquals("3", props.get(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0")); - assertEquals("3", props.get(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1")); + assertEquals("3", props.get(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "0")); + assertEquals("3", props.get(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "1")); } public void testGetNullKeyAsStreamContext(){ try{ - keyStrategy.getKeyAsStreamContext(null); + keyStrategy.getKeyAsExecutionAttributes(null); fail(); }catch(IllegalArgumentException ex){ //expected @@ -87,7 +87,7 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran public void testRestoreKeysFromNull(){ try{ - keyStrategy.getKeyAsStreamContext(null); + keyStrategy.getKeyAsExecutionAttributes(null); }catch(IllegalArgumentException ex){ //expected } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java index 5f6735d5c..8a6832030 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java @@ -54,7 +54,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa public void testGetKeyAsStreamContext(){ - ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(new Long(3)); + ExecutionAttributes streamContext = keyStrategy.getKeyAsExecutionAttributes(new Long(3)); Properties props = streamContext.getProperties(); assertEquals(1, props.size()); @@ -64,7 +64,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa public void testGetNullKeyAsStreamContext(){ try{ - keyStrategy.getKeyAsStreamContext(null); + keyStrategy.getKeyAsExecutionAttributes(null); fail(); }catch(IllegalArgumentException ex){ //expected @@ -74,7 +74,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa public void testRestoreKeysFromNull(){ try{ - keyStrategy.getKeyAsStreamContext(null); + keyStrategy.getKeyAsExecutionAttributes(null); }catch(IllegalArgumentException ex){ //expected } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/writer/ItemWriterItemProcessorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/writer/ItemWriterItemProcessorTests.java index 14a3dbf55..f42f11b7e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/writer/ItemWriterItemProcessorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/writer/ItemWriterItemProcessorTests.java @@ -17,13 +17,12 @@ package org.springframework.batch.item.writer; import java.util.ArrayList; import java.util.List; -import java.util.Properties; import junit.framework.TestCase; import org.springframework.batch.io.Skippable; -import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ItemWriter; import org.springframework.batch.support.PropertiesConverter; /** @@ -52,54 +51,6 @@ public class ItemWriterItemProcessorTests extends TestCase { assertEquals("test:foo", list.get(0)); } - /** - * Gets restart data from the input template - */ - public void testGetStreamContext() { - Properties props = processor.getStreamContext().getProperties(); - assertEquals("foo", props.getProperty("value")); - } - - /** - * Forward restart data to input template - * @throws Exception - */ - public void testRestoreFrom() throws Exception { - processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar"))); - processor.write("foo"); - assertEquals("bar:foo", list.get(0)); - } - - /** - * Forward restart data to input template - * @throws Exception - */ - public void testGetStreamContextWithoutItemStream() throws Exception { - processor.setDelegate(null); - try { - processor.getStreamContext(); - fail("Expected IllegalStateException"); - } - catch (IllegalStateException e) { - // expected - } - } - - /** - * Forward restart data to input template - * @throws Exception - */ - public void testRestoreFromWithoutRestartable() throws Exception { - processor.setDelegate(null); - try { - processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar"))); - fail("Expected IllegalStateException"); - } - catch (IllegalStateException e) { - // expected - } - } - public void testSkip() { processor.skip(); assertEquals(1, list.size()); 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 09aeabd51..bbad67170 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 @@ -215,33 +215,29 @@ public class StagingItemReader extends JdbcDaoSupport implements ItemStream, Key return true; } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) */ - public void mark(ExecutionAttributes streamContext) { + public void mark(ExecutionAttributes executionAttributes) { getBuffer().commit(); } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) */ - public void reset(ExecutionAttributes streamContext) { + public void reset(ExecutionAttributes executionAttributes) { getBuffer().rollback(); } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.StreamContext) + /* (non-Javadoc) + * @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.ExecutionAttributes) */ public void restoreFrom(ExecutionAttributes context) { // no-op } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.StreamContextProvider#getStreamContext() + /* (non-Javadoc) + * @see org.springframework.batch.item.ExecutionAttributesProvider#getExecutionAttributes() */ public ExecutionAttributes getExecutionAttributes() { return new ExecutionAttributes(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/InfiniteLoopTasklet.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/InfiniteLoopTasklet.java index 29e283847..318cb0e81 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/InfiniteLoopTasklet.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/InfiniteLoopTasklet.java @@ -47,9 +47,8 @@ public class InfiniteLoopTasklet implements Tasklet, ExecutionAttributesProvider return ExitStatus.CONTINUABLE; } - /* - * (non-Javadoc) - * @see org.springframework.batch.item.stream.ItemStreamAdapter#getStreamContext() + /* (non-Javadoc) + * @see org.springframework.batch.item.ExecutionAttributesProvider#getExecutionAttributes() */ public ExecutionAttributes getExecutionAttributes() { return new ExecutionAttributes(PropertiesConverter.stringToProperties("count=" + count)); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java index e4f2cddca..de1352262 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/SimpleTradeTasklet.java @@ -84,7 +84,7 @@ public class SimpleTradeTasklet implements Tasklet, ExecutionAttributesProvider } /* (non-Javadoc) - * @see org.springframework.batch.item.StreamContextProvider#getStreamContext() + * @see org.springframework.batch.item.ExecutionAttributesProvider#getExecutionAttributes() */ public ExecutionAttributes getExecutionAttributes() { ExecutionAttributes statistics = new ExecutionAttributes();