RESOLVED - issue BATCH-362: Rename ExecutionAttributes to ExecutionContext
http://jira.springframework.org/browse/BATCH-362
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStep"
|
||||
abstract="true">
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<property name="saveExecutionAttributes" value="false" />
|
||||
<property name="saveExecutionContext" value="false" />
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
|
||||
Reference in New Issue
Block a user