org.springframework.batch.sample.common

## Class StagingItemReader<T>

- java.lang.Object
- - org.springframework.batch.sample.common.StagingItemReader<T>

- All Implemented Interfaces:
    StepExecutionListener, StepListener, ItemReader<ProcessIndicatorItemWrapper<T>>, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

      public class StagingItemReader<T>
      extends java.lang.Object
      implements ItemReader<ProcessIndicatorItemWrapper<T>>, StepExecutionListener, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

  Thread-safe database `ItemReader` implementing the process indicator pattern. To achieve restartability use together with `StagingItemProcessor`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StagingItemReader()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `ExitStatus` | `afterStep(StepExecution stepExecution)` Give a listener a chance to modify the exit status from a step.
    `void` | `beforeStep(StepExecution stepExecution)` Initialize the state of the listener with the `StepExecution` from the current scope.
    `void` | `destroy()`
    `ProcessIndicatorItemWrapper<T>` | `read()` Reads a piece of input data and advance to the next one.
    `void` | `setDataSource(javax.sql.DataSource dataSource)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StagingItemReader

          public StagingItemReader()

  - ### Method Detail

    - #### setDataSource

          public void setDataSource(javax.sql.DataSource dataSource)

    - #### destroy

          public void destroy()
                       throws java.lang.Exception

      Specified by:
        `destroy` in interface `org.springframework.beans.factory.DisposableBean`
      Throws:
        `java.lang.Exception`

    - #### afterPropertiesSet

          public final void afterPropertiesSet()
                                        throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.Exception`

    - #### read

          public ProcessIndicatorItemWrapper<T> read()

      Description copied from interface: `ItemReader`
      Reads a piece of input data and advance to the next one. Implementations must return `null` at the end of the input data set. In a transactional setting, caller might get the same item twice from successive calls (or otherwise), if the first call was in a transaction that rolled back.
      Specified by:
        `read` in interface `ItemReader<ProcessIndicatorItemWrapper<T>>`
      Returns:
        T the item to be processed

    - #### afterStep

          public ExitStatus afterStep(StepExecution stepExecution)

      Description copied from interface: `StepExecutionListener`
      Give a listener a chance to modify the exit status from a step. The value returned will be combined with the normal exit status using `ExitStatus.and(ExitStatus)`. Called after execution of step's processing logic (both successful or failed). Throwing exception in this method has no effect, it will only be logged.
      Specified by:
        `afterStep` in interface `StepExecutionListener`
      Returns:
        an `ExitStatus` to combine with the normal value. Return null to leave the old value unchanged.

    - #### beforeStep

          public void beforeStep(StepExecution stepExecution)

      Description copied from interface: `StepExecutionListener`
      Initialize the state of the listener with the `StepExecution` from the current scope.
      Specified by:
        `beforeStep` in interface `StepExecutionListener`