IN PROGRESS - BATCH-518: clean up the *Or* repository methods
renamed saveOrUpdateExecutionContext to persistExecutionContext (since EC has no identity 'save vs. update' doesn't apply).
This commit is contained in:
@@ -77,7 +77,7 @@ public interface JobRepository {
|
||||
* that an ID be assigned before calling this method. Instead, it should be
|
||||
* left blank, to be assigned by a {@link JobRepository}. The
|
||||
* {@link ExecutionContext} of the {@link StepExecution} is <em>not</em>
|
||||
* saved: see {@link #saveOrUpdateExecutionContext(StepExecution)}.
|
||||
* saved: see {@link #persistExecutionContext(StepExecution)}.
|
||||
*
|
||||
* Preconditions: {@link StepExecution} must have a valid {@link Step}.
|
||||
*
|
||||
@@ -95,12 +95,13 @@ public interface JobRepository {
|
||||
void update(StepExecution stepExecution);
|
||||
|
||||
/**
|
||||
* Save the {@link ExecutionContext} of the given {@link StepExecution}.
|
||||
* Persist the {@link ExecutionContext} of the given {@link StepExecution}
|
||||
* and enclosing {@link JobExecution}.
|
||||
*
|
||||
* @param stepExecution the {@link StepExecution} containing the
|
||||
* {@link ExecutionContext} to be saved.
|
||||
*/
|
||||
void saveOrUpdateExecutionContext(StepExecution stepExecution);
|
||||
void persistExecutionContext(StepExecution stepExecution);
|
||||
|
||||
/**
|
||||
* @return the last execution of step for the given job instance.
|
||||
|
||||
@@ -252,7 +252,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
return ecDao.getExecutionContext(jobExecution);
|
||||
}
|
||||
|
||||
public void saveOrUpdateExecutionContext(JobExecution jobExecution) {
|
||||
public void persistExecutionContext(JobExecution jobExecution) {
|
||||
ecDao.saveOrUpdateExecutionContext(jobExecution);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
*
|
||||
* @see LobCreator
|
||||
*/
|
||||
public void saveOrUpdateExecutionContext(final StepExecution stepExecution) {
|
||||
public void persistExecutionContext(final StepExecution stepExecution) {
|
||||
|
||||
ecDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,6 @@ public interface JobExecutionDao {
|
||||
* {@link ExecutionContext} to be saved.
|
||||
* @throws IllegalArgumentException if the attributes are null.
|
||||
*/
|
||||
void saveOrUpdateExecutionContext(JobExecution jobExecution);
|
||||
void persistExecutionContext(JobExecution jobExecution);
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
|
||||
return (ExecutionContext) contextsByJobExecutionId.get(jobExecution.getId());
|
||||
}
|
||||
|
||||
public void saveOrUpdateExecutionContext(JobExecution jobExecution) {
|
||||
public void persistExecutionContext(JobExecution jobExecution) {
|
||||
contextsByJobExecutionId.put(jobExecution.getId(), jobExecution.getExecutionContext());
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
|
||||
return (StepExecution) executions.get(step.getName());
|
||||
}
|
||||
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
contextsByStepExecutionId.put(stepExecution.getId(), stepExecution.getExecutionContext());
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface StepExecutionDao {
|
||||
* {@link ExecutionContext} to be saved.
|
||||
* @throws IllegalArgumentException if the attributes are null.
|
||||
*/
|
||||
void saveOrUpdateExecutionContext(StepExecution stepExecution);
|
||||
void persistExecutionContext(StepExecution stepExecution);
|
||||
|
||||
StepExecution getStepExecution(JobExecution jobExecution, Step step);
|
||||
|
||||
|
||||
@@ -250,10 +250,10 @@ public class SimpleJobRepository implements JobRepository {
|
||||
* saveOrUpdateExecutionContext
|
||||
* (org.springframework.batch.core.domain.StepExecution)
|
||||
*/
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
// Until there is an interface change (
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
jobExecutionDao.saveOrUpdateExecutionContext(stepExecution.getJobExecution());
|
||||
stepExecutionDao.persistExecutionContext(stepExecution);
|
||||
jobExecutionDao.persistExecutionContext(stepExecution.getJobExecution());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
|
||||
try {
|
||||
getJobRepository().update(stepExecution);
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
getJobRepository().persistExecutionContext(stepExecution);
|
||||
}
|
||||
catch (Exception e) {
|
||||
commitException = e;
|
||||
@@ -223,7 +223,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
|
||||
try {
|
||||
exitStatus = exitStatus.and(getCompositeListener().onErrorInStep(stepExecution, e));
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
getJobRepository().persistExecutionContext(stepExecution);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.error("Encountered an error on listener error callback.", ex);
|
||||
|
||||
@@ -222,7 +222,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
*/
|
||||
protected ExitStatus doExecute(final StepExecution stepExecution) throws Exception {
|
||||
stream.update(stepExecution.getExecutionContext());
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
getJobRepository().persistExecutionContext(stepExecution);
|
||||
itemHandler.mark();
|
||||
|
||||
final ExceptionHolder fatalException = new ExceptionHolder();
|
||||
@@ -286,7 +286,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
}
|
||||
|
||||
try {
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
getJobRepository().persistExecutionContext(stepExecution);
|
||||
}
|
||||
catch (Exception e) {
|
||||
fatalException.setException(e);
|
||||
|
||||
@@ -500,7 +500,7 @@ public class SimpleJobTests extends TestCase {
|
||||
stepExecution.getExecutionContext().putString("stepKey", "stepValue");
|
||||
stepExecution.getJobExecution().getExecutionContext().putString("jobKey", "jobValue");
|
||||
jobRepository.save(stepExecution);
|
||||
jobRepository.saveOrUpdateExecutionContext(stepExecution);
|
||||
jobRepository.persistExecutionContext(stepExecution);
|
||||
|
||||
if (exception instanceof RuntimeException) {
|
||||
stepExecution.setExitStatus(ExitStatus.FAILED);
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
|
||||
dao.saveJobExecution(exec1);
|
||||
dao.saveJobExecution(exec2);
|
||||
dao.saveOrUpdateExecutionContext(exec2);
|
||||
dao.persistExecutionContext(exec2);
|
||||
|
||||
JobExecution last = dao.getLastJobExecution(jobInstance);
|
||||
assertEquals(exec2, last);
|
||||
@@ -117,7 +117,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
}
|
||||
});
|
||||
execution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(execution);
|
||||
dao.persistExecutionContext(execution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(execution);
|
||||
assertEquals(ctx, retrieved);
|
||||
@@ -127,7 +127,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
dao.saveJobExecution(execution);
|
||||
ExecutionContext ctx = new ExecutionContext();
|
||||
execution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(execution);
|
||||
dao.persistExecutionContext(execution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(execution);
|
||||
assertEquals(ctx, retrieved);
|
||||
@@ -141,10 +141,10 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
|
||||
}
|
||||
});
|
||||
execution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(execution);
|
||||
dao.persistExecutionContext(execution);
|
||||
|
||||
ctx.putLong("longKey", 7);
|
||||
dao.saveOrUpdateExecutionContext(execution);
|
||||
dao.persistExecutionContext(execution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(execution);
|
||||
assertEquals(ctx, retrieved);
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
|
||||
|
||||
public void testUpdateStepWithExecutionContext() {
|
||||
stepExecution.setExecutionContext(executionContext);
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
stepExecutionDao.persistExecutionContext(stepExecution);
|
||||
ExecutionContext tempAttributes = stepExecutionDao.findExecutionContext(stepExecution);
|
||||
assertEquals(executionContext, tempAttributes);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
|
||||
execution.setExecutionContext(executionContext);
|
||||
execution.setExitStatus(ExitStatus.FAILED.addExitDescription("java.lang.Exception"));
|
||||
stepExecutionDao.saveStepExecution(execution);
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(execution);
|
||||
stepExecutionDao.persistExecutionContext(execution);
|
||||
StepExecution retrievedExecution = stepExecutionDao.getStepExecution(jobExecution, step2);
|
||||
assertNotNull(retrievedExecution);
|
||||
assertEquals(execution, retrievedExecution);
|
||||
@@ -202,14 +202,14 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
|
||||
public void testSaveExecutionContext(){
|
||||
|
||||
stepExecution.setExecutionContext(executionContext);
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
stepExecutionDao.persistExecutionContext(stepExecution);
|
||||
ExecutionContext attributes = stepExecutionDao.findExecutionContext(stepExecution);
|
||||
assertEquals(executionContext, attributes);
|
||||
executionContext.putString("newString", "newString");
|
||||
executionContext.putLong("newLong", 1);
|
||||
executionContext.putDouble("newDouble", 2.5);
|
||||
executionContext.put("newSerializable", "serializableValue");
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
stepExecutionDao.persistExecutionContext(stepExecution);
|
||||
attributes = stepExecutionDao.findExecutionContext(stepExecution);
|
||||
assertEquals(executionContext, attributes);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
|
||||
}
|
||||
});
|
||||
stepExecution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(stepExecution);
|
||||
dao.persistExecutionContext(stepExecution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(stepExecution);
|
||||
assertEquals(ctx, retrieved);
|
||||
@@ -166,7 +166,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
|
||||
dao.saveStepExecution(stepExecution);
|
||||
ExecutionContext ctx = new ExecutionContext();
|
||||
stepExecution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(stepExecution);
|
||||
dao.persistExecutionContext(stepExecution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(stepExecution);
|
||||
assertEquals(ctx, retrieved);
|
||||
@@ -180,10 +180,10 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
|
||||
}
|
||||
});
|
||||
stepExecution.setExecutionContext(ctx);
|
||||
dao.saveOrUpdateExecutionContext(stepExecution);
|
||||
dao.persistExecutionContext(stepExecution);
|
||||
|
||||
ctx.putLong("longKey", 7);
|
||||
dao.saveOrUpdateExecutionContext(stepExecution);
|
||||
dao.persistExecutionContext(stepExecution);
|
||||
|
||||
ExecutionContext retrieved = dao.findExecutionContext(stepExecution);
|
||||
assertEquals(ctx, retrieved);
|
||||
@@ -225,7 +225,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
|
||||
ExecutionContext ec = new ExecutionContext();
|
||||
ec.put("intValue", new Integer(343232));
|
||||
stepExecution.setExecutionContext(ec);
|
||||
dao.saveOrUpdateExecutionContext(stepExecution);
|
||||
dao.persistExecutionContext(stepExecution);
|
||||
ExecutionContext restoredEc = dao.findExecutionContext(stepExecution);
|
||||
assertEquals(ec, restoredEc);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MockStepDao implements StepExecutionDao {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
public StepExecution getStepExecution(JobExecution jobExecution, Step step) {
|
||||
|
||||
@@ -154,7 +154,7 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
|
||||
stepExec.setExecutionContext(ctx);
|
||||
|
||||
jobRepository.save(stepExec);
|
||||
jobRepository.saveOrUpdateExecutionContext(stepExec);
|
||||
jobRepository.persistExecutionContext(stepExec);
|
||||
|
||||
StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step);
|
||||
assertEquals(stepExec, retrievedStepExec);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class AbstractStepTests extends TestCase {
|
||||
|
||||
ExecutionContext saved = new ExecutionContext();
|
||||
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
saved = stepExecution.getExecutionContext();
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class AbstractStepTests extends TestCase {
|
||||
}
|
||||
};
|
||||
repository = new JobRepositoryStub() {
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
throw new RuntimeException("Bad context!");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ public class JobRepositorySupport implements JobRepository {
|
||||
public void update(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
final JobExecution jobExecution = new JobExecution(jobInstance);
|
||||
final StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution);
|
||||
itemOrientedStep.setJobRepository(new JobRepositorySupport() {
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
list.add(stepExecution);
|
||||
}
|
||||
});
|
||||
@@ -284,7 +284,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
private int counter = 0;
|
||||
|
||||
// initial save before item processing succeeds, later calls fail
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
if (counter > 0)
|
||||
throw new RuntimeException("foo");
|
||||
counter++;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TaskletStepTests extends TestCase {
|
||||
|
||||
public void testSuccessfulExecutionWithExecutionContext() throws Exception {
|
||||
TaskletStep step = new TaskletStep(new StubTasklet(false, false), new JobRepositorySupport() {
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
list.add(stepExecution);
|
||||
}
|
||||
});
|
||||
@@ -82,7 +82,7 @@ public class TaskletStepTests extends TestCase {
|
||||
|
||||
public void testSuccessfulExecutionWithFailureOnSaveOfExecutionContext() throws Exception {
|
||||
TaskletStep step = new TaskletStep(new StubTasklet(false, false, true), new JobRepositorySupport() {
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
throw new RuntimeException("foo");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ public class JobRepositorySupport implements JobRepository {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.repository.JobRepository#saveOrUpdateExecutionContext(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
public void persistExecutionContext(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
public void save(StepExecution stepExecution) {
|
||||
|
||||
Reference in New Issue
Block a user