Add new constructor to ClassPathXmlApplicationContextJobFactory

This commit is contained in:
dsyer
2008-07-14 15:18:07 +00:00
parent 3e71bde064
commit 11e706dcb3
2 changed files with 22 additions and 3 deletions

View File

@@ -21,7 +21,9 @@ import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.configuration.JobFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -32,13 +34,30 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @author Dave Syer
*
*/
public class ClassPathXmlApplicationContextJobFactory implements JobFactory {
public class ClassPathXmlApplicationContextJobFactory implements JobFactory, ApplicationContextAware {
final private String beanName;
final private String path;
final private ApplicationContext parent;
private ApplicationContext parent;
/**
* Setter for the parent application context.
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
parent = applicationContext;
}
/**
* @param beanName the id of the {@link Job} in the application context to
* be created
* @param path the path to the XML configuration containing the {@link Job}
*/
public ClassPathXmlApplicationContextJobFactory(String beanName, String path) {
this(beanName, path, null);
}
/**
* @param beanName the id of the {@link Job} in the application context to

View File

@@ -25,7 +25,7 @@ import org.springframework.util.ClassUtils;
*/
public class ClassPathXmlApplicationContextJobFactoryTests extends TestCase {
private ClassPathXmlApplicationContextJobFactory factory = new ClassPathXmlApplicationContextJobFactory("test-job", ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml"), null);
private ClassPathXmlApplicationContextJobFactory factory = new ClassPathXmlApplicationContextJobFactory("test-job", ClassUtils.addResourcePathToPackagePath(getClass(), "trivial-context.xml"));
/**
* Test method for {@link org.springframework.batch.core.configuration.support.ClassPathXmlApplicationContextJobFactory#createJob()}.