Java Code Examples for org.springframework.batch.core.launch.support.SimpleJobLauncher#setJobRepository()

The following examples show how to use org.springframework.batch.core.launch.support.SimpleJobLauncher#setJobRepository() . 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: SpringBatchConfiguration.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    jobLauncher.afterPropertiesSet();
    return jobLauncher;
}
 
Example 2
Source File: ApplicationConfiguration.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: JobTaskScheduled.java    From j360-dubbo-app-all with Apache License 2.0 5 votes vote down vote up
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 4
Source File: SpringBatchLightminBatchConfiguration.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Bean(name = "defaultAsyncJobLauncher")
public JobLauncher defaultAsyncJobLauncher(final JobRepository jobRepository) {
    final SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return jobLauncher;
}
 
Example 5
Source File: TaskJobLauncherCommandLineRunnerCoreTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public JobLauncher getJobLauncher() {
	SimpleJobLauncher launcher = new SimpleJobLauncher();
	launcher.setJobRepository(this.jobRepository);
	launcher.setTaskExecutor(new SyncTaskExecutor());
	return launcher;
}
 
Example 6
Source File: TaskJobLauncherCommandLineRunnerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
protected JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
	jobLauncher.setJobRepository(getJobRepository());
	jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor());
	jobLauncher.afterPropertiesSet();
	return jobLauncher;
}
 
Example 7
Source File: ThreadedPerformanceTest.java    From batchers with Apache License 2.0 5 votes vote down vote up
@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: TaskExecutorBatchConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
	simpleJobLauncher.setJobRepository(jobRepository);
	simpleJobLauncher.setTaskExecutor(taskExecutor);
	simpleJobLauncher.afterPropertiesSet();
	return simpleJobLauncher;
}
 
Example 9
Source File: SpringbatchPartitionConfig.java    From tutorials with MIT License 5 votes vote down vote up
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 10
Source File: SpringConfig.java    From tutorials with MIT License 5 votes vote down vote up
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 11
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
	jobLauncher.setJobRepository(jobRepository);
	jobLauncher.setTaskExecutor( new SimpleAsyncTaskExecutor());
	jobLauncher.afterPropertiesSet();
	return jobLauncher;
}
 
Example 12
Source File: AdHocBatchConfig.java    From spring-batch-rest with Apache License 2.0 4 votes vote down vote up
public JobLauncher getJobLauncher() {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor(executorService));
    return jobLauncher;
}
 
Example 13
Source File: BatchConfiguration.java    From patient-batch-loader with GNU General Public License v3.0 4 votes vote down vote up
protected JobLauncher createJobLauncher() throws Exception {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.afterPropertiesSet();
    return jobLauncher;
}
 
Example 14
Source File: DefaultSpringBatchLightminBatchConfigurer.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
protected JobLauncher createJobLauncher() throws Exception {
    final SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(this.jobRepository);
    jobLauncher.afterPropertiesSet();
    return jobLauncher;
}