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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user