org.springframework.batch.core.step.item
Class SimpleItemHandler

java.lang.Object
  extended by org.springframework.batch.core.step.item.SimpleItemHandler
All Implemented Interfaces:
ItemHandler
Direct Known Subclasses:
ItemSkipPolicyItemHandler

public class SimpleItemHandler
extends Object
implements ItemHandler

Simplest possible implementation of ItemHandler with no skipping or recovering. Just delegates all calls to the provided ItemReader and ItemWriter. Provides extension points by protected read(StepContribution) and write(Object, StepContribution) methods that can be overriden to provide more sophisticated behavior (e.g. skipping).

Author:
Dave Syer, Robert Kasanicky

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
SimpleItemHandler(ItemReader itemReader, ItemWriter itemWriter)
           
 
Method Summary
 void clear()
          Implementations should delegate to an ItemWriter.
protected  Object doRead()
           
protected  void doWrite(Object item)
           
 void flush()
          Implementations should delegate to an ItemWriter.
 ExitStatus handle(StepContribution contribution)
          Get the next item from read(StepContribution) and if not null pass the item to write(Object, StepContribution).
 void mark()
          Implementations should delegate to an ItemReader.
protected  Object read(StepContribution contribution)
           
 void reset()
          Implementations should delegate to an ItemReader.
protected  void write(Object item, StepContribution contribution)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

SimpleItemHandler

public SimpleItemHandler(ItemReader itemReader,
                         ItemWriter itemWriter)
Parameters:
itemReader -
itemWriter -
Method Detail

handle

public ExitStatus handle(StepContribution contribution)
                  throws Exception
Get the next item from read(StepContribution) and if not null pass the item to write(Object, StepContribution).

Specified by:
handle in interface ItemHandler
Parameters:
contribution - the current step context
Returns:
an ExitStatus indicating whether processing is continuable.
Throws:
Exception
See Also:
ItemHandler.handle(org.springframework.batch.core.StepContribution)

read

protected Object read(StepContribution contribution)
               throws Exception
Parameters:
contribution - current context
Returns:
next item for writing
Throws:
Exception

doRead

protected final Object doRead()
                       throws Exception
Returns:
item
Throws:
Exception

write

protected void write(Object item,
                     StepContribution contribution)
              throws Exception
Parameters:
item - the item to write
contribution - current context
Throws:
Exception

doWrite

protected final void doWrite(Object item)
                      throws Exception
Parameters:
item -
Throws:
Exception

mark

public void mark()
          throws MarkFailedException
Description copied from interface: ItemHandler
Implementations should delegate to an ItemReader.

Specified by:
mark in interface ItemHandler
Throws:
MarkFailedException
See Also:
ItemReader.mark()

reset

public void reset()
           throws ResetFailedException
Description copied from interface: ItemHandler
Implementations should delegate to an ItemReader.

Specified by:
reset in interface ItemHandler
Throws:
ResetFailedException
See Also:
ItemReader.reset()

clear

public void clear()
           throws ClearFailedException
Description copied from interface: ItemHandler
Implementations should delegate to an ItemWriter.

Specified by:
clear in interface ItemHandler
Throws:
ClearFailedException
See Also:
ItemWriter.clear()

flush

public void flush()
           throws FlushFailedException
Description copied from interface: ItemHandler
Implementations should delegate to an ItemWriter.

Specified by:
flush in interface ItemHandler
Throws:
FlushFailedException
See Also:
ItemWriter.flush()


Copyright © 2009 SpringSource. All Rights Reserved.