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

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

Introduction

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

Prototype

public Chunk(Collection<? extends W> items) 

Source Link

Usage

From source file:es.fcs.batch.integration.chunk.GenericChunkProcessorChunkHandler.java

/**
 * @param chunkRequest the current request
 * @param stepContribution the step contribution to update
 * @throws Exception if there is a fatal exception
 *//*w w w. ja  v  a 2s  . co m*/
private Throwable process(MyChunkRequest<S> chunkRequest, StepContribution stepContribution) throws Exception {

    ChunkProcessor<S> chunkProcessor = chunkRequest.getChunkProcessor();
    logger.debug("ChunkProcessor=" + chunkProcessor.getClass());
    Assert.state(chunkProcessor instanceof ChunkProcessor<?>,
            chunkProcessor.getClass() + "must be a ChunkProcessor");

    Chunk<S> chunk = new Chunk<S>(chunkRequest.getItems());
    Throwable failure = null;
    try {
        chunkProcessor.process(stepContribution, chunk);
    } catch (SkipLimitExceededException e) {
        failure = e;
    } catch (NonSkippableReadException e) {
        failure = e;
    } catch (SkipListenerFailedException e) {
        failure = e;
    } catch (RetryException e) {
        failure = e;
    } catch (JobInterruptedException e) {
        failure = e;
    } catch (Exception e) {
        if (chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>) {
            // try again...
            throw e;
        } else {
            failure = e;
        }
    }

    return failure;

}

From source file:org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler.java

/**
 * @param chunkRequest the current request
 * @param stepContribution the step contribution to update
 * @throws Exception if there is a fatal exception
 *///  w w w .j a  v  a  2 s  . c o m
private Throwable process(ChunkRequest<S> chunkRequest, StepContribution stepContribution) throws Exception {

    Chunk<S> chunk = new Chunk<S>(chunkRequest.getItems());
    Throwable failure = null;
    try {
        chunkProcessor.process(stepContribution, chunk);
    } catch (SkipLimitExceededException e) {
        failure = e;
    } catch (NonSkippableReadException e) {
        failure = e;
    } catch (SkipListenerFailedException e) {
        failure = e;
    } catch (RetryException e) {
        failure = e;
    } catch (JobInterruptedException e) {
        failure = e;
    } catch (Exception e) {
        if (chunkProcessor instanceof FaultTolerantChunkProcessor<?, ?>) {
            // try again...
            throw e;
        } else {
            failure = e;
        }
    }

    return failure;

}