org.springframework.batch.core.listener
Class ItemListenerSupport<I,O>

java.lang.Object
  extended by org.springframework.batch.core.listener.ItemListenerSupport<I,O>
All Implemented Interfaces:
ItemProcessListener<I,O>, ItemReadListener<I>, ItemWriteListener<O>, StepListener
Direct Known Subclasses:
DefaultItemFailureHandler

public class ItemListenerSupport<I,O>
extends Object
implements ItemReadListener<I>, ItemProcessListener<I,O>, ItemWriteListener<O>

Basic no-op implementation of the ItemReadListener, ItemProcessListener, and ItemWriteListener interfaces. All are implemented, since it is very common that all may need to be implemented at once.

Author:
Lucas Ward

Constructor Summary
ItemListenerSupport()
           
 
Method Summary
 void afterProcess(I item, O result)
          Called after ItemProcessor.process(Object) returns.
 void afterRead(I item)
          Called after ItemReader.read()
 void afterWrite(List<? extends O> item)
          Called after ItemWriter.write(java.util.List) This will be called before any transaction is committed, and before ChunkListener.afterChunk()
 void beforeProcess(I item)
          Called before ItemProcessor.process(Object).
 void beforeRead()
          Called before ItemReader.read()
 void beforeWrite(List<? extends O> item)
          Called before ItemWriter.write(java.util.List)
 void onProcessError(I item, Exception e)
          Called if an exception was thrown from ItemProcessor.process(Object).
 void onReadError(Exception ex)
          Called if an error occurs while trying to read.
 void onWriteError(Exception ex, List<? extends O> item)
          Called if an error occurs while trying to write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemListenerSupport

public ItemListenerSupport()
Method Detail

afterRead

public void afterRead(I item)
Description copied from interface: ItemReadListener
Called after ItemReader.read()

Specified by:
afterRead in interface ItemReadListener<I>
Parameters:
item - returned from read()

beforeRead

public void beforeRead()
Description copied from interface: ItemReadListener
Called before ItemReader.read()

Specified by:
beforeRead in interface ItemReadListener<I>

onReadError

public void onReadError(Exception ex)
Description copied from interface: ItemReadListener
Called if an error occurs while trying to read.

Specified by:
onReadError in interface ItemReadListener<I>
Parameters:
ex - thrown from ItemWriter

afterProcess

public void afterProcess(I item,
                         O result)
Description copied from interface: ItemProcessListener
Called after ItemProcessor.process(Object) returns. If the processor returns null, this method will still be called, with a null result, allowing for notification of 'filtered' items.

Specified by:
afterProcess in interface ItemProcessListener<I,O>
Parameters:
item - to be processed
result - of processing

beforeProcess

public void beforeProcess(I item)
Description copied from interface: ItemProcessListener
Called before ItemProcessor.process(Object).

Specified by:
beforeProcess in interface ItemProcessListener<I,O>
Parameters:
item - to be processed.

onProcessError

public void onProcessError(I item,
                           Exception e)
Description copied from interface: ItemProcessListener
Called if an exception was thrown from ItemProcessor.process(Object).

Specified by:
onProcessError in interface ItemProcessListener<I,O>
Parameters:
item - attempted to be processed
e - - exception thrown during processing.

afterWrite

public void afterWrite(List<? extends O> item)
Description copied from interface: ItemWriteListener
Called after ItemWriter.write(java.util.List) This will be called before any transaction is committed, and before ChunkListener.afterChunk()

Specified by:
afterWrite in interface ItemWriteListener<O>
Parameters:
item - written items

beforeWrite

public void beforeWrite(List<? extends O> item)
Description copied from interface: ItemWriteListener
Called before ItemWriter.write(java.util.List)

Specified by:
beforeWrite in interface ItemWriteListener<O>
Parameters:
item - to be written

onWriteError

public void onWriteError(Exception ex,
                         List<? extends O> item)
Description copied from interface: ItemWriteListener
Called if an error occurs while trying to write. Will be called inside a transaction, but the transaction will normally be rolled back. There is no way to identify from this callback which of the items (if any) caused the error.

Specified by:
onWriteError in interface ItemWriteListener<O>
Parameters:
ex - thrown from ItemWriter
item - attempted to be written.


Copyright © 2013 SpringSource. All Rights Reserved.