Example usage for org.springframework.batch.integration.chunk ChunkRequest getItems

List of usage examples for org.springframework.batch.integration.chunk ChunkRequest getItems

Introduction

In this page you can find the example usage for org.springframework.batch.integration.chunk ChunkRequest getItems.

Prototype

public Collection<? extends T> getItems() 

Source Link

Usage

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
 *//*from  w w w .  j a v  a2  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;

}

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

@Test
public void testSerializable() throws Exception {
    @SuppressWarnings("unchecked")
    ChunkRequest<String> result = (ChunkRequest<String>) SerializationUtils
            .deserialize(SerializationUtils.serialize(request));
    assertNotNull(result.getStepContribution());
    assertEquals(111L, result.getJobId());
    assertEquals(2, result.getItems().size());
}