Class JsrChunkProcessor<I,​O>

  • Type Parameters:
    I - The input type for the step
    O - The output type for the step
    All Implemented Interfaces:
    ChunkProcessor<I>
    Direct Known Subclasses:
    JsrFaultTolerantChunkProcessor

    public class JsrChunkProcessor<I,​O>
    extends java.lang.Object
    implements ChunkProcessor<I>
    ChunkProcessor implementation that implements JSR-352's chunking pattern (read and process in a loop until the chunk is complete then write). This implementation is responsible for all three phases of chunk based processing (reading, processing and writing).
    Author:
    Michael Minella
    • Method Detail

      • setListeners

        public void setListeners​(java.util.List<? extends StepListener> listeners)
        Register some StepListeners with the handler. Each will get the callbacks in the order specified at the correct stage.
        Parameters:
        listeners - list of listeners to be used within this step
      • registerListener

        public void registerListener​(StepListener listener)
        Register a listener for callbacks at the appropriate stages in a process.
        Parameters:
        listener - a StepListener
      • provide

        protected I provide​(StepContribution contribution,
                            Chunk<I> chunk)
                     throws java.lang.Exception
        Responsible for the reading portion of the chunking loop. In this implementation, delegates to doProvide(StepContribution, Chunk)
        Parameters:
        contribution - a StepContribution
        chunk - a Chunk
        Returns:
        an item
        Throws:
        java.lang.Exception - thrown if error occurs during the reading portion of the chunking loop.
      • doProvide

        protected final I doProvide​(StepContribution contribution,
                                    Chunk<I> chunk)
                             throws java.lang.Exception
        Implements reading as well as any related listener calls required.
        Parameters:
        contribution - a StepContribution
        chunk - a Chunk
        Returns:
        an item
        Throws:
        java.lang.Exception - thrown if error occurs during reading or listener calls.
      • transform

        protected O transform​(StepContribution contribution,
                              I item)
                       throws java.lang.Exception
        Responsible for the processing portion of the chunking loop. In this implementation, delegates to the doTransform(Object) if a processor is available (returns the item unmodified if it is not)
        Parameters:
        contribution - a StepContribution
        item - an item
        Returns:
        a processed item if a processor is present (the unmodified item if it is not)
        Throws:
        java.lang.Exception - thrown if error occurs during the processing portion of the chunking loop.
      • doTransform

        protected final O doTransform​(I item)
                               throws java.lang.Exception
        Implements processing and all related listener calls.
        Parameters:
        item - the item to be processed
        Returns:
        the processed item
        Throws:
        java.lang.Exception - thrown if error occurs during processing.
      • persist

        protected void persist​(StepContribution contribution,
                               Chunk<O> chunk)
                        throws java.lang.Exception
        Responsible for the writing portion of the chunking loop. In this implementation, delegates to the {doPersist(StepContribution, Chunk).
        Parameters:
        contribution - a StepContribution
        chunk - a Chunk
        Throws:
        java.lang.Exception - thrown if error occurs during the writing portion of the chunking loop.
      • doPersist

        protected final void doPersist​(StepContribution contribution,
                                       Chunk<O> chunk)
                                throws java.lang.Exception
        Implements writing and all related listener calls
        Parameters:
        contribution - a StepContribution
        chunk - a Chunk
        Throws:
        java.lang.Exception - thrown if error occurs during the writing portion of the chunking loop.