org.springframework.batch.support.transaction.ResourcelessTransactionManager Java Examples

The following examples show how to use org.springframework.batch.support.transaction.ResourcelessTransactionManager. 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 createMapComponents() throws Exception {
    if (this.transactionManager == null) {
        this.transactionManager = new ResourcelessTransactionManager();
    }
    // jobRepository
    final MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(
            this.transactionManager);
    jobRepositoryFactory.afterPropertiesSet();
    this.jobRepository = jobRepositoryFactory.getObject();
    // jobExplorer
    final MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(
            jobRepositoryFactory);
    jobExplorerFactory.afterPropertiesSet();
    this.jobExplorer = jobExplorerFactory.getObject();
    // jobExecutionDao
    this.jobExecutionDao = new MapJobExecutionDao();
    // jobInstanceDao
    this.jobInstanceDao = new MapJobInstanceDao();
    // stepExecutionDao
    this.stepExecutionDao = new MapStepExecutionDao();
}
 
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: DefaultTaskConfigurer.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public PlatformTransactionManager getTransactionManager() {
	if (this.transactionManager == null) {
		if (isDataSourceAvailable()) {
			try {
				Class.forName("javax.persistence.EntityManager");
				if (this.context != null && this.context
						.getBeanNamesForType(EntityManager.class).length > 0) {
					logger.debug(
							"EntityManager was found, using JpaTransactionManager");
					this.transactionManager = new JpaTransactionManager();
				}
			}
			catch (ClassNotFoundException ignore) {
				logger.debug(
						"No EntityManager was found, using DataSourceTransactionManager");
			}
			finally {
				if (this.transactionManager == null) {
					this.transactionManager = new DataSourceTransactionManager(
							this.dataSource);
				}
			}
		}
		else {
			logger.debug(
					"No DataSource was found, using ResourcelessTransactionManager");
			this.transactionManager = new ResourcelessTransactionManager();
		}
	}

	return this.transactionManager;
}
 
Example #4
Source File: TestConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	if (this.dataSource == null) {
		return new ResourcelessTransactionManager();
	}
	else {
		return new DataSourceTransactionManager(this.dataSource);
	}
}
 
Example #5
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 #6
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 #7
Source File: ApplicationConfiguration.java    From blackduck-alert with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #8
Source File: SpringBatchLightminServiceConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean(name = "lightminTransactionManager")
@ConditionalOnMissingBean(name = "lightminTransactionManager")
public PlatformTransactionManager lightminTransactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #9
Source File: LightminServerCoreConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean(name = "lightminServerSchedulerTransactionManager")
@ConditionalOnMissingBean(name = "lightminServerSchedulerTransactionManager")
public PlatformTransactionManager lightminServerSchedulerTransactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #10
Source File: SpringBatchScheduler.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public JobRepository jobRepository() throws Exception {
    MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
    factory.setTransactionManager(new ResourcelessTransactionManager());
    return (JobRepository) factory.getObject();
}
 
Example #11
Source File: TaskletsConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #12
Source File: ChunksConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #13
Source File: SpringbatchPartitionConfig.java    From tutorials with MIT License 4 votes vote down vote up
private PlatformTransactionManager getTransactionManager() {
    return new ResourcelessTransactionManager();
}
 
Example #14
Source File: SpringConfig.java    From tutorials with MIT License 4 votes vote down vote up
private PlatformTransactionManager getTransactionManager() {
    return new ResourcelessTransactionManager();
}