Example usage for org.springframework.batch.core.configuration.support AutomaticJobRegistrar addApplicationContextFactory

List of usage examples for org.springframework.batch.core.configuration.support AutomaticJobRegistrar addApplicationContextFactory

Introduction

In this page you can find the example usage for org.springframework.batch.core.configuration.support AutomaticJobRegistrar addApplicationContextFactory.

Prototype

public void addApplicationContextFactory(ApplicationContextFactory applicationContextFactory) 

Source Link

Document

Add some factories to the set that will be used to load contexts and jobs.

Usage

From source file:de.codecentric.batch.configuration.AutomaticJobRegistrarConfiguration.java

protected void registerJobsFromJavaConfig(AutomaticJobRegistrar automaticJobRegistrar)
        throws ClassNotFoundException, IOException {
    List<Class<?>> classes = findMyTypes(
            env.getProperty("batch.config.package.javaconfig", "spring.batch.jobs"));
    for (Class<?> clazz : classes) {
        LOGGER.info("Register jobs from {}", clazz);
        automaticJobRegistrar.addApplicationContextFactory(new GenericApplicationContextFactory(clazz));
    }//  w w  w.jav a 2 s  .  c o m
}

From source file:de.codecentric.batch.configuration.AutomaticJobRegistrarConfiguration.java

protected void registerJobsFromXml(AutomaticJobRegistrar automaticJobRegistrar) throws IOException {
    // Add all XML-Configurations to the AutomaticJobRegistrar
    ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    Resource[] xmlConfigurations = resourcePatternResolver.getResources(
            "classpath*:" + env.getProperty("batch.config.path.xml", "/META-INF/spring/batch/jobs") + "/*.xml");
    for (Resource resource : xmlConfigurations) {
        LOGGER.info("Register jobs from {}", resource);
        automaticJobRegistrar.addApplicationContextFactory(new GenericApplicationContextFactory(resource));
    }/*from  w  w w.ja v  a2  s. c o  m*/
}