Interface StatefulWriter

  • All Known Implementing Classes:
    BeanWriterImpl, XmlWriter

    public interface StatefulWriter
    StatefulWriter can be implemented by writers that maintain state, so that in case of an error, the last updated state of the writer can be restored and writing can resume.

    This interface is used to implement a restartable flat file item writer for Spring Batch.

    Since:
    1.2
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void restoreState​(java.lang.String namespace, java.util.Map<java.lang.String,​java.lang.Object> state)
      Restores a Map of previously stored state information.
      void updateState​(java.lang.String namespace, java.util.Map<java.lang.String,​java.lang.Object> state)
      Updates a Map with the current state of the Writer to allow for restoration at a later time.
    • Method Detail

      • updateState

        void updateState​(java.lang.String namespace,
                         java.util.Map<java.lang.String,​java.lang.Object> state)
        Updates a Map with the current state of the Writer to allow for restoration at a later time.
        Parameters:
        namespace - a String to prefix all state keys with
        state - the Map to update with the latest state
      • restoreState

        void restoreState​(java.lang.String namespace,
                          java.util.Map<java.lang.String,​java.lang.Object> state)
                   throws java.lang.IllegalStateException
        Restores a Map of previously stored state information.
        Parameters:
        namespace - a String to prefix all state keys with
        state - the Map containing the state to restore
        Throws:
        java.lang.IllegalStateException - if the Map is missing any state information