Package org.springframework.batch.core.step.item

# Class ChunkMonitor

java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.core.step.item.ChunkMonitor

All Implemented Interfaces:
  `ItemStream`

public class ChunkMonitor extends ItemStreamSupport
Manage the offset data between the last successful commit and updates made to an input chunk. Only works with single threaded steps because it has to use a `ThreadLocal` to manage the state and coordinate between the caller and the wrapped `ItemStream`.

Since:
  2.0
Author:
  Dave Syer

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `ChunkMonitor.ChunkMonitorData`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChunkMonitor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  No-op.
  `int`
  `getOffset()`
  `void`
  `incrementOffset()`
  `void`
  `open(ExecutionContext executionContext)`
  No-op.
  `void`
  `registerItemStream(ItemStream stream)`
  `void`
  `resetOffset()`
  `void`
  `setChunkSize(int chunkSize)`
  `void`
  `setItemReader(ItemReader<?> reader)`
  `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 Details

  - ### ChunkMonitor

    public ChunkMonitor()

- ## Method Details

  - ### registerItemStream

    public void registerItemStream(ItemStream stream)
    Parameters:
      `stream` - the stream to set

  - ### setItemReader

    public void setItemReader(ItemReader<?> reader)
    Parameters:
      `reader` - the reader to set

  - ### incrementOffset

    public void incrementOffset()

  - ### getOffset

    public int getOffset()

  - ### resetOffset

    public void resetOffset()

  - ### setChunkSize

    public void setChunkSize(int chunkSize)

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

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

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