org.springframework.batch.sample.common

## Class StagingItemWriter<T>

- java.lang.Object
- - org.springframework.dao.support.DaoSupport
  - - org.springframework.jdbc.core.support.JdbcDaoSupport
    - - org.springframework.batch.sample.common.StagingItemWriter<T>

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

      public class StagingItemWriter<T>
      extends org.springframework.jdbc.core.support.JdbcDaoSupport
      implements StepExecutionListener, ItemWriter<T>

  Database `ItemWriter` implementing the process indicator pattern.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `DONE`
    `protected static java.lang.String` | `NEW`

    - ### Fields inherited from class org.springframework.dao.support.DaoSupport

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StagingItemWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `protected void` | `initDao()` Check mandatory properties.
    `void` | `setIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer incrementer)` Setter for the key generator for the staging table.
    `void` | `write(java.util.List<? extends T> items)` Serialize the item to the staging table, and add a NEW processed flag.

    - ### Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport

      `checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate`

    - ### Methods inherited from class org.springframework.dao.support.DaoSupport

      `afterPropertiesSet`

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

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

- - ### Field Detail

    - #### NEW

          protected static final java.lang.String NEW

      See Also:
        Constant Field Values

    - #### DONE

          protected static final java.lang.String DONE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StagingItemWriter

          public StagingItemWriter()

  - ### Method Detail

    - #### initDao

          protected void initDao()
                          throws java.lang.Exception

      Check mandatory properties.
      Overrides:
        `initDao` in class `org.springframework.dao.support.DaoSupport`
      Throws:
        `java.lang.Exception`
      See Also:
        `DaoSupport.initDao()`

    - #### setIncrementer

          public void setIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer incrementer)

      Setter for the key generator for the staging table.
      Parameters:
        `incrementer` - the `DataFieldMaxValueIncrementer` to set

    - #### write

          public void write(java.util.List<? extends T> items)

      Serialize the item to the staging table, and add a NEW processed flag.
      Specified by:
        `write` in interface `ItemWriter<T>`
      Parameters:
        `items` - items to be written
      See Also:
        `ItemWriter.write(java.util.List)`

    - #### 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`