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 aThreadLocal
to manage the state and coordinate between the caller and the wrappedItemStream
.- 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
All Methods Instance Methods Concrete Methods 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 emptyExecutionContext
.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, setExecutionContextName, setName
Method Detail
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 interfaceItemStream
- Overrides:
close
in classItemStreamSupport
- 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 interfaceItemStream
- Overrides:
open
in classItemStreamSupport
- Parameters:
executionContext
- current step'sExecutionContext
. 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 emptyExecutionContext
.- Specified by:
update
in interfaceItemStream
- Overrides:
update
in classItemStreamSupport
- Parameters:
executionContext
- to be updated- Throws:
ItemStreamException
- See Also:
ItemStream.update(ExecutionContext)