org.springframework.batch.jsr.item

## Class CheckpointSupport

- java.lang.Object
- - org.springframework.batch.item.ItemStreamSupport
  - - org.springframework.batch.jsr.item.CheckpointSupport

- All Implemented Interfaces:
    ItemStream
  Direct Known Subclasses:
    ItemReaderAdapter, ItemWriterAdapter

      public abstract class CheckpointSupport
      extends ItemStreamSupport

  Provides support for JSR-352 checkpointing. Checkpoint objects are copied prior to being added to the `ExecutionContext` for persistence by the framework. If the checkpoint object cannot be copied and further changes occur to the same instance, side effects may occur. In cases like this, it is recommended that a copy of the object being acted upon in the reader/writer is returned via the `ItemReader.checkpointInfo()` or `ItemWriter.checkpointInfo()` calls.
  Since:
    3.0
  Author:
    Michael Minella

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CheckpointSupport(java.lang.String checkpointKey)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` No-op.
    `protected abstract java.io.Serializable` | `doCheckpoint()` Used to provide a `Serializable` representing the current state of the batch artifact.
    `protected abstract void` | `doClose()` Used to close the underlying batch artifact
    `protected abstract void` | `doOpen(java.io.Serializable checkpoint)` Used to open a batch artifact with previously saved checkpoint information.
    `void` | `open(ExecutionContext executionContext)` No-op.
    `void` | `update(ExecutionContext executionContext)` Return empty `ExecutionContext`.

    - ### Methods inherited from class org.springframework.batch.item.ItemStreamSupport

      `getExecutionContextKey, setExecutionContextName, setName`

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

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

- - ### Constructor Detail

    - #### CheckpointSupport

          public CheckpointSupport(java.lang.String checkpointKey)

      Parameters:
        `checkpointKey` - key to store the checkpoint object with in the `ExecutionContext`

  - ### Method Detail

    - #### open

          public void open(ExecutionContext executionContext)
                    throws ItemStreamException

      Description copied from class: `ItemStreamSupport`
      No-op.
      Specified by:
        `open` in interface `ItemStream`
      Overrides:
        `open` in class `ItemStreamSupport`
      Parameters:
        `executionContext` - current step's `ExecutionContext`. Will be the executionContext from the last run of the step on a restart.
      Throws:
        `ItemStreamException`
      See Also:
        `ItemStream.open(ExecutionContext)`

    - #### doOpen

          protected abstract void doOpen(java.io.Serializable checkpoint)
                                  throws java.lang.Exception

      Used to open a batch artifact with previously saved checkpoint information.
      Parameters:
        `checkpoint` - previously saved checkpoint object
      Throws:
        `java.lang.Exception` - thrown by the implementation

    - #### update

          public void update(ExecutionContext executionContext)
                      throws ItemStreamException

      Description copied from class: `ItemStreamSupport`
      Return empty `ExecutionContext`.
      Specified by:
        `update` in interface `ItemStream`
      Overrides:
        `update` in class `ItemStreamSupport`
      Parameters:
        `executionContext` - to be updated
      Throws:
        `ItemStreamException`
      See Also:
        `ItemStream.update(ExecutionContext)`

    - #### doCheckpoint

          protected abstract java.io.Serializable doCheckpoint()
                                                        throws java.lang.Exception

      Used to provide a `Serializable` representing the current state of the batch artifact.
      Returns:
        the current state of the batch artifact
      Throws:
        `java.lang.Exception` - thrown by the implementation

    - #### close

          public void close()
                     throws ItemStreamException

      Description copied from class: `ItemStreamSupport`
      No-op.
      Specified by:
        `close` in interface `ItemStream`
      Overrides:
        `close` in class `ItemStreamSupport`
      Throws:
        `ItemStreamException`
      See Also:
        `ItemStream.close()`

    - #### doClose

          protected abstract void doClose()
                                   throws java.lang.Exception

      Used to close the underlying batch artifact
      Throws:
        `java.lang.Exception` - thrown by the underlying implementation