Example usage for org.springframework.batch.core.step.item ChunkProcessor getClass

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

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
 *//*from ww  w.  j  av a  2  s.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;

}