Interface ItemWriter

  • All Known Implementing Classes:
    AbstractItemWriter


    public interface ItemWriter
    ItemWriter defines the batch artifact that writes to a list of items for chunk processing.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.io.Serializable checkpointInfo​()
      The checkpointInfo method returns the current checkpoint data for this writer.
      void close​()
      The close method marks the end of use of the ItemWriter.
      void open​(java.io.Serializable checkpoint)
      The open method prepares the writer to write items.
      void writeItems​(java.util.List<java.lang.Object> items)
      The writeItems method writes a list of item for the current chunk.
    • Method Detail

      • open

        void open​(java.io.Serializable checkpoint)
           throws java.lang.Exception
        The open method prepares the writer to write items. The input parameter represents the last checkpoint for this writer in a given job instance. The checkpoint data is defined by this writer and is provided by the checkpointInfo method. The checkpoint data provides the writer whatever information it needs to resume writing items upon restart. A checkpoint value of null is passed upon initial start.
        Parameters:
        checkpoint - specifies the last checkpoint
        Throws:
        java.lang.Exception - is thrown for any errors.
      • close

        void close​()
            throws java.lang.Exception
        The close method marks the end of use of the ItemWriter. The writer is free to do any cleanup necessary.
        Throws:
        java.lang.Exception - is thrown for any errors.
      • writeItems

        void writeItems​(java.util.List<java.lang.Object> items)
                 throws java.lang.Exception
        The writeItems method writes a list of item for the current chunk.
        Parameters:
        items - specifies the list of items to write. This may be an empty list (e.g. if all the items have been filtered out by the ItemProcessor).
        Throws:
        java.lang.Exception - is thrown for any errors.
      • checkpointInfo

        java.io.Serializable checkpointInfo​()
                                     throws java.lang.Exception
        The checkpointInfo method returns the current checkpoint data for this writer. It is called before a chunk checkpoint is committed.
        Returns:
        checkpoint data
        Throws:
        java.lang.Exception - is thrown for any errors.