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

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.jdbc.core.support.JdbcDaoSupport
          extended by org.springframework.batch.sample.common.StagingItemWriter<T>
All Implemented Interfaces:
StepExecutionListener, StepListener, ItemWriter<T>, InitializingBean

public class StagingItemWriter<T>
extends JdbcDaoSupport
implements StepExecutionListener, ItemWriter<T>

Database ItemWriter implementing the process indicator pattern.


Field Summary
static String DONE
           
static String NEW
           
static Object WORKING
           
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
StagingItemWriter()
           
 
Method Summary
 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.
protected  void initDao()
          Check mandatory properties.
 ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e)
           
 void setIncrementer(DataFieldMaxValueIncrementer incrementer)
          Setter for the key generator for the staging table.
 void write(List<? extends T> items)
          Serialize the item to the staging table, and add a NEW processed flag.
 
Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport
checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW

public static final String NEW
See Also:
Constant Field Values

DONE

public static final String DONE
See Also:
Constant Field Values

WORKING

public static final Object WORKING
Constructor Detail

StagingItemWriter

public StagingItemWriter()
Method Detail

initDao

protected void initDao()
                throws Exception
Check mandatory properties.

Overrides:
initDao in class DaoSupport
Throws:
Exception
See Also:
DaoSupport.initDao()

setIncrementer

public void setIncrementer(DataFieldMaxValueIncrementer incrementer)
Setter for the key generator for the staging table.

Parameters:
incrementer - the DataFieldMaxValueIncrementer to set

write

public void write(List<? extends T> items)
Serialize the item to the staging table, and add a NEW processed flag.

Specified by:
write in interface ItemWriter<T>
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 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.