org.springframework.batch.sample.common
Class StagingItemReader<T>

java.lang.Object
  extended by org.springframework.batch.sample.common.StagingItemReader<T>
All Implemented Interfaces:
StepExecutionListener, StepListener, ItemReader<ProcessIndicatorItemWrapper<T>>, DisposableBean, InitializingBean

public class StagingItemReader<T>
extends Object
implements ItemReader<ProcessIndicatorItemWrapper<T>>, StepExecutionListener, InitializingBean, DisposableBean

Thread-safe database ItemReader implementing the process indicator pattern. To achieve restartability use together with StagingItemProcessor.


Constructor Summary
StagingItemReader()
           
 
Method Summary
 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 the StepExecution from the current scope.
 void destroy()
           
 ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e)
           
 ProcessIndicatorItemWrapper<T> read()
          Reads a piece of input data and advance to the next one.
 void setDataSource(DataSource dataSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StagingItemReader

public StagingItemReader()
Method Detail

setDataSource

public void setDataSource(DataSource dataSource)

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

afterPropertiesSet

public final void afterPropertiesSet()
                              throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

read

public ProcessIndicatorItemWrapper<T> read()
                                    throws DataAccessException
Description copied from interface: ItemReader
Reads a piece of input data and advance to the next one. Implementations must return null 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 interface ItemReader<ProcessIndicatorItemWrapper<T>>
Throws:
DataAccessException

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 using ExitStatus.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 interface StepExecutionListener
Returns:
an ExitStatus to combine with the normal value. Return null to leave the old value unchanged.

beforeStep

public void beforeStep(StepExecution stepExecution)
Description copied from interface: StepExecutionListener
Initialize the state of the listener with the StepExecution from the current scope.

Specified by:
beforeStep in interface StepExecutionListener

onErrorInStep

public ExitStatus onErrorInStep(StepExecution stepExecution,
                                Throwable e)


Copyright © 2009 SpringSource. All Rights Reserved.