Class ItemListenerSupport<I,O>
- java.lang.Object
- 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 java.lang.Object implements ItemReadListener<I>, ItemProcessListener<I,O>, ItemWriteListener<O>
Basic no-op implementation of theItemReadListener
,ItemProcessListener
, andItemWriteListener
interfaces. All are implemented, since it is very common that all may need to be implemented at once.- Author:
- Lucas Ward, Mahmoud Ben Hassine
Constructor Summary
Constructors Constructor Description ItemListenerSupport()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterProcess(I item, O result)
Called afterItemProcessor.process(Object)
returns.void
afterRead(I item)
Called afterItemReader.read()
.void
afterWrite(java.util.List<? extends O> item)
Called afterItemWriter.write(java.util.List)
This will be called before any transaction is committed, and beforeChunkListener.afterChunk(ChunkContext)
void
beforeProcess(I item)
Called beforeItemProcessor.process(Object)
.void
beforeRead()
Called beforeItemReader.read()
void
beforeWrite(java.util.List<? extends O> item)
Called beforeItemWriter.write(java.util.List)
void
onProcessError(I item, java.lang.Exception e)
Called if an exception was thrown fromItemProcessor.process(Object)
.void
onReadError(java.lang.Exception ex)
Called if an error occurs while trying to read.void
onWriteError(java.lang.Exception ex, java.util.List<? extends O> item)
Called if an error occurs while trying to write.
Method Detail
afterRead
public void afterRead(I item)
Description copied from interface:ItemReadListener
Called afterItemReader.read()
. This method is called only for actual items (ie it is not called when the reader returns null).- Specified by:
afterRead
in interfaceItemReadListener<I>
- Parameters:
item
- returned from read()
beforeRead
public void beforeRead()
Description copied from interface:ItemReadListener
Called beforeItemReader.read()
- Specified by:
beforeRead
in interfaceItemReadListener<I>
onReadError
public void onReadError(java.lang.Exception ex)
Description copied from interface:ItemReadListener
Called if an error occurs while trying to read.- Specified by:
onReadError
in interfaceItemReadListener<I>
- Parameters:
ex
- thrown fromItemWriter
afterProcess
public void afterProcess(I item, @Nullable O result)
Description copied from interface:ItemProcessListener
Called afterItemProcessor.process(Object)
returns. If the processor returnsnull
, this method will still be called, with a {code null} result, allowing for notification of 'filtered' items.- Specified by:
afterProcess
in interfaceItemProcessListener<I,O>
- Parameters:
item
- to be processedresult
- of processing
beforeProcess
public void beforeProcess(I item)
Description copied from interface:ItemProcessListener
Called beforeItemProcessor.process(Object)
.- Specified by:
beforeProcess
in interfaceItemProcessListener<I,O>
- Parameters:
item
- to be processed.
onProcessError
public void onProcessError(I item, java.lang.Exception e)
Description copied from interface:ItemProcessListener
Called if an exception was thrown fromItemProcessor.process(Object)
.- Specified by:
onProcessError
in interfaceItemProcessListener<I,O>
- Parameters:
item
- attempted to be processede
- - exception thrown during processing.
afterWrite
public void afterWrite(java.util.List<? extends O> item)
Description copied from interface:ItemWriteListener
Called afterItemWriter.write(java.util.List)
This will be called before any transaction is committed, and beforeChunkListener.afterChunk(ChunkContext)
- Specified by:
afterWrite
in interfaceItemWriteListener<I>
- Parameters:
item
- written items
beforeWrite
public void beforeWrite(java.util.List<? extends O> item)
Description copied from interface:ItemWriteListener
Called beforeItemWriter.write(java.util.List)
- Specified by:
beforeWrite
in interfaceItemWriteListener<I>
- Parameters:
item
- to be written
onWriteError
public void onWriteError(java.lang.Exception ex, java.util.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 interfaceItemWriteListener<I>
- Parameters:
ex
- thrown fromItemWriter
item
- attempted to be written.