@Bean public JobRegistry jobRegistry() throws Exception { return new MapJobRegistry(); }
/** * Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some * sensible values as long as a unique DataSource is available. * * @throws Exception if there is a problem in the configurer */ protected void initialize() throws Exception { if (initialized) { return; } BatchConfigurer configurer = getConfigurer(context.getBeansOfType(BatchConfigurer.class).values()); jobRepository.set(configurer.getJobRepository()); jobLauncher.set(configurer.getJobLauncher()); transactionManager.set(configurer.getTransactionManager()); jobRegistry.set(new MapJobRegistry()); jobExplorer.set(configurer.getJobExplorer()); initialized = true; }
@Test public void testAfterInitializationWithCorrectType() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); assertEquals("[foo]", registry.getJobNames().toString()); }
@Test public void testUnregisterOnDestroy() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); processor.destroy(); assertEquals("[]", registry.getJobNames().toString()); }
@Test public void testAfterInitializationWithGroupName() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); processor.setGroupName("jobs"); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); assertEquals("[jobs.foo]", registry.getJobNames().toString()); }
@Test public void testAfterInitializationWithDuplicate() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); processor.postProcessAfterInitialization(job, "bar"); try { processor.postProcessAfterInitialization(job, "spam"); fail("Expected FatalBeanException"); } catch (FatalBeanException e) { // Expected assertTrue(e.getCause() instanceof DuplicateJobException); } }
@Bean public JobRegistry jobRegistry() throws Exception { return new MapJobRegistry(); }
@Bean public JobRegistry jobRegistry() throws Exception { return new MapJobRegistry(); }
@Bean public JobRegistry jobRegistry() throws Exception { return new MapJobRegistry(); }
@Bean public JobRegistry jobRegistry() throws Exception { return new MapJobRegistry(); }
@Bean @ConditionalOnMissingBean(MapJobRegistry.class) public MapJobRegistry batchJobRegistry() { return new MapJobRegistry(); }
@Bean @ConditionalOnMissingBean(value = {JobRegistry.class}) public JobRegistry jobRegistry() { return new MapJobRegistry(); }
/** * Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some * sensible values as long as a unique DataSource is available. * * @throws Exception if there is a problem in the configurer */ protected void initialize() throws Exception { if (initialized) { return; } BatchConfigurer configurer = getConfigurer(context.getBeansOfType(BatchConfigurer.class).values()); jobRepository.set(configurer.getJobRepository()); jobLauncher.set(configurer.getJobLauncher()); transactionManager.set(configurer.getTransactionManager()); jobRegistry.set(new MapJobRegistry()); initialized = true; }
/** * Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some * sensible values as long as a unique DataSource is available. * * @throws Exception if there is a problem in the configurer */ protected void initialize() throws Exception { if (initialized) { return; } BatchConfigurer configurer = getConfigurer(context.getBeansOfType(BatchConfigurer.class).values()); jobRepository.set(configurer.getJobRepository()); jobLauncher.set(configurer.getJobLauncher()); transactionManager.set(configurer.getTransactionManager()); jobRegistry.set(new MapJobRegistry()); jobExplorer.set(configurer.getJobExplorer()); initialized = true; }
/** * Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some * sensible values as long as a unique DataSource is available. * * @throws Exception if there is a problem in the configurer */ protected void initialize() throws Exception { if (initialized) { return; } BatchConfigurer configurer = getConfigurer(context.getBeansOfType(BatchConfigurer.class).values()); jobRepository.set(configurer.getJobRepository()); jobLauncher.set(configurer.getJobLauncher()); transactionManager.set(configurer.getTransactionManager()); jobRegistry.set(new MapJobRegistry()); jobExplorer.set(configurer.getJobExplorer()); initialized = true; }
/** * Sets up the basic components by extracting them from the * {@link BatchConfigurer configurer}, defaulting to some sensible values as * long as a unique DataSource is available. * * @throws Exception * if there is a problem in the configurer */ protected void initialize() throws Exception { if (initialized) { return; } BatchConfigurer configurer = getConfigurer(context.getBeansOfType(BatchConfigurer.class).values()); jobRepository.set(configurer.getJobRepository()); jobLauncher.set(configurer.getJobLauncher()); transactionManager.set(configurer.getTransactionManager()); jobRegistry.set(new MapJobRegistry()); jobExplorer.set(configurer.getJobExplorer()); initialized = true; }
@Bean public SimpleJobServiceFactoryBean simpleJobServiceFactoryBean(DataSource dataSource, JobRepositoryFactoryBean repositoryFactoryBean) throws Exception { SimpleJobServiceFactoryBean factoryBean = new SimpleJobServiceFactoryBean(); factoryBean.setDataSource(dataSource); factoryBean.setJobRepository(repositoryFactoryBean.getObject()); factoryBean.setJobLocator(new MapJobRegistry()); factoryBean.setJobLauncher(new SimpleJobLauncher()); factoryBean.setDataSource(dataSource); return factoryBean; }
@Bean public SimpleJobServiceFactoryBean simpleJobServiceFactoryBean(DataSource dataSource, JobRepositoryFactoryBean repositoryFactoryBean, JobExplorer jobExplorer, PlatformTransactionManager dataSourceTransactionManager) throws Exception { SimpleJobServiceFactoryBean factoryBean = new SimpleJobServiceFactoryBean(); factoryBean.setDataSource(dataSource); factoryBean.setJobRepository(repositoryFactoryBean.getObject()); factoryBean.setJobLocator(new MapJobRegistry()); factoryBean.setJobLauncher(new SimpleJobLauncher()); factoryBean.setDataSource(dataSource); factoryBean.setJobExplorer(jobExplorer); factoryBean.setTransactionManager(dataSourceTransactionManager); return factoryBean; }