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

The following examples show how to use org.springframework.batch.core.repository.support.JobRepositoryFactoryBean. These examples are extracted from open source projects. 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 Project: spring-cloud-dataflow   Source File: JobDependencies.java    License: 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 2
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 3
Source Project: Demo   Source File: CsvBatchConfig.java    License: 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 4
Source Project: spring-cloud   Source File: SpringBatchConfiguration.java    License: 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 Project: SpringBootBucket   Source File: MyBatchConfig.java    License: 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 6
@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 7
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(this.batchDataSource);
    factory.setTransactionManager(getTransactionManager());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 8
Source Project: CogStack-Pipeline   Source File: BatchConfigurer.java    License: 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 9
Source Project: jump-the-queue   Source File: BeansBatchConfig.java    License: 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 10
Source Project: spring-cloud-dataflow   Source File: JobCommandTests.java    License: 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 11
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 12
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
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 Project: spring-cloud-dataflow   Source File: TaskConfiguration.java    License: 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 15
Source Project: spring-cloud-dataflow   Source File: TaskConfiguration.java    License: 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 16
Source Project: spring-cloud-dataflow   Source File: JobDependencies.java    License: 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 17
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 18
Source Project: tutorials   Source File: SpringbatchPartitionConfig.java    License: 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 19
Source Project: tutorials   Source File: SpringConfig.java    License: 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 20
Source Project: spring4-sandbox   Source File: JpaBatchConfigurer.java    License: 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();
}