Example usage for org.springframework.batch.core.scope.context ChunkContext setComplete

List of usage examples for org.springframework.batch.core.scope.context ChunkContext setComplete

Introduction

In this page you can find the example usage for org.springframework.batch.core.scope.context ChunkContext setComplete.

Prototype

public void setComplete() 

Source Link

Document

Setter for the flag to signal complete processing of a chunk.

Usage

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

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {

    @SuppressWarnings("unchecked")
    Chunk<I> inputs = (Chunk<I>) chunkContext.getAttribute(INPUTS_KEY);
    if (inputs == null) {
        inputs = chunkProvider.provide(contribution);
        if (buffering) {
            chunkContext.setAttribute(INPUTS_KEY, inputs);
        }/*from  w  w  w.  j  a v  a  2  s.  com*/
    }

    chunkProcessor.process(contribution, inputs);
    chunkProvider.postProcess(contribution, inputs);

    // Allow a message coming back from the processor to say that we
    // are not done yet
    if (inputs.isBusy()) {
        logger.debug("Inputs still busy");
        return RepeatStatus.CONTINUABLE;
    }

    chunkContext.removeAttribute(INPUTS_KEY);
    chunkContext.setComplete();

    if (logger.isDebugEnabled()) {
        logger.debug("Inputs not busy, ended: " + inputs.isEnd());
    }
    return RepeatStatus.continueIf(!inputs.isEnd());

}