Class StagingItemWriter<T>
- java.lang.Object
- org.springframework.dao.support.DaoSupport
- org.springframework.jdbc.core.support.JdbcDaoSupport
- org.springframework.batch.sample.common.StagingItemWriter<T>
- All Implemented Interfaces:
StepExecutionListener
,StepListener
,ItemWriter<T>
,org.springframework.beans.factory.InitializingBean
public class StagingItemWriter<T> extends org.springframework.jdbc.core.support.JdbcDaoSupport implements StepExecutionListener, ItemWriter<T>
DatabaseItemWriter
implementing the process indicator pattern.
Constructor Summary
Constructors Constructor Description StagingItemWriter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.protected void
initDao()
Check mandatory properties.void
setIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer incrementer)
Setter for the key generator for the staging table.void
write(java.util.List<? extends T> items)
Serialize the item to the staging table, and add a NEW processed flag.
Field Detail
NEW
protected static final java.lang.String NEW
- See Also:
- Constant Field Values
DONE
protected static final java.lang.String DONE
- See Also:
- Constant Field Values
Method Detail
initDao
protected void initDao() throws java.lang.Exception
Check mandatory properties.- Overrides:
initDao
in classorg.springframework.dao.support.DaoSupport
- Throws:
java.lang.Exception
- See Also:
DaoSupport.initDao()
setIncrementer
public void setIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer incrementer)
Setter for the key generator for the staging table.- Parameters:
incrementer
- theDataFieldMaxValueIncrementer
to set
write
public void write(java.util.List<? extends T> items)
Serialize the item to the staging table, and add a NEW processed flag.- Specified by:
write
in interfaceItemWriter<T>
- Parameters:
items
- items to be written- See Also:
ItemWriter.write(java.util.List)
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
.