RESOLVED - issue BATCH-506: JobListener is not a BatchListener

Changed BatchListener to StepListener and renamed existing Job/StepListener as *ExecutionListener.
This commit is contained in:
dsyer
2008-03-25 12:29:55 +00:00
parent 02c59ba0bd
commit 1ac5a5296a
32 changed files with 328 additions and 326 deletions

View File

@@ -32,7 +32,7 @@ import org.springframework.batch.core.StartLimitExceededException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.listener.JobListenerSupport;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.dao.JobExecutionDao;
import org.springframework.batch.core.repository.dao.JobInstanceDao;
@@ -173,7 +173,7 @@ public class SimpleJobTests extends TestCase {
}
public void testRunNormallyWithListener() throws Exception {
job.setJobListeners(new JobListenerSupport[] { new JobListenerSupport() {
job.setJobListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
public void beforeJob(JobExecution jobExecution) {
list.add("before");
}
@@ -251,7 +251,7 @@ public class SimpleJobTests extends TestCase {
}
public void testFailedWithListener() throws Exception {
job.setJobListeners(new JobListenerSupport[] { new JobListenerSupport() {
job.setJobListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
public void onError(JobExecution jobExecution, Throwable t) {
list.add(t);
}

View File

@@ -22,31 +22,31 @@ import junit.framework.TestCase;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobListener;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.listener.CompositeJobListener;
import org.springframework.batch.core.listener.JobListenerSupport;
import org.springframework.batch.core.listener.CompositeExecutionJobListener;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
/**
* @author Dave Syer
*
*/
public class CompositeJobListenerTests extends TestCase {
public class CompositeJobExecutionListenerTests extends TestCase {
private CompositeJobListener listener = new CompositeJobListener();
private CompositeExecutionJobListener listener = new CompositeExecutionJobListener();
private List list = new ArrayList();
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeJobListener#setListeners(org.springframework.batch.core.JobListener[])}.
* {@link org.springframework.batch.core.listener.CompositeExecutionJobListener#setListeners(org.springframework.batch.core.JobExecutionListener[])}.
*/
public void testSetListeners() {
listener.setListeners(new JobListener[] { new JobListenerSupport() {
listener.setListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() {
public void afterJob(JobExecution jobExecution) {
list.add("fail");
}
}, new JobListenerSupport() {
}, new JobExecutionListenerSupport() {
public void afterJob(JobExecution jobExecution) {
list.add("continue");
}
@@ -57,10 +57,10 @@ public class CompositeJobListenerTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeJobListener#registerListener(org.springframework.batch.core.JobListener)}.
* {@link org.springframework.batch.core.listener.CompositeExecutionJobListener#registerListener(org.springframework.batch.core.JobExecutionListener)}.
*/
public void testSetListener() {
listener.register(new JobListenerSupport() {
listener.register(new JobExecutionListenerSupport() {
public void afterJob(JobExecution jobExecution) {
list.add("fail");
}
@@ -71,10 +71,10 @@ public class CompositeJobListenerTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeJobListener#beforeJob(JobExecution)}.
* {@link org.springframework.batch.core.listener.CompositeExecutionJobListener#beforeJob(JobExecution)}.
*/
public void testOpen() {
listener.register(new JobListenerSupport() {
listener.register(new JobExecutionListenerSupport() {
public void beforeJob(JobExecution stepExecution) {
list.add("foo");
}

View File

@@ -21,9 +21,9 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.listener.CompositeStepListener;
import org.springframework.batch.core.listener.StepListenerSupport;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.step.StepSupport;
import org.springframework.batch.repeat.ExitStatus;
@@ -31,23 +31,23 @@ import org.springframework.batch.repeat.ExitStatus;
* @author Dave Syer
*
*/
public class CompositeStepListenerTests extends TestCase {
public class CompositeStepExecutionListenerTests extends TestCase {
private CompositeStepListener listener = new CompositeStepListener();
private CompositeStepExecutionListener listener = new CompositeStepExecutionListener();
private List list = new ArrayList();
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeStepListener#setListeners(org.springframework.batch.core.StepListener[])}.
* {@link org.springframework.batch.core.listener.CompositeStepExecutionListener#setListeners(org.springframework.batch.core.StepExecutionListener[])}.
*/
public void testSetListeners() {
listener.setListeners(new StepListener[] { new StepListenerSupport() {
listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
public ExitStatus afterStep(StepExecution stepExecution) {
list.add("fail");
return ExitStatus.FAILED;
}
}, new StepListenerSupport() {
}, new StepExecutionListenerSupport() {
public ExitStatus afterStep(StepExecution stepExecution) {
list.add("continue");
return ExitStatus.CONTINUABLE;
@@ -59,10 +59,10 @@ public class CompositeStepListenerTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeStepListener#registerListener(org.springframework.batch.core.StepListener)}.
* {@link org.springframework.batch.core.listener.CompositeStepExecutionListener#registerListener(org.springframework.batch.core.StepExecutionListener)}.
*/
public void testSetListener() {
listener.register(new StepListenerSupport() {
listener.register(new StepExecutionListenerSupport() {
public ExitStatus afterStep(StepExecution stepExecution) {
list.add("fail");
return ExitStatus.FAILED;
@@ -74,10 +74,10 @@ public class CompositeStepListenerTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeStepListener#beforeStep(StepExecution)}.
* {@link org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(StepExecution)}.
*/
public void testOpen() {
listener.register(new StepListenerSupport() {
listener.register(new StepExecutionListenerSupport() {
public void beforeStep(StepExecution stepExecution) {
list.add("foo");
}
@@ -88,10 +88,10 @@ public class CompositeStepListenerTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.core.listener.CompositeStepListener#beforeStep(StepExecution)}.
* {@link org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(StepExecution)}.
*/
public void testOnError() {
listener.register(new StepListenerSupport() {
listener.register(new StepExecutionListenerSupport() {
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
list.add("foo");
return null;

View File

@@ -29,10 +29,10 @@ import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.listener.StepListenerSupport;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.repository.dao.MapJobExecutionDao;
import org.springframework.batch.core.repository.dao.MapJobInstanceDao;
import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
@@ -231,7 +231,7 @@ public class ItemOrientedStepTests extends TestCase {
};
itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter));
itemOrientedStep.registerStepListener(new StepListenerSupport() {
itemOrientedStep.registerStepListener(new StepExecutionListenerSupport() {
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
return ExitStatus.FAILED.addExitDescription("FOO");
}
@@ -394,7 +394,7 @@ public class ItemOrientedStepTests extends TestCase {
}
public void testDirectlyInjectedListener() throws Exception {
itemOrientedStep.registerStepListener(new StepListenerSupport() {
itemOrientedStep.registerStepListener(new StepExecutionListenerSupport() {
public void beforeStep(StepExecution stepExecution) {
list.add("foo");
}
@@ -431,7 +431,7 @@ public class ItemOrientedStepTests extends TestCase {
final ExitStatus customStatus = new ExitStatus(false, "custom code");
itemOrientedStep.setStepListeners(new StepListener[] { new StepListenerSupport() {
itemOrientedStep.setStepListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
public ExitStatus afterStep(StepExecution stepExecution) {
list.add("afterStepCalled");
return customStatus;
@@ -452,7 +452,7 @@ public class ItemOrientedStepTests extends TestCase {
}
public void testDirectlyInjectedListenerOnError() throws Exception {
itemOrientedStep.registerStepListener(new StepListenerSupport() {
itemOrientedStep.registerStepListener(new StepExecutionListenerSupport() {
public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) {
list.add(e);
return null;
@@ -725,7 +725,7 @@ public class ItemOrientedStepTests extends TestCase {
return str.indexOf(searchStr) != -1;
}
private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, StepListener {
private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, StepExecutionListener {
private boolean getExecutionAttributesCalled = false;

View File

@@ -23,7 +23,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.BatchListener;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.JobExecution;
@@ -141,7 +141,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
throw new RuntimeException("Error!");
}
});
factory.setListeners(new BatchListener[] { new ItemListenerSupport() {
factory.setListeners(new StepListener[] { new ItemListenerSupport() {
public void onReadError(Exception ex) {
recovered.add(ex);
}
@@ -207,7 +207,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
}
}
CountingChunkListener chunkListener = new CountingChunkListener();
factory.setListeners(new BatchListener[]{ chunkListener });
factory.setListeners(new StepListener[]{ chunkListener });
factory.setCommitInterval(commitInterval);
ItemOrientedStep step = (ItemOrientedStep) factory.getObject();

View File

@@ -12,9 +12,9 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.listener.StepListenerSupport;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.step.JobRepositorySupport;
import org.springframework.batch.core.step.StepSupport;
import org.springframework.batch.core.step.tasklet.Tasklet;
@@ -109,7 +109,7 @@ public class TaskletStepTests extends TestCase {
public void testSuccessfulExecutionWithListener() throws Exception {
TaskletStep step = new TaskletStep(new StubTasklet(false, false), new JobRepositorySupport());
step.setStepListeners(new StepListener[] { new StepListenerSupport() {
step.setStepListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
public void beforeStep(StepExecution context) {
list.add("open");
}
@@ -169,7 +169,7 @@ public class TaskletStepTests extends TestCase {
}
}
private class StubTasklet extends StepListenerSupport implements Tasklet {
private class StubTasklet extends StepExecutionListenerSupport implements Tasklet {
private final boolean exitFailure;