protected void registerJobsFromJavaConfig(AutomaticJobRegistrar automaticJobRegistrar) throws ClassNotFoundException, IOException { List<Class<?>> classes = findMyTypes(getDefaultPackageToScanForBatchJobs()); for (Class<?> clazz : classes) { LOGGER.info("Register jobs from {}", clazz); automaticJobRegistrar.addApplicationContextFactory(new GenericApplicationContextFactory(clazz)); } }
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)); } }
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)); } }
@Bean public ApplicationContextFactory job1() { return new GenericApplicationContextFactory(JobConfig.class); }
@Bean public ApplicationContextFactory testJobFactory() { return new GenericApplicationContextFactory(TestJobConfig.class); }