org.springframework.batch.core.repository.support.JobRepositoryFactoryBean Java Examples

The following examples show how to use org.springframework.batch.core.repository.support.JobRepositoryFactoryBean. 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: TaskExecutorBatchConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 6 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
	JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
	factory.setDataSource(dataSource);
	factory.setTransactionManager(transactionManager);
	factory.setSerializer(serializer);
	String isolationLevelForCreate = batchConfig.getRepository().getIsolationLevelForCreate();
	if (isolationLevelForCreate != null) {
		factory.setIsolationLevelForCreate(isolationLevelForCreate);
	}
	String tablePrefix = batchConfig.getRepository().getTablePrefix();
	if (tablePrefix != null) {
		factory.setTablePrefix(tablePrefix);
	}
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
Example #2
Source File: JobDependencies.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: JobExecutionsDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void initialize() throws Exception {
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(this.dataSource);
	repositoryFactoryBean.setTransactionManager(new DataSourceTransactionManager(this.dataSource));
	this.jobRepository = repositoryFactoryBean.getObject();
	this.dao = (new TaskExecutionDaoFactoryBean(this.dataSource)).getObject();
	this.taskBatchDao = new JdbcTaskBatchDao(this.dataSource);
}
 
Example #4
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
	JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
	factory.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE");
	factory.setDataSource(dataSource);
	factory.setTransactionManager(transactionManager);
	factory.setValidateTransactionState(false);
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
Example #5
Source File: SpringConfig.java    From tutorials with MIT License 5 votes vote down vote up
private JobRepository getJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(dataSource());
    factory.setTransactionManager(getTransactionManager());
    // JobRepositoryFactoryBean's methods Throws Generic Exception,
    // it would have been better to have a specific one
    factory.afterPropertiesSet();
    return (JobRepository) factory.getObject();
}
 
Example #6
Source File: SpringbatchPartitionConfig.java    From tutorials with MIT License 5 votes vote down vote up
private JobRepository getJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(dataSource());
    factory.setTransactionManager(getTransactionManager());
    // JobRepositoryFactoryBean's methods Throws Generic Exception,
    // it would have been better to have a specific one
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #7
Source File: DefaultSpringBatchLightminBatchConfigurer.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
    final JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
    jobRepositoryFactoryBean.setDataSource(this.dataSource);
    jobRepositoryFactoryBean.setTransactionManager(this.transactionManager);
    jobRepositoryFactoryBean.setTablePrefix(this.tablePrefix);
    jobRepositoryFactoryBean.afterPropertiesSet();
    return jobRepositoryFactoryBean.getObject();
}
 
Example #8
Source File: JobDependencies.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public JobRepositoryFactoryBean jobRepositoryFactoryBeanForServer(DataSource dataSource,
		PlatformTransactionManager platformTransactionManager) {
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(dataSource);
	repositoryFactoryBean.setTransactionManager(platformTransactionManager);
	return repositoryFactoryBean;
}
 
Example #9
Source File: TaskConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public JobRepositoryFactoryBean jobRepositoryFactoryBean(DataSource dataSource,
		PlatformTransactionManager platformTransactionManager) {
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(dataSource);
	repositoryFactoryBean.setTransactionManager(platformTransactionManager);
	return repositoryFactoryBean;
}
 
Example #10
Source File: TaskConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@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 #11
Source File: CsvBatchConfig.java    From Demo with Apache License 2.0 5 votes vote down vote up
@Bean
public JobRepository jobRepository(DataSource dataSource, PlatformTransactionManager transactionManager)
        throws Exception {
    JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
    jobRepositoryFactoryBean.setDataSource(dataSource);
    jobRepositoryFactoryBean.setTransactionManager(transactionManager);
    jobRepositoryFactoryBean.setDatabaseType("mysql");
    return jobRepositoryFactoryBean.getObject();
}
 
Example #12
Source File: JobStepExecutionsDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void initialize() throws Exception {
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(this.dataSource);
	repositoryFactoryBean.setTransactionManager(new DataSourceTransactionManager(this.dataSource));
	this.jobRepository = repositoryFactoryBean.getObject();
	this.dao = (new TaskExecutionDaoFactoryBean(this.dataSource)).getObject();
	this.taskBatchDao = new JdbcTaskBatchDao(this.dataSource);
}
 
Example #13
Source File: JobInstancesDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void initialize() throws Exception {
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(this.dataSource);
	repositoryFactoryBean.setTransactionManager(new DataSourceTransactionManager(this.dataSource));
	this.jobRepository = repositoryFactoryBean.getObject();
	this.dao = (new TaskExecutionDaoFactoryBean(this.dataSource)).getObject();
	this.taskBatchDao = new JdbcTaskBatchDao(this.dataSource);
}
 
Example #14
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
	Thread.sleep(2000);
	DataSource dataSource = applicationContext.getBean(DataSource.class);
	taskBatchDao = new JdbcTaskBatchDao(dataSource);
	JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
	repositoryFactoryBean.setDataSource(dataSource);
	repositoryFactoryBean.setTransactionManager(new DataSourceTransactionManager(dataSource));
	jobRepository = repositoryFactoryBean.getObject();
	TaskExecutionDaoFactoryBean taskExecutionDaoFactoryBean = new TaskExecutionDaoFactoryBean(dataSource);
	dao = taskExecutionDaoFactoryBean.getObject();
	taskExecutionIds.add(createSampleJob(JOB_NAME_ORIG, 1));
	taskExecutionIds.add(createSampleJob(JOB_NAME_FOO, 1));
	taskExecutionIds.add(createSampleJob(JOB_NAME_FOOBAR, 2));
}
 
Example #15
Source File: BeansBatchConfig.java    From jump-the-queue with Apache License 2.0 5 votes vote down vote up
/**
 * This method is creating jobrepository
 *
 * @return JobRepositoryFactoryBean
 */
@Bean(name = "jobRepository")
public JobRepositoryFactoryBean jobRepository() {

  this.jobRepository = new JobRepositoryFactoryBean();
  this.jobRepository.setDataSource(this.dataSource);
  this.jobRepository.setTransactionManager(this.transactionManager);
  this.jobRepository.setIsolationLevelForCreate(this.isolationLevelForCreate);
  return this.jobRepository;
}
 
Example #16
Source File: BatchConfigurer.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Override
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(jobRepositoryDataSource);
    factory.setTransactionManager(getTransactionManager());
    //to avoid deadlocks on the Job repo in SQL SERVER 2008
    factory.setIsolationLevelForCreate("ISOLATION_REPEATABLE_READ");
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #17
Source File: BatchConfiguration.java    From patient-batch-loader with GNU General Public License v3.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(this.batchDataSource);
    factory.setTransactionManager(getTransactionManager());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #18
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 #19
Source File: MyBatchConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * JobRepository,用来注册Job的容器
 * jobRepositor的定义需要dataSource和transactionManager,Spring Boot已为我们自动配置了
 * 这两个类,Spring可通过方法注入已有的Bean
 *
 * @param dataSource
 * @param transactionManager
 * @return
 * @throws Exception
 */
@Bean
public JobRepository jobRepository(DruidDataSource dataSource, PlatformTransactionManager transactionManager) throws Exception {
    JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
    jobRepositoryFactoryBean.setDataSource(dataSource);
    jobRepositoryFactoryBean.setTransactionManager(transactionManager);
    jobRepositoryFactoryBean.setDatabaseType(String.valueOf(DatabaseType.ORACLE));
    jobRepositoryFactoryBean.setMaxVarCharLength(5000);
    // 下面事务隔离级别的配置是针对Oracle的
    jobRepositoryFactoryBean.setIsolationLevelForCreate("ISOLATION_READ_COMMITTED");
    jobRepositoryFactoryBean.afterPropertiesSet();
    return jobRepositoryFactoryBean.getObject();
}
 
Example #20
Source File: SpringBatchConfiguration.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE");
    factory.setDataSource(dataSource);
    factory.setTransactionManager(transactionManager);
    factory.setValidateTransactionState(false);
    factory.afterPropertiesSet();
    return factory.getObject();
}