Introduction
In this page you can find the example usage for org.springframework.batch.core.repository.support JobRepositoryFactoryBean JobRepositoryFactoryBean.
Prototype
JobRepositoryFactoryBean
Source Link
Usage
From source file:
com.example.configuration.BatchConfiguration.java
public JobRepository getJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(config.dataSource());
factory.setTransactionManager(transactionManager);
factory.setLobHandler(lobHandler());
factory.setDatabaseType(DatabaseType.fromMetaData(config.dataSource()).name());
factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
factory.afterPropertiesSet();//ww w .j a v a2 s .com
return (JobRepository) factory.getObject();
From source file:
org.my.spring.batch.java.config.demo.configuration.BatchConfiguration.java
@Override
public JobRepository getJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(getDataSource());
factory.setTransactionManager(getTransactionManager());
factory.afterPropertiesSet();/* ww w .j a v a2 s.co m*/
return (JobRepository) factory.getObject();
From source file:
com.apress.prospringintegration.springbatch.integration.BatchConfiguration.java
@Bean
public JobRepositoryFactoryBean jobRepository() {
JobRepositoryFactoryBean jobRepository = new JobRepositoryFactoryBean();
jobRepository.setDataSource(dataSource);
jobRepository.setTransactionManager(transactionManager());
return jobRepository;
From source file:
uk.ac.kcl.batch.BatchConfigurer.java
@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();// w w w .ja v a 2 s. c om
return factory.getObject();
From source file:
de.codecentric.batch.configuration.TaskExecutorBatchConfigurer.java
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(dataSource);//w w w . ja va 2 s . c om
factory.setTransactionManager(transactionManager);
String isolationLevelForCreate = env.getProperty("batch.repository.isolationlevelforcreate");
if (isolationLevelForCreate != null) {
factory.setIsolationLevelForCreate(isolationLevelForCreate);
String tablePrefix = env.getProperty("batch.repository.tableprefix");
if (tablePrefix != null) {
factory.setTablePrefix(tablePrefix);
factory.afterPropertiesSet();
return factory.getObject();
From source file:
com.springsource.html5expense.config.BatchConfig.java
@Bean
public JobRepositoryFactoryBean jobRepository() throws Exception {
JobRepositoryFactoryBean bean = new JobRepositoryFactoryBean();
bean.setTransactionManager(new DataSourceTransactionManager(dataSourceConfig.dataSource()));
bean.setDataSource(dataSourceConfig.dataSource());
return bean;//from w w w. j av a 2 s .com
From source file:
io.getlime.push.configuration.BatchSendingConfiguration.java
private JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(dataSource);//from www . j av a 2 s . c om
factory.setTransactionManager(transactionManager);
factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
factory.afterPropertiesSet();
return factory.getObject();
From source file:
org.cloudfoundry.workers.stocks.batch.BatchConfiguration.java
/**
* Stores information about the {@link Job jobs} into a backend store (like
* a {@link DataSource})//w w w.ja v a 2 s . c o m
* @throws Exception
@Bean
public JobRepository jobRepository() throws Exception {
JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
jobRepositoryFactoryBean.setDataSource(dsConfig.dataSource());
jobRepositoryFactoryBean.setTransactionManager(this.transactionManager());
jobRepositoryFactoryBean.afterPropertiesSet();
return (JobRepository) jobRepositoryFactoryBean.getObject();
From source file:
org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer.java
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(dataSource);/* www .ja va 2 s . com*/
factory.setTransactionManager(transactionManager);
factory.afterPropertiesSet();
return factory.getObject();
From source file:
org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java
@Test
@Ignore //FIXME//from w ww .ja v a 2s . c o m
public void testTransactionException() throws Exception {
final SkipWriterStub<String> writer = new SkipWriterStub<String>();
FaultTolerantStepFactoryBean<String, String> factory = new FaultTolerantStepFactoryBean<String, String>();
factory.setItemWriter(writer);
@SuppressWarnings("serial")
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource) {
private boolean failed = false;
@Override
protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
if (writer.getWritten().isEmpty() || failed || !isExistingTransaction(status.getTransaction())) {
super.doCommit(status);
return;
failed = true;
status.setRollbackOnly();
super.doRollback(status);
throw new UnexpectedRollbackException("Planned");
factory.setBeanName("stepName");
factory.setTransactionManager(transactionManager);
factory.setCommitInterval(2);
ItemReader<String> reader = new ListItemReader<String>(Arrays.asList("1", "2"));
factory.setItemReader(reader);
JobRepositoryFactoryBean repositoryFactory = new JobRepositoryFactoryBean();
repositoryFactory.setDataSource(dataSource);
repositoryFactory.setTransactionManager(transactionManager);
repositoryFactory.afterPropertiesSet();
JobRepository repository = repositoryFactory.getObject();
factory.setJobRepository(repository);
JobExecution jobExecution = repository.createJobExecution("job", new JobParameters());
StepExecution stepExecution = jobExecution.createStepExecution(factory.getName());
repository.add(stepExecution);
Step step = factory.getObject();
step.execute(stepExecution);
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());