diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 3e88fda21..c8bbbce40 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -11,15 +11,11 @@ import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; -import org.springframework.jdbc.support.lob.DefaultLobHandler; -import org.springframework.jdbc.support.lob.LobCreator; -import org.springframework.jdbc.support.lob.LobHandler; import org.springframework.util.Assert; /** @@ -62,12 +58,8 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement private int exitMessageLength = DEFAULT_EXIT_MESSAGE_LENGTH; - private LobHandler lobHandler = new DefaultLobHandler(); - private DataFieldMaxValueIncrementer stepExecutionIncrementer; - private JdbcExecutionContextDao ecDao = new JdbcExecutionContextDao(); - /** * Public setter for the exit message length in database. Do not set this if * you haven't modified the schema. @@ -77,11 +69,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement this.exitMessageLength = exitMessageLength; } - public ExecutionContext findExecutionContext(final StepExecution stepExecution) { - - return ecDao.getExecutionContext(stepExecution); - } - /** * Save a StepExecution. A unique id will be generated by the * stepExecutionIncrementor, and then set in the StepExecution. All values @@ -130,18 +117,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null."); } - /** - * Save or update execution attributes. A lob creator must be used, since - * any attributes that don't match a provided type must be serialized into a - * blob. - * - * @see LobCreator - */ - public void persistExecutionContext(final StepExecution stepExecution) { - - ecDao.persistExecutionContext(stepExecution); - } - /* * (non-Javadoc) * @see org.springframework.batch.execution.repository.dao.StepExecutionDao#updateStepExecution(org.springframework.batch.core.domain.StepExecution) @@ -225,7 +200,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement stepExecution.setCommitCount(rs.getInt(6)); stepExecution.setItemCount(rs.getInt(7)); stepExecution.setExitStatus(new ExitStatus("Y".equals(rs.getString(8)), rs.getString(9), rs.getString(10))); - stepExecution.setExecutionContext(findExecutionContext(stepExecution)); stepExecution.setReadSkipCount(rs.getInt(11)); stepExecution.setWriteSkipCount(rs.getInt(12)); stepExecution.setRollbackCount(rs.getInt(13)); @@ -234,10 +208,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement } - public void setLobHandler(LobHandler lobHandler) { - this.lobHandler = lobHandler; - } - public void setStepExecutionIncrementer(DataFieldMaxValueIncrementer stepExecutionIncrementer) { this.stepExecutionIncrementer = stepExecutionIncrementer; } @@ -245,10 +215,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(stepExecutionIncrementer, "StepExecutionIncrementer cannot be null."); - ecDao.setJdbcTemplate(getJdbcTemplate()); - ecDao.setLobHandler(lobHandler); - ecDao.setTablePrefix(getTablePrefix()); - ecDao.afterPropertiesSet(); } @SuppressWarnings("unchecked") diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index bd8a4ddf6..a3e6624ce 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -21,7 +21,6 @@ import java.util.Map; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.util.Assert; @@ -35,17 +34,11 @@ public class MapStepExecutionDao implements StepExecutionDao { .createTransactionalMap(); private static long currentId = 0; - - private MapExecutionContextDao ecDao = new MapExecutionContextDao(); public static void clear() { executionsByJobExecutionId.clear(); } - public ExecutionContext findExecutionContext(StepExecution stepExecution) { - return ecDao.getExecutionContext(stepExecution); - } - public void saveStepExecution(StepExecution stepExecution) { Assert.isTrue(stepExecution.getId() == null); Assert.isTrue(stepExecution.getVersion() == null); @@ -92,8 +85,4 @@ public class MapStepExecutionDao implements StepExecutionDao { return (StepExecution) executions.get(step.getName()); } - public void persistExecutionContext(StepExecution stepExecution) { - ecDao.persistExecutionContext(stepExecution); - } - } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java index 659549535..dc14e295d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java @@ -281,6 +281,10 @@ public class SimpleJobRepository implements JobRepository { latest = stepExecution; } } + if (latest != null) { + ExecutionContext executionContext = ecDao.getExecutionContext(latest); + latest.setExecutionContext(executionContext); + } return latest; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MockStepDao.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MockStepDao.java index 4b45939ff..80c85497b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MockStepDao.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MockStepDao.java @@ -16,22 +16,13 @@ package org.springframework.batch.core.repository.support; -import java.util.List; - import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.repository.dao.StepExecutionDao; -import org.springframework.batch.item.ExecutionContext; public class MockStepDao implements StepExecutionDao { - private List newSteps; - - public List findStepInstances(JobInstance job) { - return newSteps; - } public void saveStepExecution(StepExecution stepExecution) { } @@ -39,17 +30,6 @@ public class MockStepDao implements StepExecutionDao { public void updateStepExecution(StepExecution stepExecution) { } - public void setStepsToReturnOnCreate(List steps) { - this.newSteps = steps; - } - - public ExecutionContext findExecutionContext(StepExecution stepExecution) { - return null; - } - - public void persistExecutionContext(StepExecution stepExecution) { - } - public StepExecution getStepExecution(JobExecution jobExecution, Step step) { return null; }