IN PROGRESS - issue BATCH-419: JobListener and StepListener should pass in JobExecution/StepExecution in each method
http://jira.springframework.org/browse/BATCH-419 added StepExecution argument to StepListener#afterStep
This commit is contained in:
@@ -55,11 +55,11 @@ public class CompositeStepListener implements StepListener {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.StepListener#close()
|
||||
*/
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
ExitStatus status = null;
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
StepListener listener = (StepListener) iterator.next();
|
||||
ExitStatus close = listener.afterStep();
|
||||
ExitStatus close = listener.afterStep(stepExecution);
|
||||
status = status!=null ? status.and(close): close;
|
||||
}
|
||||
return status;
|
||||
|
||||
@@ -416,7 +416,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
finally {
|
||||
|
||||
try {
|
||||
status = status.and(listener.afterStep());
|
||||
status = status.and(listener.afterStep(stepExecution));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
logger.error("Unexpected error in listener after step.", e);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class TaskletStep extends AbstractStep implements Step, InitializingBean,
|
||||
listener.beforeStep(stepExecution);
|
||||
exitStatus = tasklet.execute();
|
||||
try {
|
||||
exitStatus = exitStatus.and(listener.afterStep());
|
||||
exitStatus = exitStatus.and(listener.afterStep(stepExecution));
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Encountered an error on listener close.", e);
|
||||
|
||||
@@ -87,8 +87,8 @@ public class ListenerMulticaster implements StepListener, ChunkListener, ItemRea
|
||||
* @return
|
||||
* @see org.springframework.batch.execution.listener.CompositeStepListener#afterStep()
|
||||
*/
|
||||
public ExitStatus afterStep() {
|
||||
return stepListener.afterStep();
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return stepListener.afterStep(stepExecution);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,17 +42,17 @@ public class CompositeStepListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(new StepListener[] { new StepListenerSupport() {
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}, new StepListenerSupport() {
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("continue");
|
||||
return ExitStatus.CONTINUABLE;
|
||||
}
|
||||
} });
|
||||
assertFalse(listener.afterStep().isContinuable());
|
||||
assertFalse(listener.afterStep(null).isContinuable());
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ public class CompositeStepListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new StepListenerSupport() {
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
});
|
||||
assertFalse(listener.afterStep().isContinuable());
|
||||
assertFalse(listener.afterStep(null).isContinuable());
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
list.add("foo");
|
||||
}
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("bar");
|
||||
return null;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
final ExitStatus customStatus = new ExitStatus(false, "custom code");
|
||||
|
||||
itemOrientedStep.setStepListeners(new StepListener[] {new StepListenerSupport() {
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("afterStepCalled");
|
||||
return customStatus;
|
||||
}
|
||||
@@ -699,7 +699,7 @@ public class ItemOrientedStepTests extends TestCase {
|
||||
public void reset() throws ResetFailedException {
|
||||
}
|
||||
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TaskletStepTests extends TestCase {
|
||||
list.add("open");
|
||||
}
|
||||
|
||||
public ExitStatus afterStep() {
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("close");
|
||||
return ExitStatus.CONTINUABLE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user