List of usage examples for org.springframework.batch.core.repository.support JobRepositoryFactoryBean afterPropertiesSet
@Override
public void afterPropertiesSet() throws Exception
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(); return (JobRepository) factory.getObject(); }
From source file:io.getlime.push.configuration.BatchSendingConfiguration.java
private JobRepository createJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource);/*from w w w .j av a2s .co m*/ factory.setTransactionManager(transactionManager); factory.setIsolationLevelForCreate("ISOLATION_DEFAULT"); factory.afterPropertiesSet(); return factory.getObject(); }
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(); return (JobRepository) factory.getObject(); }
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(); 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:de.codecentric.batch.configuration.TaskExecutorBatchConfigurer.java
protected JobRepository createJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource);//from w w w.j av a 2s.com 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:org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer.java
protected JobRepository createJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource);//w w w . java 2 s .c o m factory.setTransactionManager(transactionManager); factory.afterPropertiesSet(); return factory.getObject(); }
From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java
@Test @Ignore //FIXME/*from w w w . java2 s .co 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()); assertEquals("[]", writer.getCommitted().toString()); }
From source file:org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.java
protected JobRepository createJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(this.dataSource); if (this.entityManagerFactory != null) { logger.warn(/*w ww. j av a2s. c om*/ "JPA does not support custom isolation levels, so locks may not be taken when launching Jobs"); factory.setIsolationLevelForCreate("ISOLATION_DEFAULT"); } String tablePrefix = this.properties.getTablePrefix(); if (StringUtils.hasText(tablePrefix)) { factory.setTablePrefix(tablePrefix); } factory.setTransactionManager(getTransactionManager()); factory.afterPropertiesSet(); return factory.getObject(); }