Example usage for org.springframework.batch.core.repository.support MapJobRepositoryFactoryBean setTransactionManager

List of usage examples for org.springframework.batch.core.repository.support MapJobRepositoryFactoryBean setTransactionManager

Introduction

In this page you can find the example usage for org.springframework.batch.core.repository.support MapJobRepositoryFactoryBean setTransactionManager.

Prototype

public void setTransactionManager(PlatformTransactionManager transactionManager) 

Source Link

Document

Public setter for the PlatformTransactionManager .

Usage

From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanRollbackTests.java

@SuppressWarnings("unchecked")
@Before//from  w w w  . j av  a2 s  .  c  o m
public void setUp() throws Exception {
    reader = new SkipReaderStub<String>();
    processor = new SkipProcessorStub<String>();
    writer = new SkipWriterStub<String>();

    factory = new FaultTolerantStepFactoryBean<String, String>();

    factory.setBeanName("stepName");
    ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager();
    factory.setTransactionManager(transactionManager);
    factory.setCommitInterval(2);

    reader.clear();
    reader.setItems("1", "2", "3", "4", "5");
    factory.setItemReader(reader);
    processor.clear();
    factory.setItemProcessor(processor);
    writer.clear();
    factory.setItemWriter(writer);

    factory.setSkipLimit(2);

    factory.setSkippableExceptionClasses(getExceptionMap(Exception.class));

    MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean();
    repositoryFactory.setTransactionManager(transactionManager);
    repositoryFactory.afterPropertiesSet();
    repository = repositoryFactory.getObject();
    factory.setJobRepository(repository);

    jobExecution = repository.createJobExecution("skipJob", new JobParameters());
    stepExecution = jobExecution.createStepExecution(factory.getName());
    repository.add(stepExecution);
}