Example usage for org.springframework.batch.core.partition.support TaskExecutorPartitionHandler setTaskExecutor

List of usage examples for org.springframework.batch.core.partition.support TaskExecutorPartitionHandler setTaskExecutor

Introduction

In this page you can find the example usage for org.springframework.batch.core.partition.support TaskExecutorPartitionHandler setTaskExecutor.

Prototype

public void setTaskExecutor(TaskExecutor taskExecutor) 

Source Link

Document

Setter for the TaskExecutor that is used to farm out step executions to multiple threads.

Usage

From source file:uk.ac.kcl.batch.LocalConfiguration.java

@Bean
public TaskExecutorPartitionHandler partitionHandler(@Qualifier("compositeSlaveStep") Step compositeSlaveStep,
        @Qualifier("slaveTaskExecutor") TaskExecutor taskExecutor) {
    TaskExecutorPartitionHandler handler = new TaskExecutorPartitionHandler();
    handler.setGridSize(gridSize);//ww w. ja v a  2 s  .  c om
    handler.setStep(compositeSlaveStep);
    handler.setTaskExecutor(taskExecutor);
    return handler;
}

From source file:org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.java

private void configurePartitionStep(PartitionStep ts) {
    Assert.state(partitioner != null, "A Partitioner must be provided for a partition step");
    configureAbstractStep(ts);/*from   ww  w . ja  v a2  s.  co m*/

    if (partitionHandler != null) {
        ts.setPartitionHandler(partitionHandler);
    } else {
        TaskExecutorPartitionHandler partitionHandler = new TaskExecutorPartitionHandler();
        partitionHandler.setStep(step);
        if (taskExecutor == null) {
            taskExecutor = new SyncTaskExecutor();
        }
        partitionHandler.setGridSize(gridSize);
        partitionHandler.setTaskExecutor(taskExecutor);
        ts.setPartitionHandler(partitionHandler);
    }

    boolean allowStartIfComplete = this.allowStartIfComplete != null ? this.allowStartIfComplete : false;
    String name = this.name;
    if (step != null) {
        try {
            allowStartIfComplete = step.isAllowStartIfComplete();
            name = step.getName();
        } catch (Exception e) {
            logger.info("Ignored exception from step asking for name and allowStartIfComplete flag. "
                    + "Using default from enclosing PartitionStep (" + name + "," + allowStartIfComplete
                    + ").");
        }
    }
    SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, allowStartIfComplete,
            name, partitioner);
    ts.setStepExecutionSplitter(splitter);
    if (stepExecutionAggregator != null) {
        ts.setStepExecutionAggregator(stepExecutionAggregator);
    }
}