Class ChunkMonitor
java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.core.step.item.ChunkMonitor
- All Implemented Interfaces:
ItemStream
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, Mahmoud Ben Hassine, Seungrae Kim
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()If any resources are needed for the stream to operate they need to be destroyed here.intvoidvoidopen(ExecutionContext executionContext) Open the stream for the providedExecutionContext.voidregisterItemStream(ItemStream stream) voidvoidsetChunkSize(int chunkSize) voidsetItemReader(ItemReader<?> reader) voidupdate(ExecutionContext executionContext) Indicates that the execution context provided during open is about to be saved.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setName
-
Constructor Details
-
ChunkMonitor
public ChunkMonitor()
-
-
Method Details
-
registerItemStream
- Parameters:
stream- the stream to set
-
setItemReader
- 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
Description copied from interface:ItemStreamIf any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.- Throws:
ItemStreamException
-
open
Description copied from interface:ItemStreamOpen the stream for the providedExecutionContext.- Parameters:
executionContext- current step'sExecutionContext. Will be the executionContext from the last run of the step on a restart.- Throws:
ItemStreamException
-
update
Description copied from interface:ItemStreamIndicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.- Parameters:
executionContext- to be updated- Throws:
ItemStreamException
-