Java 类org.springframework.batch.core.configuration.support.AutomaticJobRegistrar 实例源码
项目:spring-batch-tools
文件:ServiceJobFactoryRegistrarTest.java
@Test
public void test() {
final ApplicationContextFactory factory = mock(ApplicationContextFactory.class);
final Iterable<ApplicationContextFactory> factories = Arrays.asList(factory);
final AutomaticJobRegistrar jobRegistrar = mock(AutomaticJobRegistrar.class);
final ServiceJobFactoryRegistrar registrar = new ServiceJobFactoryRegistrar(jobRegistrar) {
@Override
protected Iterable<ApplicationContextFactory> lookupServices() {
return factories;
}
};
registrar.registerJobFactories();
verify(jobRegistrar).addApplicationContextFactory(factory);
}
项目:spring-batch-support
文件:AutomaticJobRegistrarConfigurationSupport.java
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));
}
}
项目:spring-batch-support
文件:SpringBatchSupportStarterAutoConfiguration.java
@Bean
public AutomaticJobRegistrar jobRegistrar(JobRegistry jobRegistry) throws Exception {
AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
registrar.setJobLoader(new DefaultJobLoader(jobRegistry));
for (ApplicationContextFactory factory : applicationContext.getBeansOfType(ApplicationContextFactory.class).values()) {
registrar.addApplicationContextFactory(factory);
}
return registrar;
}
项目:spring-boot-starter-batch-web
文件: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));
}
}
项目:spring-boot-starter-batch-web
文件: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));
}
}
项目:spring-batch-support
文件:AutomaticJobRegistrarConfigurationSupport.java
@Override
protected void addApplicationContextFactories(AutomaticJobRegistrar automaticJobRegistrar) throws Exception {
registerJobsFromJavaConfig(automaticJobRegistrar);
}
项目:spring-batch-tools
文件:ServiceJobFactoryRegistrar.java
public ServiceJobFactoryRegistrar(final AutomaticJobRegistrar jobRegistrar) {
this.jobRegistrar = jobRegistrar;
}
项目:spring-boot-starter-batch-web
文件:AutomaticJobRegistrarConfiguration.java
/**
* @see de.codecentric.batch.configuration.AutomaticJobRegistrarConfigurationSupport#addApplicationContextFactories(org.springframework.batch.core.configuration.support.AutomaticJobRegistrar)
*/
@Override
protected void addApplicationContextFactories(AutomaticJobRegistrar automaticJobRegistrar) throws Exception {
registerJobsFromXml(automaticJobRegistrar);
registerJobsFromJavaConfig(automaticJobRegistrar);
}
项目:spring-batch-support
文件:SpringBatchSupportAutoConfiguration.java
/**
* Add ApplicationContextFactories to the given job registrar.
*
* @param automaticJobRegistrar Bean
* @throws Exception Some error.
*/
protected abstract void addApplicationContextFactories(AutomaticJobRegistrar automaticJobRegistrar)
throws Exception;
项目:spring-boot-starter-batch-web
文件:AutomaticJobRegistrarConfigurationSupport.java
/**
* Add ApplicationContextFactories to the given job registrar.
*
* @param automaticJobRegistrar
* Bean
* @throws Exception
* Some error.
*/
protected abstract void addApplicationContextFactories(AutomaticJobRegistrar automaticJobRegistrar)
throws Exception;