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 be33980d8..e2434e13e 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 isSaveExecutionAttributes(); + boolean isSaveExecutionContext(); /** * @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 dc929997a..804f84e90 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 @@ -15,7 +15,7 @@ */ package org.springframework.batch.core.domain; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; /** * Represents a contribution to a {@link StepExecution}, buffering changes @@ -30,7 +30,7 @@ public class StepContribution { private StepExecution execution; - private ExecutionAttributes executionAttributes; + private ExecutionContext executionContext; private int commitCount; @@ -67,18 +67,18 @@ public class StepContribution { /** * Set the statistics properties. * - * @param executionAttributes + * @param executionContext */ - public void setExecutionAttributes(ExecutionAttributes executionAttributes) { - this.executionAttributes = executionAttributes; + public void setExecutionContext(ExecutionContext executionContext) { + this.executionContext = executionContext; } /** - * Public getter for the {@link ExecutionAttributes}. + * Public getter for the {@link ExecutionContext}. * @return the stream context */ - public ExecutionAttributes getExecutionAttributes() { - return executionAttributes; + public ExecutionContext getExecutionContext() { + return executionContext; } /** 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 e0afdd78f..e1b69293e 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 @@ -18,7 +18,7 @@ package org.springframework.batch.core.domain; import java.util.Date; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; /** @@ -55,7 +55,7 @@ public class StepExecution extends Entity { private Date endTime = null; - private ExecutionAttributes executionAttributes = new ExecutionAttributes(); + private ExecutionContext executionContext = new ExecutionContext(); private ExitStatus exitStatus = ExitStatus.UNKNOWN; @@ -106,21 +106,21 @@ public class StepExecution extends Entity { } /** - * Returns the {@link ExecutionAttributes} for this execution + * Returns the {@link ExecutionContext} for this execution * * @return the attributes */ - public ExecutionAttributes getExecutionAttributes() { - return executionAttributes; + public ExecutionContext getExecutionContext() { + return executionContext; } /** - * Sets the {@link ExecutionAttributes} for this execution + * Sets the {@link ExecutionContext} for this execution * - * @param executionAttributes the attributes + * @param executionContext the attributes */ - public void setExecutionAttributes(ExecutionAttributes executionAttributes) { - this.executionAttributes = executionAttributes; + public void setExecutionContext(ExecutionContext executionContext) { + this.executionContext = executionContext; } /** @@ -346,7 +346,7 @@ public class StepExecution extends Entity { */ public synchronized void apply(StepContribution contribution) { taskCount += contribution.getTaskCount(); - executionAttributes = contribution.getExecutionAttributes(); + executionContext = contribution.getExecutionContext(); commitCount += contribution.getCommitCount(); } 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 420ac1aa3..f2e4c6e85 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 @@ -33,7 +33,7 @@ public class StepSupport implements Step, BeanNameAware { private boolean allowStartIfComplete; - private boolean saveExecutionAttributes = false; + private boolean saveExecutionContext = false; /** * Default constructor for {@link StepSupport}. @@ -102,12 +102,12 @@ public class StepSupport implements Step, BeanNameAware { this.allowStartIfComplete = allowStartIfComplete; } - public void setSaveExecutionAttributes(boolean saveExecutionAttributes) { - this.saveExecutionAttributes = saveExecutionAttributes; + public void setSaveExecutionContext(boolean saveExecutionContext) { + this.saveExecutionContext = saveExecutionContext; } - public boolean isSaveExecutionAttributes() { - return saveExecutionAttributes; + public boolean isSaveExecutionContext() { + return saveExecutionContext; } /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java index dccb423b1..c78600229 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java @@ -21,7 +21,7 @@ import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; /** *
@@ -29,7 +29,7 @@ import org.springframework.batch.item.ExecutionAttributes; * must first be obtained using the findOrCreateJob method. Once a Job and it's * related steps are obtained, they can be updated. It should be noted that any * reconstituted steps are expected to contain restart data if the step - * says it wants to be restored after a restart, and {@link ExecutionAttributes} + * says it wants to be restored after a restart, and {@link ExecutionContext} * exists. *
* 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 ed004fc98..3a7a42fd7 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 @@ -17,7 +17,7 @@ package org.springframework.batch.core.domain; import junit.framework.TestCase; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; /** * @author Dave Syer @@ -41,14 +41,14 @@ public class StepContributionTests extends TestCase { /** * Test method for - * {@link org.springframework.batch.core.domain.StepContribution#setExecutionAttributes(ExecutionAttributes)}. + * {@link org.springframework.batch.core.domain.StepContribution#setExecutionContext(ExecutionContext)}. */ - public void testSetExecutionAttributes() { - assertEquals(null, contribution.getExecutionAttributes()); - ExecutionAttributes context = new ExecutionAttributes(); + public void testSetExecutionContext() { + assertEquals(null, contribution.getExecutionContext()); + ExecutionContext context = new ExecutionContext(); context.putString("foo", "bar"); - contribution.setExecutionAttributes(context); - assertEquals(1, contribution.getExecutionAttributes().getProperties().size()); + contribution.setExecutionContext(context); + assertEquals(1, contribution.getExecutionContext().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 d2585050c..b7119db0b 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 @@ -19,7 +19,7 @@ import java.util.Date; import junit.framework.TestCase; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; /** @@ -198,12 +198,12 @@ public class StepExecutionTests extends TestCase { execution.toString().indexOf("rollback") >= 0); } - public void testExecutionAttributes() throws Exception { - assertNotNull(execution.getExecutionAttributes()); - ExecutionAttributes context = new ExecutionAttributes(); + public void testExecutionContext() throws Exception { + assertNotNull(execution.getExecutionContext()); + ExecutionContext context = new ExecutionContext(); context.putString("foo", "bar"); - execution.setExecutionAttributes(context ); - assertEquals("bar", execution.getExecutionAttributes().getString("foo")); + execution.setExecutionContext(context ); + assertEquals("bar", execution.getExecutionContext().getString("foo")); } public void testEqualsWithSameIdentifier() throws Exception { 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 c7f135e17..3e85bbf33 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.isSaveExecutionAttributes()); - configuration.setSaveExecutionAttributes(true); - assertEquals(true, configuration.isSaveExecutionAttributes()); + assertEquals(false, configuration.isSaveExecutionContext()); + configuration.setSaveExecutionContext(true); + assertEquals(true, configuration.isSaveExecutionContext()); } /** 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 168e1e1ce..04d616858 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.getExecutionAttributes().getProperties(); + Properties statistics = stepExecution.getExecutionContext().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 4e93e67bf..19f64afeb 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 @@ -36,7 +36,7 @@ import org.springframework.batch.execution.repository.dao.JobExecutionDao; import org.springframework.batch.execution.repository.dao.JobInstanceDao; import org.springframework.batch.execution.repository.dao.StepExecutionDao; import org.springframework.batch.execution.repository.dao.StepInstanceDao; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.transaction.annotation.Isolation; import org.springframework.util.Assert; @@ -264,12 +264,12 @@ public class SimpleJobRepository implements JobRepository { jobExecutionDao.saveJobExecution(jobExecution); } stepExecutionDao.saveStepExecution(stepExecution); - stepExecutionDao.saveExecutionAttributes(stepExecution.getId(), stepExecution.getExecutionAttributes()); + stepExecutionDao.saveExecutionContext(stepExecution.getId(), stepExecution.getExecutionContext()); } else { // existing execution, update stepExecutionDao.updateStepExecution(stepExecution); - stepExecutionDao.updateExecutionAttributes(stepExecution.getId(), stepExecution.getExecutionAttributes()); + stepExecutionDao.updateExecutionContext(stepExecution.getId(), stepExecution.getExecutionContext()); } } @@ -315,9 +315,9 @@ public class SimpleJobRepository implements JobRepository { if (stepInstance != null) { stepInstance.setLastExecution(stepExecutionDao.getLastStepExecution(stepInstance)); if (stepInstance.getLastExecution() != null) { - ExecutionAttributes executionAttributes = stepExecutionDao.findExecutionAttributes(stepInstance + ExecutionContext executionContext = stepExecutionDao.findExecutionContext(stepInstance .getLastExecution().getId()); - stepInstance.getLastExecution().setExecutionAttributes(executionAttributes); + stepInstance.getLastExecution().setExecutionContext(executionContext); } stepInstance.setStepExecutionCount(stepExecutionDao.getStepExecutionCount(stepInstance)); stepInstances.add(stepInstance); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java index 5a1138eaa..842bcbafc 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepExecutionDao.java @@ -18,7 +18,7 @@ import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.execution.repository.dao.JdbcJobExecutionDao.JobExecutionRowMapper; import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.support.PropertiesConverter; import org.springframework.beans.factory.InitializingBean; @@ -96,11 +96,11 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao private DataFieldMaxValueIncrementer stepExecutionIncrementer; - public ExecutionAttributes findExecutionAttributes(final Long executionId) { + public ExecutionContext findExecutionContext(final Long executionId) { Assert.notNull(executionId, "ExecutionId must not be null."); - final ExecutionAttributes executionAttributes = new ExecutionAttributes(); + final ExecutionContext executionContext = new ExecutionContext(); RowCallbackHandler callback = new RowCallbackHandler() { @@ -110,16 +110,16 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao AttributeType type = AttributeType.getType(typeCd); String key = rs.getString("KEY_NAME"); if (type == AttributeType.STRING) { - executionAttributes.putString(key, rs.getString("STRING_VAL")); + executionContext.putString(key, rs.getString("STRING_VAL")); } else if (type == AttributeType.LONG) { - executionAttributes.putLong(key, rs.getLong("LONG_VAL")); + executionContext.putLong(key, rs.getLong("LONG_VAL")); } else if (type == AttributeType.DOUBLE) { - executionAttributes.putDouble(key, rs.getDouble("DOUBLE_VAL")); + executionContext.putDouble(key, rs.getDouble("DOUBLE_VAL")); } else if (type == AttributeType.OBJECT) { - executionAttributes.putLong(key, rs.getLong("OBJECT_VAL")); + executionContext.putLong(key, rs.getLong("OBJECT_VAL")); } else { throw new BatchCriticalException("Invalid type found: [" + typeCd + "] for execution id: [" @@ -130,7 +130,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao getJdbcTemplate().query(getQuery(FIND_STEP_EXECUTION_ATTRS), new Object[] { executionId }, callback); - return executionAttributes; + return executionContext; } /** @@ -200,12 +200,12 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao * attributes that don't match a provided type must be serialized into a * blob. */ - public void saveExecutionAttributes(final Long executionId, final ExecutionAttributes executionAttributes) { + public void saveExecutionContext(final Long executionId, final ExecutionContext executionContext) { Assert.notNull(executionId, "ExecutionId must not be null."); - Assert.notNull(executionAttributes, "The ExecutionAttributes must not be null."); + Assert.notNull(executionContext, "The ExecutionContext must not be null."); - for (Iterator it = executionAttributes.entrySet().iterator(); it.hasNext();) { + for (Iterator it = executionContext.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); final String key = entry.getKey().toString(); final Object value = entry.getValue(); @@ -285,7 +285,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao stepExecution.getStepId(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getTaskCount(), - PropertiesConverter.propertiesToString(stepExecution.getExecutionAttributes().getProperties()), + PropertiesConverter.propertiesToString(stepExecution.getExecutionContext().getProperties()), stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), stepExecution.getExitStatus().getExitDescription() }; getJdbcTemplate().update(getQuery(SAVE_STEP_EXECUTION), parameters, new int[] { Types.INTEGER, Types.INTEGER, @@ -314,12 +314,12 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao * * @see {@link LobCreator} */ - public void updateExecutionAttributes(final Long executionId, ExecutionAttributes executionAttributes) { + public void updateExecutionContext(final Long executionId, ExecutionContext executionContext) { Assert.notNull(executionId, "ExecutionId must not be null."); - Assert.notNull(executionAttributes, "The ExecutionAttributes must not be null."); + Assert.notNull(executionContext, "The ExecutionContext must not be null."); - for (Iterator it = executionAttributes.entrySet().iterator(); it.hasNext();) { + for (Iterator it = executionContext.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); final String key = entry.getKey().toString(); final Object value = entry.getValue(); @@ -411,7 +411,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao 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.getExecutionAttributes().getProperties()), + PropertiesConverter.propertiesToString(stepExecution.getExecutionContext().getProperties()), stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), exitDescription, version, stepExecution.getId(), stepExecution.getVersion() }; @@ -449,7 +449,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao stepExecution.setStatus(BatchStatus.getStatus(rs.getString(5))); stepExecution.setCommitCount(rs.getInt(6)); stepExecution.setTaskCount(rs.getInt(7)); - stepExecution.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties(rs + stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties(rs .getString(8)))); stepExecution .setExitStatus(new ExitStatus("Y".equals(rs.getString(9)), rs.getString(10), rs.getString(11))); diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepInstanceDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepInstanceDao.java index 469580da7..c46a5a743 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepInstanceDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/JdbcStepInstanceDao.java @@ -124,20 +124,6 @@ public class JdbcStepInstanceDao extends AbstractJdbcBatchMetadataDao implements return getJdbcTemplate().query(getQuery(FIND_STEPS), parameters, rowMapper); } -// /** -// * @see StepDao#updateStepInstance(StepInstance) -// * @throws IllegalArgumentException if step, or it's status and id is null. -// */ -// public void updateStepInstance(final StepInstance step) { -// -// Assert.notNull(step, "Step cannot be null."); -// Assert.notNull(step.getId(), "Step Id cannot be null."); -// -// Object[] parameters = new Object[] { step.getLastExecution().getId(), step.getId() }; -// -// getJdbcTemplate().update(getQuery(UPDATE_STEP), parameters); -// } - public void setStepIncrementer(DataFieldMaxValueIncrementer stepIncrementer) { this.stepIncrementer = stepIncrementer; } 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 89c135a25..b68347154 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 @@ -26,7 +26,7 @@ import java.util.Map.Entry; import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; import org.springframework.dao.IncorrectResultSizeDataAccessException; @@ -82,8 +82,8 @@ public class MapStepDao implements StepDao { return new ArrayList(steps); } - public ExecutionAttributes getExecutionAttributes(Long stepId) { - return (ExecutionAttributes) restartsById.get(stepId); + public ExecutionContext getExecutionContext(Long stepId) { + return (ExecutionContext) restartsById.get(stepId); } public int getStepExecutionCount(StepInstance stepInstance) { @@ -150,16 +150,16 @@ public class MapStepDao implements StepDao { // no-op } - public ExecutionAttributes findExecutionAttributes(Long executionId) { + public ExecutionContext findExecutionContext(Long executionId) { return null; } - public void saveExecutionAttributes(Long executionId, - ExecutionAttributes executionAttributes) { + public void saveExecutionContext(Long executionId, + ExecutionContext executionContext) { } - public void updateExecutionAttributes(Long executionId, - ExecutionAttributes executionAttributes) { + public void updateExecutionContext(Long executionId, + ExecutionContext executionContext) { } public StepExecution getLastStepExecution(StepInstance stepInstance) { diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepExecutionDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepExecutionDao.java index 9f1dd5b53..51217ebdb 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepExecutionDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepExecutionDao.java @@ -4,7 +4,7 @@ import java.util.List; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; public interface StepExecutionDao { @@ -55,33 +55,33 @@ public interface StepExecutionDao { StepExecution getStepExecution(Long stepExecutionId, StepInstance stepInstance); /** - * Find all {@link ExecutionAttributes} for the given execution id. + * Find all {@link ExecutionContext} for the given execution id. * * @param executionId - Long id of the {@link StepExecution} that the * attributes belongs to. * @return attributes for the provided id. If none are found, an empty - * {@link ExecutionAttributes} will be returned. + * {@link ExecutionContext} will be returned. * @throws IllegalArgumentException if the id is null. */ - ExecutionAttributes findExecutionAttributes(final Long executionId); + ExecutionContext findExecutionContext(final Long executionId); /** - * Save the provided {@link ExecutionAttributes} for the given executionId. + * Save the provided {@link ExecutionContext} for the given executionId. * * @param executionId to be saved - * @param executionAttributes to be saved. + * @param executionContext to be saved. * @throws IllegalArgumentException if the executionId or attributes are * null. */ - void saveExecutionAttributes(final Long executionId, final ExecutionAttributes executionAttributes); + void saveExecutionContext(final Long executionId, final ExecutionContext executionContext); /** - * Update the provided ExecutionAttributes. + * Update the provided ExecutionContext. * * @param executionId - * @param executionAttributes + * @param executionContext */ - void updateExecutionAttributes(final Long executionId, ExecutionAttributes executionAttributes); + void updateExecutionContext(final Long executionId, ExecutionContext executionContext); /** * @return the last execution of the given instance diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepInstanceDao.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepInstanceDao.java index 0a575d07b..a26544b45 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepInstanceDao.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/dao/StepInstanceDao.java @@ -35,12 +35,4 @@ public interface StepInstanceDao { */ StepInstance createStepInstance(JobInstance jobInstance, String stepName); -// /** -// * Update an existing StepInstance. -// * -// * Preconditions: StepInstance must have an ID. -// * -// * @param job -// */ -// void updateStepInstance(StepInstance stepInstance); } 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 428b33073..d74a47db8 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 @@ -26,7 +26,7 @@ import java.util.Set; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.item.ItemStream; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.stream.StreamManager; import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor; @@ -46,7 +46,7 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements private StreamManager streamManager; - private ExecutionAttributes executionAttributes; + private ExecutionContext executionContext; /** * 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, executionAttributes); + streamManager.register(this, stream, executionContext); } } @@ -193,17 +193,17 @@ public class SimpleStepContext extends SynchronizedAttributeAccessor implements } /* (non-Javadoc) - * @see org.springframework.batch.item.ExecutionAttributesProvider#getExecutionAttributes() + * @see org.springframework.batch.item.ExecutionContextProvider#getExecutionContext() */ - public ExecutionAttributes getExecutionAttributes() { - return streamManager.getExecutionAttributes(this); + public ExecutionContext getExecutionContext() { + return streamManager.getExecutionContext(this); } /* (non-Javadoc) - * @see org.springframework.batch.execution.scope.StepContext#restoreFrom(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.execution.scope.StepContext#restoreFrom(org.springframework.batch.item.ExecutionContext) */ - public void restoreFrom(ExecutionAttributes executionAttributes) { - this.executionAttributes = executionAttributes; + public void restoreFrom(ExecutionContext executionContext) { + this.executionContext = executionContext; } } 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 f3dc598ab..645b904aa 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 @@ -17,8 +17,8 @@ package org.springframework.batch.execution.scope; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.item.ItemStream; -import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.ExecutionAttributesProvider; +import org.springframework.batch.item.ExecutionContext; +import org.springframework.batch.item.ExecutionContextProvider; import org.springframework.core.AttributeAccessor; /** @@ -27,7 +27,7 @@ import org.springframework.core.AttributeAccessor; * @author Dave Syer * */ -public interface StepContext extends AttributeAccessor, ExecutionAttributesProvider { +public interface StepContext extends AttributeAccessor, ExecutionContextProvider { /** * Accessor for the {@link StepExecution} associated with the currently @@ -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 executionAttributes + * @param executionContext */ - void restoreFrom(ExecutionAttributes executionAttributes); + void restoreFrom(ExecutionContext executionContext); } \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java index 25e708725..6d5962dc5 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java @@ -39,7 +39,7 @@ import org.springframework.batch.execution.scope.StepContext; import org.springframework.batch.execution.scope.StepScope; import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemWriter; @@ -271,11 +271,11 @@ public class ChunkedStep extends StepSupport implements InitializingBean{ // the conversation in StepScope stepContext.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution().getId()); - final boolean saveExecutionAttributes = isSaveExecutionAttributes(); + final boolean saveExecutionContext = isSaveExecutionContext(); - if (saveExecutionAttributes && isRestart && stepInstance.getLastExecution() != null) { - stepExecution.setExecutionAttributes(stepInstance.getLastExecution().getExecutionAttributes()); - stepContext.restoreFrom(stepExecution.getExecutionAttributes()); + if (saveExecutionContext && isRestart && stepInstance.getLastExecution() != null) { + stepExecution.setExecutionContext(stepInstance.getLastExecution().getExecutionContext()); + stepContext.restoreFrom(stepExecution.getExecutionContext()); } try { @@ -371,8 +371,8 @@ public class ChunkedStep extends StepSupport implements InitializingBean{ // TODO: check that stepExecution can // aggregate these contributions if they // come in asynchronously. - ExecutionAttributes statistics = stepContext.getExecutionAttributes(); - contribution.setExecutionAttributes(statistics); + ExecutionContext statistics = stepContext.getExecutionContext(); + contribution.setExecutionContext(statistics); contribution.incrementCommitCount(); // If the step operations are asynchronous then we need @@ -384,8 +384,8 @@ public class ChunkedStep extends StepSupport implements InitializingBean{ // only if chunk was successful stepExecution.apply(contribution); - if (isSaveExecutionAttributes()) { - stepExecution.setExecutionAttributes(stepContext.getExecutionAttributes()); + if (isSaveExecutionContext()) { + stepExecution.setExecutionContext(stepContext.getExecutionContext()); } jobRepository.saveOrUpdate(stepExecution); 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 e638a11b1..372a7d990 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 @@ -34,7 +34,7 @@ import org.springframework.batch.execution.scope.StepScope; import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.io.Skippable; import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemRecoverer; import org.springframework.batch.item.ItemStream; @@ -302,11 +302,11 @@ public class SimpleStepExecutor implements InitializingBean { // the conversation in StepScope stepContext.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution().getId()); - final boolean saveExecutionAttributes = step.isSaveExecutionAttributes(); + final boolean saveExecutionContext = step.isSaveExecutionContext(); - if (saveExecutionAttributes && isRestart && stepInstance.getLastExecution() != null) { - stepExecution.setExecutionAttributes(stepInstance.getLastExecution().getExecutionAttributes()); - stepContext.restoreFrom(stepExecution.getExecutionAttributes()); + if (saveExecutionContext && isRestart && stepInstance.getLastExecution() != null) { + stepExecution.setExecutionContext(stepInstance.getLastExecution().getExecutionContext()); + stepContext.restoreFrom(stepExecution.getExecutionContext()); } try { @@ -336,8 +336,8 @@ public class SimpleStepExecutor implements InitializingBean { // TODO: check that stepExecution can // aggregate these contributions if they // come in asynchronously. - ExecutionAttributes statistics = stepContext.getExecutionAttributes(); - contribution.setExecutionAttributes(statistics); + ExecutionContext statistics = stepContext.getExecutionContext(); + contribution.setExecutionContext(statistics); contribution.incrementCommitCount(); // If the step operations are asynchronous then we need @@ -349,8 +349,8 @@ public class SimpleStepExecutor implements InitializingBean { // only if chunk was successful stepExecution.apply(contribution); - if (saveExecutionAttributes) { - stepExecution.setExecutionAttributes(stepContext.getExecutionAttributes()); + if (saveExecutionContext) { + stepExecution.setExecutionContext(stepContext.getExecutionContext()); } 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 0a88e8d3b..c3960c299 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 @@ -32,7 +32,7 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep import org.springframework.batch.core.runtime.JobParametersFactory; import org.springframework.batch.execution.configuration.MapJobRegistry; import org.springframework.batch.execution.launch.JobLauncher; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.support.PropertiesConverter; /** @@ -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.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); + stepExecution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); list.add(jobParameters); return result; } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/MockStepDao.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/MockStepDao.java index 0d7be4195..7a48833af 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/MockStepDao.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/MockStepDao.java @@ -22,7 +22,7 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.execution.repository.dao.StepDao; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; public class MockStepDao implements StepDao { @@ -72,16 +72,16 @@ public class MockStepDao implements StepDao { return null; } - public ExecutionAttributes findExecutionAttributes(Long executionId) { + public ExecutionContext findExecutionContext(Long executionId) { return null; } - public void saveExecutionAttributes(Long executionId, - ExecutionAttributes executionAttributes) { + public void saveExecutionContext(Long executionId, + ExecutionContext executionContext) { } - public void updateExecutionAttributes(Long executionId, - ExecutionAttributes executionAttributes) { + public void updateExecutionContext(Long executionId, + ExecutionContext executionContext) { } public StepExecution getStepExecution(Long stepExecutionId, 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 5f6c11c7f..24d3cd1b2 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 @@ -37,7 +37,7 @@ import org.springframework.batch.core.domain.StepSupport; import org.springframework.batch.core.repository.BatchRestartException; import org.springframework.batch.execution.repository.dao.JobDao; import org.springframework.batch.execution.repository.dao.StepDao; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; /** * Test SimpleJobRepository. The majority of test cases are tested using @@ -77,7 +77,7 @@ public class SimpleJobRepositoryTests extends TestCase { List steps; - ExecutionAttributes executionAttributes; + ExecutionContext executionContext; private JobExecution jobExecution; @@ -120,7 +120,7 @@ public class SimpleJobRepositoryTests extends TestCase { steps.add(databaseStep1); steps.add(databaseStep2); - executionAttributes = new ExecutionAttributes(); + executionContext = new ExecutionContext(); } /* @@ -180,16 +180,16 @@ public class SimpleJobRepositoryTests extends TestCase { stepDaoControl.setReturnValue(databaseStep1); stepDao.getLastStepExecution(databaseStep1); stepDaoControl.setReturnValue(databaseStep1Exec); - stepDao.findExecutionAttributes(databaseStep1Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep1Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep1); stepDaoControl.setReturnValue(1); stepDao.findStepInstance(databaseJob, "TestStep2"); stepDaoControl.setReturnValue(databaseStep2); stepDao.getLastStepExecution(databaseStep2); stepDaoControl.setReturnValue(databaseStep2Exec); - stepDao.findExecutionAttributes(databaseStep2Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep2Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep2); stepDaoControl.setReturnValue(1); stepDaoControl.replay(); @@ -259,16 +259,16 @@ public class SimpleJobRepositoryTests extends TestCase { stepDaoControl.setReturnValue(databaseStep1); stepDao.getLastStepExecution(databaseStep1); stepDaoControl.setReturnValue(databaseStep1Exec); - stepDao.findExecutionAttributes(databaseStep1Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep1Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep1); stepDaoControl.setReturnValue(1); stepDao.findStepInstance(databaseJob, "TestStep2"); stepDaoControl.setReturnValue(databaseStep2); stepDao.getLastStepExecution(databaseStep2); stepDaoControl.setReturnValue(databaseStep2Exec); - stepDao.findExecutionAttributes(databaseStep2Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep2Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep2); stepDaoControl.setReturnValue(1); stepDaoControl.replay(); @@ -359,10 +359,10 @@ public class SimpleJobRepositoryTests extends TestCase { public void testUpdateStepExecution() { StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), null, new Long(1)); stepExecution.setId(new Long(11)); - ExecutionAttributes executionAttributes = new ExecutionAttributes(); - stepExecution.setExecutionAttributes(executionAttributes); + ExecutionContext executionContext = new ExecutionContext(); + stepExecution.setExecutionContext(executionContext); stepDao.updateStepExecution(stepExecution); - stepDao.updateExecutionAttributes(stepExecution.getId(), executionAttributes); + stepDao.updateExecutionContext(stepExecution.getId(), executionContext); stepDaoControl.replay(); jobRepository.saveOrUpdate(stepExecution); stepDaoControl.verify(); @@ -370,10 +370,10 @@ public class SimpleJobRepositoryTests extends TestCase { public void testSaveExistingStepExecution() { StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), new JobExecution(null), null); - ExecutionAttributes executionAttributes = new ExecutionAttributes(); - stepExecution.setExecutionAttributes(executionAttributes); + ExecutionContext executionContext = new ExecutionContext(); + stepExecution.setExecutionContext(executionContext); stepDao.saveStepExecution(stepExecution); - stepDao.saveExecutionAttributes(stepExecution.getId(), executionAttributes); + stepDao.saveExecutionContext(stepExecution.getId(), executionContext); stepDaoControl.replay(); jobRepository.saveOrUpdate(stepExecution); stepDaoControl.verify(); @@ -397,7 +397,7 @@ public class SimpleJobRepositoryTests extends TestCase { * Test to ensure that if a StepDao returns invalid restart data, it is * corrected. */ - public void testCreateStepsFixesInvalidExecutionAttributes() throws Exception { + public void testCreateStepsFixesInvalidExecutionContext() throws Exception { List jobs = new ArrayList(); @@ -430,7 +430,7 @@ public class SimpleJobRepositoryTests extends TestCase { assertTrue(step.equals(databaseStep2)); } - public void testFindStepsFixesInvalidExecutionAttributes() throws Exception { + public void testFindStepsFixesInvalidExecutionContext() throws Exception { StepExecution databaseStep1Exec = new StepExecution(databaseStep1, null, new Long(1)); StepExecution databaseStep2Exec = new StepExecution(databaseStep2, null, new Long(2)); @@ -443,16 +443,16 @@ public class SimpleJobRepositoryTests extends TestCase { stepDaoControl.setReturnValue(databaseStep1); stepDao.getLastStepExecution(databaseStep1); stepDaoControl.setReturnValue(databaseStep1Exec); - stepDao.findExecutionAttributes(databaseStep1Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep1Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep1); stepDaoControl.setReturnValue(1); stepDao.findStepInstance(databaseJob, "TestStep2"); stepDaoControl.setReturnValue(databaseStep2); stepDao.getLastStepExecution(databaseStep2); stepDaoControl.setReturnValue(databaseStep2Exec); - stepDao.findExecutionAttributes(databaseStep2Exec.getId()); - stepDaoControl.setReturnValue(executionAttributes); + stepDao.findExecutionContext(databaseStep2Exec.getId()); + stepDaoControl.setReturnValue(executionContext); stepDao.getStepExecutionCount(databaseStep2); stepDaoControl.setReturnValue(1); stepDaoControl.replay(); @@ -477,9 +477,9 @@ public class SimpleJobRepositoryTests extends TestCase { Iterator it = jobSteps.iterator(); StepInstance step = (StepInstance) it.next(); assertTrue(step.equals(databaseStep1)); - assertTrue(step.getLastExecution().getExecutionAttributes().isEmpty()); + assertTrue(step.getLastExecution().getExecutionContext().isEmpty()); step = (StepInstance) it.next(); - assertTrue(step.getLastExecution().getExecutionAttributes().isEmpty()); + assertTrue(step.getLastExecution().getExecutionContext().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 f40950638..7663cdbaf 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 @@ -27,7 +27,7 @@ import org.springframework.batch.core.domain.JobSupport; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.support.PropertiesConverter; import org.springframework.dao.OptimisticLockingFailureException; @@ -64,7 +64,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour protected JobParameters jobParameters = new JobParameters(); - protected ExecutionAttributes executionAttributes; + protected ExecutionContext executionContext; public void setJobInstanceDao(JobInstanceDao jobInstanceDao) { this.jobInstanceDao = jobInstanceDao; @@ -109,11 +109,11 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour step1.setLastExecution(stepExecution); //stepInstanceDao.updateStepInstance(step1); - executionAttributes = new ExecutionAttributes(); - executionAttributes.putString("1", "testString1"); - executionAttributes.putString("2", "testString2"); - executionAttributes.putLong("3", 3); - executionAttributes.putDouble("4", 4.4); + executionContext = new ExecutionContext(); + executionContext.putString("1", "testString1"); + executionContext.putString("2", "testString2"); + executionContext.putLong("3", 3); + executionContext.putDouble("4", 4.4); } @@ -163,20 +163,20 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour assertEquals(step3, tempStep); } - public void testUpdateStepWithoutExecutionAttributes() { + public void testUpdateStepWithoutExecutionContext() { //stepInstanceDao.updateStepInstance(step1); StepInstance tempStep = stepInstanceDao.findStepInstance(jobInstance, step1.getName()); assertEquals(tempStep, step1); } - public void testUpdateStepWithExecutionAttributes() { + public void testUpdateStepWithExecutionContext() { - stepExecutionDao.saveExecutionAttributes(step1.getId(), executionAttributes); + stepExecutionDao.saveExecutionContext(step1.getId(), executionContext); StepInstance tempStep = stepInstanceDao.findStepInstance(jobInstance, step1.getName()); - ExecutionAttributes tempAttributes = stepExecutionDao.findExecutionAttributes(step1.getId()); + ExecutionContext tempAttributes = stepExecutionDao.findExecutionContext(step1.getId()); assertEquals(tempStep, step1); - assertEquals(executionAttributes, tempAttributes); + assertEquals(executionContext, tempAttributes); } public void testSaveStepExecution() { @@ -184,7 +184,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.setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("key1=0,key2=5"))); + execution.setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("key1=0,key2=5"))); execution.setExitStatus(new ExitStatus(false, ExitStatusExceptionClassifier.FATAL_EXCEPTION, "java.lang.Exception")); stepExecutionDao.saveStepExecution(execution); @@ -192,7 +192,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour assertEquals(1, executions.size()); StepExecution tempExecution = (StepExecution) executions.get(0); assertEquals(execution, tempExecution); - assertEquals(execution.getExecutionAttributes().getString("key1"), tempExecution.getExecutionAttributes().getString("key1")); + assertEquals(execution.getExecutionContext().getString("key1"), tempExecution.getExecutionContext().getString("key1")); assertEquals(execution.getExitStatus(), tempExecution.getExitStatus()); } @@ -202,7 +202,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour stepExecution.setEndTime(new Date(System.currentTimeMillis())); stepExecution.setCommitCount(5); stepExecution.setTaskCount(5); - stepExecution.setExecutionAttributes(new ExecutionAttributes()); + stepExecution.setExecutionContext(new ExecutionContext()); stepExecution.setExitStatus(new ExitStatus(false, ExitStatusExceptionClassifier.FATAL_EXCEPTION, "java.lang.Exception")); stepExecutionDao.updateStepExecution(stepExecution); @@ -262,15 +262,15 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour } } - public void testSaveExecutionAttributes(){ + public void testSaveExecutionContext(){ - stepExecutionDao.saveExecutionAttributes(stepExecution.getId(), executionAttributes); - ExecutionAttributes attributes = stepExecutionDao.findExecutionAttributes(stepExecution.getId()); - assertEquals(executionAttributes, attributes); - executionAttributes.putString("newString", "newString"); - stepExecutionDao.updateExecutionAttributes(stepExecution.getId(), executionAttributes); - attributes = stepExecutionDao.findExecutionAttributes(stepExecution.getId()); - assertEquals(executionAttributes, attributes); + stepExecutionDao.saveExecutionContext(stepExecution.getId(), executionContext); + ExecutionContext attributes = stepExecutionDao.findExecutionContext(stepExecution.getId()); + assertEquals(executionContext, attributes); + executionContext.putString("newString", "newString"); + stepExecutionDao.updateExecutionContext(stepExecution.getId(), executionContext); + attributes = stepExecutionDao.findExecutionContext(stepExecution.getId()); + assertEquals(executionContext, attributes); } public void testGetLastStepExecution() { 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 246fdace4..f5107ef16 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 @@ -25,7 +25,7 @@ import org.springframework.batch.core.domain.JobInstance; import org.springframework.batch.core.domain.JobParameters; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; public class MapStepDaoTests extends TestCase { @@ -103,17 +103,17 @@ public class MapStepDaoTests extends TestCase { assertEquals(2, dao.getStepExecutionCount(step)); } - public void testSaveExecutionAttributes() throws Exception { - assertEquals(null, dao.getExecutionAttributes(step.getId())); + public void testSaveExecutionContext() throws Exception { + assertEquals(null, dao.getExecutionContext(step.getId())); Properties data = new Properties(); data.setProperty("restart.key1", "restartData"); - ExecutionAttributes executionAttributes = new ExecutionAttributes(data); + ExecutionContext executionContext = new ExecutionContext(data); StepExecution stepExecution = new StepExecution(step, null, null); - stepExecution.setExecutionAttributes(executionAttributes); + stepExecution.setExecutionContext(executionContext); dao.saveStepExecution(stepExecution); StepExecution tempExecution = dao.getStepExecution(stepExecution.getId(), step); assertEquals(tempExecution, stepExecution); - assertEquals(stepExecution.getExecutionAttributes(), tempExecution.getExecutionAttributes()); + assertEquals(stepExecution.getExecutionContext(), tempExecution.getExecutionContext()); } } 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 cc431d521..389507c31 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 @@ -24,7 +24,7 @@ import junit.framework.TestCase; import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.item.ItemStream; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.stream.ItemStreamAdapter; import org.springframework.batch.item.stream.SimpleStreamManager; import org.springframework.batch.support.PropertiesConverter; @@ -133,11 +133,11 @@ public class SimpleStepContextTests extends TestCase { assertTrue(list.contains("spam")); } - public void testExecutionAttributesWithNotNullService() throws Exception { + public void testExecutionContextWithNotNullService() throws Exception { Map map = new HashMap(); context = new SimpleStepContext(null, null, new StubStreamManager(map)); - assertEquals(1, context.getExecutionAttributes().getProperties().size()); - assertEquals("bar", context.getExecutionAttributes().getProperties().getProperty("foo")); + assertEquals(1, context.getExecutionContext().getProperties().size()); + assertEquals("bar", context.getExecutionContext().getProperties().getProperty("foo")); } public void testStreamManagerRegistration() throws Exception { @@ -164,18 +164,18 @@ public class SimpleStepContextTests extends TestCase { public void close(Object key) { } - public ExecutionAttributes getExecutionAttributes(Object key) { - return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar")); + public ExecutionContext getExecutionContext(Object key) { + return new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar")); } public void open(Object key) { } - public void register(Object key, ItemStream stream, ExecutionAttributes executionAttributes) { + public void register(Object key, ItemStream stream, ExecutionContext executionContext) { map.put(key, stream); } - public void restoreFrom(Object key, ExecutionAttributes data) { + public void restoreFrom(Object key, ExecutionContext data) { } } 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 386b020ef..71b727d1c 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 @@ -103,12 +103,12 @@ public class SimpleStepConfigurationTests extends TestCase { } /** - * Test method for {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveExecutionAttributes()}. + * Test method for {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveExecutionContext()}. */ - public void testIsSaveExecutionAttributes() { - assertEquals(false, configuration.isSaveExecutionAttributes()); - configuration.setSaveExecutionAttributes(true); - assertEquals(true, configuration.isSaveExecutionAttributes()); + public void testIsSaveExecutionContext() { + assertEquals(false, configuration.isSaveExecutionContext()); + configuration.setSaveExecutionContext(true); + assertEquals(true, configuration.isSaveExecutionContext()); } } 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 bcdef0e75..20af14203 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 @@ -38,7 +38,7 @@ import org.springframework.batch.execution.repository.dao.MapJobDao; import org.springframework.batch.execution.repository.dao.MapStepDao; import org.springframework.batch.execution.scope.StepScope; import org.springframework.batch.execution.scope.StepSynchronizationManager; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.exception.ResetFailedException; @@ -283,7 +283,7 @@ public class SimpleStepExecutorTests extends TestCase { StepInstance step = new StepInstance(new Long(1)); MockRestartableTasklet tasklet = new MockRestartableTasklet(); stepExecutor.setItemReader(tasklet); - stepConfiguration.setSaveExecutionAttributes(true); + stepConfiguration.setSaveExecutionContext(true); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecutionContext); @@ -302,12 +302,12 @@ public class SimpleStepExecutorTests extends TestCase { step.setStepExecutionCount(1); MockRestartableTasklet tasklet = new MockRestartableTasklet(); stepExecutor.setItemReader(tasklet); - stepConfiguration.setSaveExecutionAttributes(true); + stepConfiguration.setSaveExecutionContext(true); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecutionContext); stepExecution - .setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); + .setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); step.setLastExecution(stepExecution); stepExecutor.execute(stepExecution); @@ -326,7 +326,7 @@ public class SimpleStepExecutorTests extends TestCase { step.setStepExecutionCount(1); MockRestartableTasklet tasklet = new MockRestartableTasklet(); stepConfiguration.setItemReader(tasklet); - stepConfiguration.setSaveExecutionAttributes(false); + stepConfiguration.setSaveExecutionContext(false); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecutionContext); @@ -354,7 +354,7 @@ public class SimpleStepExecutorTests extends TestCase { return ExitStatus.FINISHED; } }); - stepConfiguration.setSaveExecutionAttributes(true); + stepConfiguration.setSaveExecutionContext(true); JobExecution jobExecution = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecution); @@ -408,17 +408,17 @@ public class SimpleStepExecutorTests extends TestCase { return ExitStatus.FINISHED; } }); - stepConfiguration.setSaveExecutionAttributes(true); + stepConfiguration.setSaveExecutionContext(true); JobExecution jobExecution = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step, jobExecution); - assertEquals(false, stepExecution.getExecutionAttributes().containsKey("foo")); + assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); final Map map = new HashMap(); stepExecutor.setStreamManager(new SimpleStreamManager(new ResourcelessTransactionManager()) { - public ExecutionAttributes getExecutionAttributes(Object key) { + public ExecutionContext getExecutionContext(Object key) { // TODO Auto-generated method stub - return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar")); + return new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar")); } }); @@ -426,7 +426,7 @@ public class SimpleStepExecutorTests extends TestCase { // At least once in that process the statistics service was asked for // statistics... - assertEquals("bar", stepExecution.getExecutionAttributes().getString("foo")); + assertEquals("bar", stepExecution.getExecutionContext().getString("foo")); // ...but nothing was registered because nothing with step scoped. assertEquals(0, map.size()); } @@ -448,12 +448,12 @@ public class SimpleStepExecutorTests extends TestCase { return restoreFromCalledWithSomeContext; } - public ExecutionAttributes getExecutionAttributes() { + public ExecutionContext getExecutionContext() { getExecutionAttributesCalled = true; - return new ExecutionAttributes(PropertiesConverter.stringToProperties("spam=bucket")); + return new ExecutionContext(PropertiesConverter.stringToProperties("spam=bucket")); } - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { restoreFromCalled = true; restoreFromCalledWithSomeContext = data.getProperties().size() > 0; } @@ -507,7 +507,7 @@ public class SimpleStepExecutorTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecutionContext); stepExecution - .setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); + .setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); step.setLastExecution(stepExecution); try { @@ -544,7 +544,7 @@ public class SimpleStepExecutorTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecutionContext); stepExecution - .setExecutionAttributes(new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"))); + .setExecutionContext(new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"))); step.setLastExecution(stepExecution); try { diff --git a/spring-batch-execution/src/test/resources/simple-container-definition.xml b/spring-batch-execution/src/test/resources/simple-container-definition.xml index 4ad2ab088..ec419cb87 100644 --- a/spring-batch-execution/src/test/resources/simple-container-definition.xml +++ b/spring-batch-execution/src/test/resources/simple-container-definition.xml @@ -28,7 +28,7 @@ class="org.springframework.batch.execution.step.simple.SimpleStep" abstract="true">- * {@link ExecutionAttributes}: The current row is returned as restart data, + * {@link ExecutionContext}: The current row is returned as restart data, * and when restored from that same data, the cursor is opened and the current * row set to the value within the restart data. There are also two statistics * returned by this input source: the current line being processed and the @@ -378,11 +378,11 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen /* * (non-Javadoc) - * @see org.springframework.batch.item.stream.ItemStreamAdapter#getExecutionAttributes() + * @see org.springframework.batch.item.stream.ItemStreamAdapter#getExecutionContext() */ - public ExecutionAttributes getExecutionAttributes() { + public ExecutionContext getExecutionContext() { String skipped = skippedRows.toString(); - ExecutionAttributes context = new ExecutionAttributes(); + ExecutionContext context = new ExecutionContext(); context.putString(SKIPPED_ROWS, skipped.substring(1, skipped.length() - 1)); context.putLong(CURRENT_PROCESSED_ROW, currentProcessedRow); context.putLong(SKIP_COUNT, skipCount); @@ -391,9 +391,9 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen /* * (non-Javadoc) - * @see org.springframework.batch.item.stream.ItemStreamAdapter#restoreFrom(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.stream.ItemStreamAdapter#restoreFrom(org.springframework.batch.item.ExecutionContext) */ - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { Assert.state(!initialized); if (data == null) 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 7b8650f17..5629c9bd0 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 @@ -19,7 +19,7 @@ import java.util.Iterator; import java.util.List; import org.springframework.batch.io.support.AbstractTransactionalIoSource; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.KeyedItemReader; import org.springframework.beans.factory.InitializingBean; @@ -147,7 +147,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource implem * been initialized before calling restore (meaning, read has been called) * then an IllegalStateException will be thrown, since all input sources * should be restored before being read from, otherwise already processed - * data could be returned. The {@link ExecutionAttributes} attempting to be + * data could be returned. The {@link ExecutionContext} attempting to be * restored from must have been obtained from the same input source * as the one being restored from otherwise it is invalid. * @@ -156,10 +156,10 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource implem * @throws IllegalStateException if the input source has already been * initialized. */ - public final void restoreFrom(ExecutionAttributes data) { + public final void restoreFrom(ExecutionContext data) { - Assert.notNull(data, "ExecutionAttributes must not be null."); - Assert.notNull(data.getProperties(), "ExecutionAttributes properties must not be null."); + Assert.notNull(data, "ExecutionContext must not be null."); + Assert.notNull(data.getProperties(), "ExecutionContext properties must not be null."); Assert.state(!initialized, "Cannot restore when already intialized. Call" + " close() first before restore()"); if (data.getProperties().size() == 0) { @@ -174,8 +174,8 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource implem } } - public ExecutionAttributes getExecutionAttributes() { - return keyGenerator.getKeyAsExecutionAttributes(getCurrentKey()); + public ExecutionContext getExecutionContext() { + return keyGenerator.getKeyAsExecutionContext(getCurrentKey()); } public void afterPropertiesSet() throws Exception { @@ -223,7 +223,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource implem /* * (non-Javadoc) * - * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionContext) */ public void mark() { lastCommitIndex = currentIndex; @@ -232,7 +232,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource implem /* * (non-Javadoc) * - * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionContext) */ public void reset() { 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 ef04d45ef..bf4e8c06a 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 @@ -2,7 +2,7 @@ package org.springframework.batch.io.driving; import java.util.List; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; /** * Strategy interface used to generate keys in driving query input. @@ -20,19 +20,19 @@ public interface KeyGenerator { /** * Restore the keys list based on provided restart data. * - * @param executionAttributes, the restart data to restore the keys list from. + * @param executionContext, the restart data to restore the keys list from. * @return a list of keys. - * @throws IllegalArgumentException is executionAttributes is null. + * @throws IllegalArgumentException if executionContext is null. */ - List restoreKeys(ExecutionAttributes executionAttributes); + List restoreKeys(ExecutionContext executionContext); /** * Return the provided key as restart data. * * @param key to be converted to restart data. - * @return {@link ExecutionAttributes} representation of the key. + * @return {@link ExecutionContext} representation of the key. * @throws IllegalArgumentException if key is null. * @throws IllegalArgumentException if key is an incompatible type. */ - ExecutionAttributes getKeyAsExecutionAttributes(Object key); + ExecutionContext getKeyAsExecutionContext(Object key); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionContextRowMapper.java similarity index 76% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionContextRowMapper.java index e6391859e..d9c22b521 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionAttributesRowMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ColumnMapExecutionContextRowMapper.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.Properties; import java.util.Map.Entry; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.core.CollectionFactory; import org.springframework.jdbc.core.ColumnMapRowMapper; import org.springframework.jdbc.core.PreparedStatementSetter; @@ -23,8 +23,8 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; /** - *
Extension of the ColumnMapRowMapper that converts a column map to {@link ExecutionAttributes} and allows - * {@link ExecutionAttributes} to be converted back as a PreparedStatementSetter. This is useful in a restart + * Extension of the ColumnMapRowMapper that converts a column map to {@link ExecutionContext} and allows + * {@link ExecutionContext} to be converted back as a PreparedStatementSetter. This is useful in a restart * scenario, as it allows for the standard functionality of the ColumnMapRowMapper to be used to * create a map representing the columns returned by a query. It should be noted that this column ordering * is preserved in the map using a link list version of Map. @@ -32,15 +32,15 @@ import org.springframework.util.ClassUtils; * * @author Lucas Ward * @author Dave Syer - * @see ExecutionAttributesRowMapper + * @see ExecutionContextRowMapper */ -public class ColumnMapExecutionAttributesRowMapper extends ColumnMapRowMapper implements ExecutionAttributesRowMapper { +public class ColumnMapExecutionContextRowMapper extends ColumnMapRowMapper implements ExecutionContextRowMapper { - public static final String KEY_PREFIX = ClassUtils.getQualifiedName(ColumnMapExecutionAttributesRowMapper.class) + ".KEY."; + public static final String KEY_PREFIX = ClassUtils.getQualifiedName(ColumnMapExecutionContextRowMapper.class) + ".KEY."; - public PreparedStatementSetter createSetter(ExecutionAttributes executionAttributes) { + public PreparedStatementSetter createSetter(ExecutionContext executionContext) { - ColumnMapExecutionAttributes columnData = new ColumnMapExecutionAttributes(executionAttributes.getProperties()); + ColumnMapExecutionContext columnData = new ColumnMapExecutionContext(executionContext.getProperties()); List columns = new ArrayList(); for (Iterator iterator = columnData.keys.entrySet().iterator(); iterator.hasNext();) { @@ -52,21 +52,21 @@ public class ColumnMapExecutionAttributesRowMapper extends ColumnMapRowMapper im return new ArgPreparedStatementSetter(columns.toArray()); } - public ExecutionAttributes createExecutionAttributes(Object key) { - Assert.isInstanceOf(Map.class, key, "Input to create ExecutionAttributes must be of type Map."); + public ExecutionContext createExecutionContext(Object key) { + Assert.isInstanceOf(Map.class, key, "Input to create ExecutionContext must be of type Map."); Map keys = (Map) key; - return new ColumnMapExecutionAttributes(keys); + return new ColumnMapExecutionContext(keys); } - private static class ColumnMapExecutionAttributes extends ExecutionAttributes { + private static class ColumnMapExecutionContext extends ExecutionContext { private final Map keys; - public ColumnMapExecutionAttributes(Map keys) { + public ColumnMapExecutionContext(Map keys) { this.keys = keys; } - public ColumnMapExecutionAttributes(Properties props) { + public ColumnMapExecutionContext(Properties props) { keys = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(props.size()); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionContextRowMapper.java similarity index 62% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionContextRowMapper.java index 145b050c8..4170302c5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionAttributesRowMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/driving/support/ExecutionContextRowMapper.java @@ -15,39 +15,39 @@ */ package org.springframework.batch.io.driving.support; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.RowMapper; /** - * {@link ExecutionAttributesRowMapper} extends the standard {@link RowMapper} interface to provide for - * converting an object returned from a RowMapper to {@link ExecutionAttributes} and back again. One + * {@link ExecutionContextRowMapper} extends the standard {@link RowMapper} interface to provide for + * converting an object returned from a RowMapper to {@link ExecutionContext} and back again. One * of the most common use cases for this type of functionality is the DrivingQuery approach - * to sql processing. Using a {@link ExecutionAttributesRowMapper}, developers can create each unique key + * to sql processing. Using a {@link ExecutionContextRowMapper}, developers can create each unique key * to suite their specific needs, and also describe how such a key would be converted to - * {@link ExecutionAttributes}, so that it can be serialized and stored. + * {@link ExecutionContext}, so that it can be serialized and stored. * * @author Lucas Ward * @see RowMapper * @since 1.0 */ -public interface ExecutionAttributesRowMapper extends RowMapper { +public interface ExecutionContextRowMapper extends RowMapper { /** - * Given the provided composite key, return a {@link ExecutionAttributes} representation. + * Given the provided composite key, return a {@link ExecutionContext} representation. * * @param key - * @return ExecutionAttributes representing the composite key. + * @return ExecutionContext representing the composite key. * @throws IllegalArgumentException if key is null or of an unsupported type. */ - public ExecutionAttributes createExecutionAttributes(Object key); + public ExecutionContext createExecutionContext(Object key); /** * Given the provided restart data, return a PreparedStatementSeter that can * be used as parameters to a JdbcTemplate. * - * @param executionAttributes + * @param executionContext * @return an array of objects that can be used as arguments to a JdbcTemplate. */ - public PreparedStatementSetter createSetter(ExecutionAttributes executionAttributes); + public PreparedStatementSetter createSetter(ExecutionContext executionContext); } 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 d3d555965..b86aaed86 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 @@ -5,7 +5,7 @@ import java.util.Properties; import org.springframework.batch.io.driving.DrivingQueryItemReader; import org.springframework.batch.io.driving.KeyGenerator; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.orm.ibatis.SqlMapClientTemplate; import org.springframework.util.Assert; @@ -40,22 +40,22 @@ public class IbatisKeyGenerator implements KeyGenerator { } /* (non-Javadoc) - * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionAttributes(java.lang.Object) + * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionContext(java.lang.Object) */ - public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { + public ExecutionContext getKeyAsExecutionContext(Object key) { Properties props = new Properties(); props.setProperty(RESTART_KEY, key.toString()); - ExecutionAttributes executionAttributes = new ExecutionAttributes(); - executionAttributes.putString(RESTART_KEY, key.toString()); - return executionAttributes; + ExecutionContext executionContext = new ExecutionContext(); + executionContext.putString(RESTART_KEY, key.toString()); + return executionContext; } /** * Restore the keys list given the provided restart data. * - * @see org.springframework.batch.io.driving.DrivingQueryItemReader#restoreKeys(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.io.driving.DrivingQueryItemReader#restoreKeys(org.springframework.batch.item.ExecutionContext) */ - public List restoreKeys(ExecutionAttributes data) { + public List restoreKeys(ExecutionContext data) { Properties props = data.getProperties(); Object key = props.getProperty(RESTART_KEY); 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 7e7c77d27..eec7406f0 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 @@ -20,7 +20,7 @@ import java.util.List; import org.springframework.batch.io.driving.DrivingQueryItemReader; import org.springframework.batch.io.driving.KeyGenerator; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -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 ExecutionAttributesRowMapper} to map each row in the resultset to an Object must be set in + * a {@link ExecutionContextRowMapper} 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 ExecutionAttributesRowMapper keyMapper = new ColumnMapExecutionAttributesRowMapper(); + private ExecutionContextRowMapper keyMapper = new ColumnMapExecutionContextRowMapper(); 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.ExecutionAttributes) + * @see org.springframework.batch.io.driving.KeyGenerator#restoreKeys(org.springframework.batch.item.ExecutionContext) */ - public List restoreKeys(ExecutionAttributes executionAttributes) { + public List restoreKeys(ExecutionContext executionContext) { 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 (executionAttributes.getProperties() != null) { - return jdbcTemplate.query(restartSql, keyMapper.createSetter(executionAttributes), keyMapper); + if (executionContext.getProperties() != null) { + return jdbcTemplate.query(restartSql, keyMapper.createSetter(executionContext), keyMapper); } return new ArrayList(); } /* (non-Javadoc) - * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionAttributes(java.lang.Object) + * @see org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionContext(java.lang.Object) */ - public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { + public ExecutionContext getKeyAsExecutionContext(Object key) { Assert.state(keyMapper != null, "Kye mapper must not be null."); - return keyMapper.createExecutionAttributes(key); + return keyMapper.createExecutionContext(key); } /** @@ -121,12 +121,12 @@ public class MultipleColumnJdbcKeyGenerator implements } /** - * Set the {@link ExecutionAttributesRowMapper} to be used to map a resultset + * Set the {@link ExecutionContextRowMapper} to be used to map a resultset * to keys. * * @param keyMapper */ - public void setKeyMapper(ExecutionAttributesRowMapper keyMapper) { + public void setKeyMapper(ExecutionContextRowMapper 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 abed9d80c..66ccc90a3 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 @@ -20,7 +20,7 @@ import java.util.List; import org.apache.commons.lang.ClassUtils; import org.springframework.batch.io.driving.KeyGenerator; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.SingleColumnRowMapper; @@ -95,36 +95,36 @@ public class SingleColumnJdbcKeyGenerator implements KeyGenerator { /** * Get the restart data representing the last processed key. * - * @see KeyGenerator#getKeyAsExecutionAttributes(Object) + * @see KeyGenerator#getKeyAsExecutionContext(Object) * @throws IllegalArgumentException if key is null. */ - public ExecutionAttributes getKeyAsExecutionAttributes(Object key) { + public ExecutionContext getKeyAsExecutionContext(Object key) { Assert.notNull(key, "The key must not be null."); - ExecutionAttributes context = new ExecutionAttributes(); + ExecutionContext context = new ExecutionContext(); context.putString(RESTART_KEY, key.toString()); return context; } /** * Return the remaining to be processed for the provided - * {@link ExecutionAttributes}. The {@link ExecutionAttributes} attempting to be + * {@link ExecutionContext}. The {@link ExecutionContext} attempting to be * restored from must have been obtained from the same * KeyGenerationStrategy as the one being restored from otherwise * it is invalid. * - * @param executionAttributes {@link ExecutionAttributes} obtained by calling - * {@link #getKeyAsExecutionAttributes(Object)} during a previous run. + * @param executionContext {@link ExecutionContext} obtained by calling + * {@link #getKeyAsExecutionContext(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) + * @see KeyGenerator#restoreKeys(org.springframework.batch.item.ExecutionContext) */ - public List restoreKeys(ExecutionAttributes executionAttributes) { + public List restoreKeys(ExecutionContext executionContext) { - Assert.notNull(executionAttributes, "The restart data must not be null."); + Assert.notNull(executionContext, "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 = executionAttributes.getProperties().getProperty(RESTART_KEY); + String lastProcessedKey = executionContext.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/FlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemReader.java index 5bd701cea..f07beb5ce 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/FlatFileItemReader.java @@ -32,7 +32,7 @@ import org.springframework.batch.io.file.separator.ResourceLineReader; import org.springframework.batch.io.file.transform.AbstractLineTokenizer; import org.springframework.batch.io.file.transform.DelimitedLineTokenizer; import org.springframework.batch.io.file.transform.LineTokenizer; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.exception.StreamException; @@ -184,9 +184,9 @@ public class FlatFileItemReader implements ItemReader, Skippable, ItemStream, In * and position the buffer reader according to information provided by the * restart data * - * @param data {@link ExecutionAttributes} information + * @param data {@link ExecutionContext} information */ - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { if (data == null || data.getProperties() == null || data.getProperties().getProperty(READ_STATISTICS_NAME) == null || getReader() == null) { @@ -213,14 +213,14 @@ public class FlatFileItemReader implements ItemReader, Skippable, ItemStream, In * the current Line Count which can be used to reinitialise the batch job in * case of restart. */ - public ExecutionAttributes getExecutionAttributes() { + public ExecutionContext getExecutionContext() { if (reader == null) { throw new StreamException("ItemStream not open or already closed."); } - ExecutionAttributes executionAttributes = new ExecutionAttributes(); - executionAttributes.putLong(READ_STATISTICS_NAME, reader.getPosition()); - executionAttributes.putLong(SKIPPED_STATISTICS_NAME, skippedLines.size()); - return executionAttributes; + ExecutionContext executionContext = new ExecutionContext(); + executionContext.putLong(READ_STATISTICS_NAME, reader.getPosition()); + executionContext.putLong(SKIPPED_STATISTICS_NAME, skippedLines.size()); + return executionContext; } /** @@ -237,7 +237,7 @@ public class FlatFileItemReader implements ItemReader, Skippable, ItemStream, In /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionContext) */ public void mark() { getReader().mark(); @@ -245,7 +245,7 @@ public class FlatFileItemReader implements ItemReader, Skippable, ItemStream, In /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionContext) */ public void reset() { 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 d0123898b..c8cd5e5ce 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 @@ -31,7 +31,7 @@ import java.util.Properties; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.io.exception.BatchEnvironmentException; import org.springframework.batch.io.support.AbstractTransactionalIoSource; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.exception.ResetFailedException; @@ -71,7 +71,7 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements private Resource resource; - private ExecutionAttributes executionAttributes = new ExecutionAttributes(); + private ExecutionContext executionContext = new ExecutionContext(); private OutputState state = null; @@ -215,22 +215,22 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements } /** - * @see ItemStream#getExecutionAttributes() + * @see ItemStream#getExecutionContext() */ - public ExecutionAttributes getExecutionAttributes() { + public ExecutionContext getExecutionContext() { if (state == null) { throw new StreamException("ItemStream not open or already closed."); } - executionAttributes.putLong(RESTART_DATA_NAME, state.position()); - executionAttributes.putLong(WRITTEN_STATISTICS_NAME, state.linesWritten); - executionAttributes.putLong(RESTART_COUNT_STATISTICS_NAME, state.restartCount); - return executionAttributes; + executionContext.putLong(RESTART_DATA_NAME, state.position()); + executionContext.putLong(WRITTEN_STATISTICS_NAME, state.linesWritten); + executionContext.putLong(RESTART_COUNT_STATISTICS_NAME, state.restartCount); + return executionContext; } /** - * @see ItemStream#restoreFrom(ExecutionAttributes) + * @see ItemStream#restoreFrom(ExecutionContext) */ - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { if (data == null) return; getOutputState().restoreFrom(data.getProperties()); @@ -520,7 +520,7 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements /* * (non-Javadoc) - * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#mark(org.springframework.batch.item.ExecutionContext) */ public void mark() { getOutputState().mark(); @@ -528,7 +528,7 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements /* * (non-Javadoc) - * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.io.support.AbstractTransactionalIoSource#reset(org.springframework.batch.item.ExecutionContext) */ public void reset() throws ResetFailedException { try { 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 d4cede3ef..3143dc092 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 @@ -16,7 +16,7 @@ import org.springframework.batch.io.xml.stax.DefaultFragmentEventReader; import org.springframework.batch.io.xml.stax.DefaultTransactionalEventReader; import org.springframework.batch.io.xml.stax.FragmentEventReader; import org.springframework.batch.io.xml.stax.TransactionalEventReader; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.exception.StreamException; @@ -174,25 +174,25 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade /** * @return wrapped count of records read so far. - * @see ItemStream#getExecutionAttributes() + * @see ItemStream#getExecutionContext() */ - public ExecutionAttributes getExecutionAttributes() { - ExecutionAttributes executionAttributes = new ExecutionAttributes(); - executionAttributes.putLong(READ_COUNT_STATISTICS_NAME, currentRecordCount); - return executionAttributes; + public ExecutionContext getExecutionContext() { + ExecutionContext executionContext = new ExecutionContext(); + executionContext.putLong(READ_COUNT_STATISTICS_NAME, currentRecordCount); + return executionContext; } /** * Restores the input source for the given restart data by rereading and - * skipping the number of records stored in the {@link ExecutionAttributes}. + * skipping the number of records stored in the {@link ExecutionContext}. * - * @param ExecutionAttributes that holds the line count from the last + * @param ExecutionContext that holds the line count from the last * commit. * @throws IllegalStateException if the ItemReader has already been * initialized or if the number of records to read and skip exceeds the * available records. */ - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { if (data == null || data.getProperties() == null || !data.containsKey(READ_COUNT_STATISTICS_NAME)) { return; @@ -263,7 +263,7 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionContext) */ public void mark() { lastCommitPointRecordCount = currentRecordCount; @@ -273,7 +273,7 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionContext) */ public void reset() { currentRecordCount = lastCommitPointRecordCount; 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 f7e95c98f..786193848 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 @@ -15,7 +15,7 @@ import javax.xml.stream.XMLStreamException; import org.springframework.batch.io.support.FileUtils; import org.springframework.batch.io.xml.stax.NoStartEndDocumentStreamWriter; -import org.springframework.batch.item.ExecutionAttributes; +import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.exception.StreamException; @@ -352,13 +352,13 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing /** * Get the restart data. * @return the restart data - * @see org.springframework.batch.item.ItemStream#getExecutionAttributes() + * @see org.springframework.batch.item.ItemStream#getExecutionContext() */ - public ExecutionAttributes getExecutionAttributes() { + public ExecutionContext getExecutionContext() { if (!initialized) { throw new StreamException("ItemStream is not open, or may have been closed. Cannot access context."); } - ExecutionAttributes context = new ExecutionAttributes(); + ExecutionContext context = new ExecutionContext(); context.putLong(RESTART_DATA_NAME, getPosition()); context.putLong(WRITE_STATISTICS_NAME, currentRecordCount); return context; @@ -367,9 +367,9 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing /** * Restore processing from provided restart data. * @param data the restart data - * @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#restoreFrom(org.springframework.batch.item.ExecutionContext) */ - public void restoreFrom(ExecutionAttributes data) { + public void restoreFrom(ExecutionContext data) { long startAtPosition = 0; @@ -440,7 +440,7 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.ExecutionContext) */ public void mark() { lastCommitPointPosition = getPosition(); @@ -449,7 +449,7 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing /* * (non-Javadoc) - * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionAttributes) + * @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.ExecutionContext) */ public void reset() { currentRecordCount = lastCommitPointRecordCount; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributes.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java similarity index 94% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributes.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java index 17cc5548e..d27eda727 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributes.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java @@ -34,17 +34,17 @@ import org.springframework.util.Assert; * * @author Lucas Ward */ -public class ExecutionAttributes { +public class ExecutionContext { private boolean dirty = false; private final Map map; - public ExecutionAttributes() { + public ExecutionContext() { map = new HashMap(); } - public ExecutionAttributes(Map map){ + public ExecutionContext(Map map){ this.map = map; } @@ -137,13 +137,13 @@ public class ExecutionAttributes { } public boolean equals(Object obj) { - if(obj instanceof ExecutionAttributes == false){ + if(obj instanceof ExecutionContext == false){ return false; } if(this == obj){ return true; } - ExecutionAttributes rhs = (ExecutionAttributes)obj; + ExecutionContext rhs = (ExecutionContext)obj; return this.entrySet().equals(rhs.entrySet()); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContextProvider.java similarity index 76% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContextProvider.java index d9991fd01..483021495 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContextProvider.java @@ -19,14 +19,14 @@ package org.springframework.batch.item; * @author Dave Syer * */ -public interface ExecutionAttributesProvider { +public interface ExecutionContextProvider { /** - * Get {@link ExecutionAttributes} representing this object's current state. + * Get {@link ExecutionContext} representing this object's current state. * Should not return null even if there is no state. * - * @return {@link ExecutionAttributes} representing current state. + * @return {@link ExecutionContext} representing current state. */ - ExecutionAttributes getExecutionAttributes(); + ExecutionContext getExecutionContext(); } 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 e366d3dc9..eb256954c 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 @@ -27,27 +27,27 @@ import org.springframework.batch.item.exception.StreamException; ** *
- * The state that is stored is represented as {@link ExecutionAttributes} which + * The state that is stored is represented as {@link ExecutionContext} which * enforces a requirement that any restart data can be represented by a * Properties object. In general, the contract is that - * {@link ExecutionAttributes} that is returned via the - * {@link #getExecutionAttributes()} method will be given back to the - * {@link #restoreFrom(ExecutionAttributes)} method, exactly as it was provided. + * {@link ExecutionContext} that is returned via the + * {@link #getExecutionContext()} method will be given back to the + * {@link #restoreFrom(ExecutionContext)} method, exactly as it was provided. *
* * @author Dave Syer * */ -public interface ItemStream extends ExecutionAttributesProvider { +public interface ItemStream extends ExecutionContextProvider { /** - * Restore to the state given the provided {@link ExecutionAttributes}. + * Restore to the state given the provided {@link ExecutionContext}. * This can be used to restart after a failure - hence not normally used * more than once per call to {@link #open()}. * * @param context */ - void restoreFrom(ExecutionAttributes context); + void restoreFrom(ExecutionContext context); /** * If any resources are needed for the stream to operate they need to be @@ -70,7 +70,7 @@ public interface ItemStream extends ExecutionAttributesProvider { * stream is being accessed from multiple threads concurrently, it will have * to manage that internally, and also reflect only the completed marks * (independent of the order they happen) when - * {@link ExecutionAttributesProvider#getExecutionAttributes()} is called. + * {@link ExecutionContextProvider#getExecutionContext()} is called. * * @return true if mark and reset are supported by the {@link ItemStream} */ @@ -79,7 +79,7 @@ public interface ItemStream extends ExecutionAttributesProvider { /** * Mark the stream so that it can be reset later and the items backed out. * After this method is called the result will be reflected in subsequent - * calls to {@link ExecutionAttributesProvider#getExecutionAttributes()}.