Java Code Examples for org.springframework.batch.core.explore.support.JobExplorerFactoryBean#setDataSource()

The following examples show how to use org.springframework.batch.core.explore.support.JobExplorerFactoryBean#setDataSource() . 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: DefaultSpringBatchLightminBatchConfigurer.java    From spring-batch-lightmin with Apache License 2.0 6 votes vote down vote up
protected void createJdbcComponents() throws Exception {

        // jobExplorer
        final JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
        jobExplorerFactoryBean.setTablePrefix(this.tablePrefix);
        jobExplorerFactoryBean.setDataSource(this.dataSource);
        jobExplorerFactoryBean.afterPropertiesSet();
        this.jobExplorer = jobExplorerFactoryBean.getObject();

        // jobExecutionDao
        this.jobExecutionDao = this.createJobExecutionDao();
        // jobInstanceDao
        this.jobInstanceDao = this.createJobInstanceDao();
        // stepExecutionDao
        this.stepExecutionDao = this.createStepExecutionDao();
        // jobRepository
        this.jobRepository = this.createJobRepository();
    }
 
Example 2
Source File: SpringBatchConfiguration.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void initialize() {
    try {
        if (dataSource == null) {
            log.warn("No datasource was provided...using a Map based JobRepository");

            if (this.transactionManager == null) {
                this.transactionManager = new ResourcelessTransactionManager();
            }

            MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(
                    this.transactionManager);
            jobRepositoryFactory.afterPropertiesSet();
            this.jobRepository = jobRepositoryFactory.getObject();

            MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(
                    jobRepositoryFactory);
            jobExplorerFactory.afterPropertiesSet();
            this.jobExplorer = jobExplorerFactory.getObject();
        } else {
            this.jobRepository = createJobRepository();

            JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
            jobExplorerFactoryBean.setDataSource(this.dataSource);
            jobExplorerFactoryBean.afterPropertiesSet();
            this.jobExplorer = jobExplorerFactoryBean.getObject();
        }

        this.jobLauncher = createJobLauncher();
    } catch (Exception e) {
        throw new BatchConfigurationException(e);
    }
}
 
Example 3
Source File: BatchConfiguration.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Bean
BatchConfigurer myBatchConfigurer(DataSource dataSource,
		Jackson2ExecutionContextStringSerializer myJackson2ExecutionContextStringSerializer,
		PlatformTransactionManager transactionManager) {
	return new DefaultBatchConfigurer(dataSource) {
		@Override
		protected JobExplorer createJobExplorer() throws Exception {
			JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
			jobExplorerFactoryBean.setDataSource(dataSource);
			jobExplorerFactoryBean
					.setSerializer(myJackson2ExecutionContextStringSerializer);
			jobExplorerFactoryBean.afterPropertiesSet();
			return jobExplorerFactoryBean.getObject();
		}

		@Override
		protected JobRepository createJobRepository() throws Exception {
			JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
			jobRepositoryFactoryBean.setDataSource(dataSource);
			jobRepositoryFactoryBean
					.setSerializer(myJackson2ExecutionContextStringSerializer);
			jobRepositoryFactoryBean.setTransactionManager(transactionManager);
			jobRepositoryFactoryBean.afterPropertiesSet();
			return jobRepositoryFactoryBean.getObject();
		}
	};
}
 
Example 4
Source File: BatchConfiguration.java    From patient-batch-loader with GNU General Public License v3.0 5 votes vote down vote up
@PostConstruct
public void afterPropertiesSet() throws Exception {
    this.jobRepository = createJobRepository();
    JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
    jobExplorerFactoryBean.setDataSource(this.batchDataSource);
    jobExplorerFactoryBean.afterPropertiesSet();
    this.jobExplorer = jobExplorerFactoryBean.getObject();
    this.jobLauncher = createJobLauncher();
}
 
Example 5
Source File: BatchConfigurer.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Bean
@Autowired
public JobExplorer jobExplorer(@Qualifier("jobRepositoryDataSource")
                                           DataSource dataSource) throws Exception{
    JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
    factory.setDataSource(dataSource);
    
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 6
Source File: AbstractEmployeeJobConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean
public JobExplorer jobExplorer() throws Exception {
    JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
    factory.setDataSource(dataSource);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 7
Source File: TaskExecutorBatchConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void initialize() throws Exception {
	if (dataSource == null) {
		LOGGER.warn("No datasource was provided...using a Map based JobRepository");

		if (this.transactionManager == null) {
			this.transactionManager = new ResourcelessTransactionManager();
		}

		MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(this.transactionManager);
		jobRepositoryFactory.afterPropertiesSet();
		this.jobRepository = jobRepositoryFactory.getObject();

		MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(jobRepositoryFactory);
		jobExplorerFactory.afterPropertiesSet();
		this.jobExplorer = jobExplorerFactory.getObject();
	} else {
		if (this.transactionManager == null) {
			this.transactionManager = new DataSourceTransactionManager(dataSource);
		}

		this.jobRepository = createJobRepository();

		JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
		jobExplorerFactoryBean.setDataSource(this.dataSource);
		jobExplorerFactoryBean.setSerializer(serializer);
		String tablePrefix = batchConfig.getRepository().getTablePrefix();
		if (tablePrefix != null) {
			jobExplorerFactoryBean.setTablePrefix(tablePrefix);
		}
		jobExplorerFactoryBean.afterPropertiesSet();
		this.jobExplorer = jobExplorerFactoryBean.getObject();
	}

	this.jobLauncher = createJobLauncher();
}
 
Example 8
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void initialize() {
	try {
		if (dataSource == null) {
			logger.warn("No datasource was provided...using a Map based JobRepository");

			if (this.transactionManager == null) {
				this.transactionManager = new ResourcelessTransactionManager();
			}

			MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(
					this.transactionManager);
			jobRepositoryFactory.afterPropertiesSet();
			this.jobRepository = jobRepositoryFactory.getObject();

			MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(
					jobRepositoryFactory);
			jobExplorerFactory.afterPropertiesSet();
			this.jobExplorer = jobExplorerFactory.getObject();
		} else {
			this.jobRepository = createJobRepository();

			JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
			jobExplorerFactoryBean.setDataSource(this.dataSource);
			jobExplorerFactoryBean.afterPropertiesSet();
			this.jobExplorer = jobExplorerFactoryBean.getObject();
		}

		this.jobLauncher = createJobLauncher();
	} catch (Exception e) {
		throw new BatchConfigurationException(e);
	}
}
 
Example 9
Source File: JdbcHdfsConfiguration.java    From spring-cloud-task-app-starters with Apache License 2.0 4 votes vote down vote up
@Bean
public JobExplorerFactoryBean jobExplorer() {
	JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
	jobExplorerFactoryBean.setDataSource(this.taskDataSource);
	return jobExplorerFactoryBean;
}
 
Example 10
Source File: JobDependencies.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
public JobExplorerFactoryBean jobExplorerFactoryBeanForServer(DataSource dataSource) {
	JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
	jobExplorerFactoryBean.setDataSource(dataSource);
	return jobExplorerFactoryBean;
}