RESOLVED - BATCH-628: SimpleJob doesn't verify that the JobRepository has been set

added the check to AbstractJob, as that's where jobRepository property is set
This commit is contained in:
robokaso
2008-05-16 09:12:37 +00:00
parent 1d386ee0d2
commit cc01a835c3
3 changed files with 40 additions and 24 deletions

View File

@@ -25,6 +25,8 @@ import org.springframework.batch.core.Step;
import org.springframework.batch.core.listener.CompositeExecutionJobListener;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
@@ -36,7 +38,7 @@ import org.springframework.util.ClassUtils;
* @author Lucas Ward
* @author Dave Syer
*/
public abstract class AbstractJob implements BeanNameAware, Job {
public abstract class AbstractJob implements Job, BeanNameAware, InitializingBean {
private List steps = new ArrayList();
@@ -161,6 +163,10 @@ public abstract class AbstractJob implements BeanNameAware, Job {
public void setJobRepository(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}
public void afterPropertiesSet() throws Exception {
Assert.notNull(getJobRepository(), "JobRepository must be set");
}
protected JobRepository getJobRepository() {
return jobRepository;