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

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

Introduction

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

Prototype

@Override
    public void setAttribute(String name, @Nullable Object value) 

Source Link

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  ww  w  .ja  v  a2s  . c  o  m
    }

    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());

}