Example usage for org.springframework.batch.core.step.item Chunk isBusy

List of usage examples for org.springframework.batch.core.step.item Chunk isBusy

Introduction

In this page you can find the example usage for org.springframework.batch.core.step.item Chunk isBusy.

Prototype

public boolean isBusy() 

Source Link

Document

Query the chunk to see if anyone has registered an interest in keeping a reference to it.

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);
        }/*ww  w. j  av a 2  s .  co 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());

}

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

@Override
protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) {

    @SuppressWarnings("unchecked")
    UserData<O> data = (UserData<O>) inputs.getUserData();
    Chunk<O> previous = data.getOutputs();

    Chunk<O> next = new Chunk<O>(outputs.getItems(), previous.getSkips());
    next.setBusy(previous.isBusy());

    // Remember for next time if there are skips accumulating
    data.setOutputs(next);/*from w  w  w  . ja v  a2s . com*/

    return next;

}