Class StagingItemReader<T>
- java.lang.Object
- org.springframework.batch.sample.common.StagingItemReader<T>
- All Implemented Interfaces:
StepExecutionListener
,StepListener
,ItemReader<ProcessIndicatorItemWrapper<T>>
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
public class StagingItemReader<T> extends java.lang.Object implements ItemReader<ProcessIndicatorItemWrapper<T>>, StepExecutionListener, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Thread-safe databaseItemReader
implementing the process indicator pattern. To achieve restartability use together withStagingItemProcessor
.
Constructor Summary
Constructors Constructor Description StagingItemReader()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
ExitStatus
afterStep(StepExecution stepExecution)
Give a listener a chance to modify the exit status from a step.void
beforeStep(StepExecution stepExecution)
Initialize the state of the listener with theStepExecution
from the current scope.void
destroy()
ProcessIndicatorItemWrapper<T>
read()
Reads a piece of input data and advance to the next one.void
setDataSource(javax.sql.DataSource dataSource)
Method Detail
setDataSource
public void setDataSource(javax.sql.DataSource dataSource)
destroy
public void destroy() throws java.lang.Exception
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
java.lang.Exception
afterPropertiesSet
public final void afterPropertiesSet() throws java.lang.Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
java.lang.Exception
read
public ProcessIndicatorItemWrapper<T> read()
Description copied from interface:ItemReader
Reads a piece of input data and advance to the next one. Implementations must returnnull
at the end of the input data set. In a transactional setting, caller might get the same item twice from successive calls (or otherwise), if the first call was in a transaction that rolled back.- Specified by:
read
in interfaceItemReader<T>
- Returns:
- T the item to be processed or
null
if the data source is exhausted
afterStep
public ExitStatus afterStep(StepExecution stepExecution)
Description copied from interface:StepExecutionListener
Give a listener a chance to modify the exit status from a step. The value returned will be combined with the normal exit status usingExitStatus.and(ExitStatus)
. Called after execution of step's processing logic (both successful or failed). Throwing exception in this method has no effect, it will only be logged.- Specified by:
afterStep
in interfaceStepExecutionListener
- Parameters:
stepExecution
-StepExecution
instance.- Returns:
- an
ExitStatus
to combine with the normal value. Returnnull
to leave the old value unchanged.
beforeStep
public void beforeStep(StepExecution stepExecution)
Description copied from interface:StepExecutionListener
Initialize the state of the listener with theStepExecution
from the current scope.- Specified by:
beforeStep
in interfaceStepExecutionListener
- Parameters:
stepExecution
- instance ofStepExecution
.