org.springframework.batch.core.launch.support.SimpleJobLauncher Java Examples
The following examples show how to use
org.springframework.batch.core.launch.support.SimpleJobLauncher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobDependencies.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@Bean public SimpleJobServiceFactoryBean simpleJobServiceFactoryBean(DataSource dataSource, JobRepositoryFactoryBean repositoryFactoryBean, JobExplorer jobExplorer, PlatformTransactionManager dataSourceTransactionManager) { SimpleJobServiceFactoryBean factoryBean = new SimpleJobServiceFactoryBean(); factoryBean.setDataSource(dataSource); try { factoryBean.setJobRepository(repositoryFactoryBean.getObject()); factoryBean.setJobLauncher(new SimpleJobLauncher()); factoryBean.setJobExplorer(jobExplorer); factoryBean.setTransactionManager(dataSourceTransactionManager); } catch (Exception e) { throw new IllegalStateException(e); } return factoryBean; }
Example #2
Source File: DefaultSchedulerServiceTest.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
@Test public void refreshSchedulerForJobCronTest() { final String beanName = "schedulerBean"; final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration("some " + "Cron", null, null, JobSchedulerType.CRON); jobSchedulerConfiguration.setBeanName(beanName); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.ASYNCHRONOUS); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final Map<String, Object> jobParameters = new HashMap<>(); jobParameters.put("LONG", 10L); jobParameters.put("DOUBLE", 20.2); jobParameters.put("STRING", "test"); jobParameters.put("DATE", "2015/03/27 23:19:24:120"); jobParameters.put("DATE", "2015/03/27"); jobConfiguration.setJobParameters(jobParameters); final SchedulerConstructorWrapper schedulerConstructorWrapper = new SchedulerConstructorWrapper(); schedulerConstructorWrapper.setJob(DomainTestHelper.createJob("sampleJob")); schedulerConstructorWrapper.setJobConfiguration(jobConfiguration); schedulerConstructorWrapper.setJobIncrementer(JobIncrementer.NONE); schedulerConstructorWrapper.setJobLauncher(new SimpleJobLauncher()); schedulerConstructorWrapper.setJobParameters(new JobParametersBuilder().toJobParameters()); //scheduler = new PeriodScheduler(schedulerConstructorWrapper); when(this.applicationContext.containsBean(beanName)).thenReturn(Boolean.TRUE); when(this.applicationContext.getBean(beanName, Scheduler.class)).thenReturn(this.scheduler); when(this.scheduler.getSchedulerStatus()).thenReturn(SchedulerStatus.INITIALIZED); this.schedulerService.refreshSchedulerForJob(jobConfiguration); verify(this.scheduler, times(1)).terminate(); }
Example #3
Source File: JpaBatchConfigurer.java From spring4-sandbox with Apache License 2.0 | 5 votes |
private JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor( new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #4
Source File: SpringConfig.java From tutorials with MIT License | 5 votes |
public JobLauncher getJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); // SimpleJobLauncher's methods Throws Generic Exception, // it would have been better to have a specific one jobLauncher.setJobRepository(getJobRepository()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #5
Source File: SpringbatchPartitionConfig.java From tutorials with MIT License | 5 votes |
public JobLauncher getJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); // SimpleJobLauncher's methods Throws Generic Exception, // it would have been better to have a specific one jobLauncher.setJobRepository(getJobRepository()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #6
Source File: TaskExecutorBatchConfiguration.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
private JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher(); simpleJobLauncher.setJobRepository(jobRepository); simpleJobLauncher.setTaskExecutor(taskExecutor); simpleJobLauncher.afterPropertiesSet(); return simpleJobLauncher; }
Example #7
Source File: ThreadedPerformanceTest.java From batchers with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { mockServer = MockRestServiceServer.createServer(restTemplate); SmtpServerStub.start(); jobParams = new JobParametersBuilder() .addLong("month", 2L) .addLong("year", 2014L).toJobParameters(); employeeGeneratorService.resetEmployees(NUMBER_OF_EMPLOYEES); runningTimeService.setMaximumTime(51); runningTimeService.setMinimumTime(50); jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); }
Example #8
Source File: TaskJobLauncherCommandLineRunnerTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
protected JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(getJobRepository()); jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #9
Source File: TaskJobLauncherCommandLineRunnerCoreTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
@Override public JobLauncher getJobLauncher() { SimpleJobLauncher launcher = new SimpleJobLauncher(); launcher.setJobRepository(this.jobRepository); launcher.setTaskExecutor(new SyncTaskExecutor()); return launcher; }
Example #10
Source File: SpringBatchLightminBatchConfiguration.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
@Bean(name = "defaultAsyncJobLauncher") public JobLauncher defaultAsyncJobLauncher(final JobRepository jobRepository) { final SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); return jobLauncher; }
Example #11
Source File: SpringBatchConfiguration.java From spring-cloud with Apache License 2.0 | 5 votes |
private JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #12
Source File: DefaultSchedulerServiceTest.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
@Test public void refreshSchedulerForJobTest() { final String beanName = "schedulerBean"; final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName(beanName); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.ASYNCHRONOUS); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final Map<String, Object> jobParameters = new HashMap<>(); jobParameters.put("LONG", 10L); jobParameters.put("DOUBLE", 20.2); jobParameters.put("STRING", "test"); jobParameters.put("DATE", "2015/03/27 23:19:24:120"); jobParameters.put("DATE", "2015/03/27"); jobConfiguration.setJobParameters(jobParameters); final SchedulerConstructorWrapper schedulerConstructorWrapper = new SchedulerConstructorWrapper(); schedulerConstructorWrapper.setJob(DomainTestHelper.createJob("sampleJob")); schedulerConstructorWrapper.setJobConfiguration(jobConfiguration); schedulerConstructorWrapper.setJobIncrementer(JobIncrementer.NONE); schedulerConstructorWrapper.setJobLauncher(new SimpleJobLauncher()); schedulerConstructorWrapper.setJobParameters(new JobParametersBuilder().toJobParameters()); //scheduler = new PeriodScheduler(schedulerConstructorWrapper); when(this.applicationContext.containsBean(beanName)).thenReturn(Boolean.TRUE); when(this.applicationContext.getBean(beanName, Scheduler.class)).thenReturn(this.scheduler); when(this.scheduler.getSchedulerStatus()).thenReturn(SchedulerStatus.INITIALIZED); this.schedulerService.refreshSchedulerForJob(jobConfiguration); verify(this.scheduler, times(1)).terminate(); }
Example #13
Source File: DefaultListenerServiceTest.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
@Before public void init() { MockitoAnnotations.initMocks(this); this.listenerService = new DefaultListenerService(this.beanRegistrar, this.jobRegistry, this.jobRepository); ReflectionTestUtils.setField(this.listenerService, "applicationContext", this.applicationContext); this.job = DomainTestHelper.createJob("testJob"); this.jobLauncher = new SimpleJobLauncher(); }
Example #14
Source File: TaskConfiguration.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@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.setJobLauncher(new SimpleJobLauncher()); factoryBean.setDataSource(dataSource); factoryBean.setJobExplorer(jobExplorer); factoryBean.setTransactionManager(dataSourceTransactionManager); return factoryBean; }
Example #15
Source File: JobTaskScheduled.java From j360-dubbo-app-all with Apache License 2.0 | 5 votes |
public void run() { long timeCount = count.incrementAndGet(); log.info("任务执行开始 [count={}, date={}]",timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date())); SimpleJobLauncher launcher = new SimpleJobLauncher(); launcher.setJobRepository(jobRepository); launcher.setTaskExecutor(new SimpleAsyncTaskExecutor()); try { launcher.run(batchJob, new JobParameters()); } catch (Exception e) { log.error("任务执行失败 [count={}, date={}]", timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date()),e); } finally { log.info("任务执行结束 [count={}, date={}]",timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date())); } }
Example #16
Source File: ApplicationConfiguration.java From blackduck-alert with Apache License 2.0 | 5 votes |
@Bean public SimpleJobLauncher jobLauncher() { SimpleJobLauncher launcher = new SimpleJobLauncher(); try { launcher.setJobRepository(jobRepository()); } catch (Exception ex) { logger.error("Creating job launcher bean", ex); } return launcher; }
Example #17
Source File: DefaultSpringBatchLightminBatchConfigurer.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
protected JobLauncher createJobLauncher() throws Exception { final SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(this.jobRepository); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #18
Source File: BatchConfiguration.java From patient-batch-loader with GNU General Public License v3.0 | 4 votes |
protected JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #19
Source File: AdHocBatchConfig.java From spring-batch-rest with Apache License 2.0 | 4 votes |
public JobLauncher getJobLauncher() { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor(executorService)); return jobLauncher; }