OPEN - issue BATCH-378: RepeatListener is confusing and too generic to use for 'intercepting' a step

http://jira.springframework.org/browse/BATCH-378

Change contract of StepListener - JobParameters are more useful at that stage than ExecutionContext.
This commit is contained in:
dsyer
2008-02-28 15:44:51 +00:00
parent e3f72a64f8
commit add7b2f806
9 changed files with 84 additions and 59 deletions

View File

@@ -180,7 +180,7 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware {
Exception fatalException = null;
try {
listener.open(stepExecution.getExecutionContext());
listener.open(stepExecution.getJobParameters());
exitStatus = tasklet.execute();
try {
@@ -204,14 +204,14 @@ public class TaskletStep implements Step, InitializingBean, BeanNameAware {
throw new BatchCriticalException(e);
}
finally {
stepExecution.setExitStatus(exitStatus);
stepExecution.setEndTime(new Date());
try {
listener.close();
exitStatus = exitStatus.and(listener.close());
}
catch (Exception e) {
logger.error("Encountered an error on listener close.");
}
stepExecution.setExitStatus(exitStatus);
stepExecution.setEndTime(new Date());
try {
jobRepository.saveOrUpdate(stepExecution);
}

View File

@@ -17,7 +17,6 @@ import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.scope.StepSynchronizationManager;
import org.springframework.batch.execution.step.support.JobRepositorySupport;
import org.springframework.batch.io.exception.BatchCriticalException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
public class TaskletStepTests extends TestCase {
@@ -106,7 +105,7 @@ public class TaskletStepTests extends TestCase {
public void testSuccessfulExecutionWithListener() throws Exception {
TaskletStep step = new TaskletStep(new StubTasklet(false, false), new JobRepositorySupport());
step.setListener(new StepListenerSupport() {
public void open(ExecutionContext context) {
public void open(JobParameters context) {
list.add("open");
}
public ExitStatus close() {