org.springframework.batch.core.listener
Class StepListenerSupport<T,S>

java.lang.Object
  extended by org.springframework.batch.core.listener.StepListenerSupport<T,S>
All Implemented Interfaces:
ChunkListener, ItemProcessListener<T,S>, ItemReadListener<T>, ItemWriteListener<S>, StepExecutionListener, StepListener
Direct Known Subclasses:
StagingItemListener

public class StepListenerSupport<T,S>
extends Object
implements StepExecutionListener, ChunkListener, ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>

Basic no-op implementations of all StepListener implementations.

Author:
Lucas Ward

Constructor Summary
StepListenerSupport()
           
 
Method Summary
 void afterChunk()
          Callback after the chunk is executed, but inside the transaction.
 void afterProcess(T item, S result)
          Called after ItemProcessor.process(Object) returns.
 void afterRead(T item)
          Called after ItemReader.read()
 ExitStatus afterStep(StepExecution stepExecution)
          Give a listener a chance to modify the exit status from a step.
 void afterWrite(List<? extends S> items)
          Called after ItemWriter.write(java.util.List) This will be called before any transaction is committed, and before ChunkListener.afterChunk()
 void beforeChunk()
          Callback before the chunk is executed, but inside the transaction.
 void beforeProcess(T item)
          Called before ItemProcessor.process(Object).
 void beforeRead()
          Called before ItemReader.read()
 void beforeStep(StepExecution stepExecution)
          Initialize the state of the listener with the StepExecution from the current scope.
 void beforeWrite(List<? extends S> items)
          Called before ItemWriter.write(java.util.List)
 ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e)
           
 void onProcessError(T 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 exception, List<? extends S> items)
          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

StepListenerSupport

public StepListenerSupport()
Method Detail

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)

afterChunk

public void afterChunk()
Description copied from interface: ChunkListener
Callback after the chunk is executed, but inside the transaction.

Specified by:
afterChunk in interface ChunkListener

beforeChunk

public void beforeChunk()
Description copied from interface: ChunkListener
Callback before the chunk is executed, but inside the transaction.

Specified by:
beforeChunk in interface ChunkListener

afterRead

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

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

beforeRead

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

Specified by:
beforeRead in interface ItemReadListener<T>

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<T>
Parameters:
ex - thrown from ItemWriter

afterWrite

public void afterWrite(List<? extends S> items)
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<S>
Parameters:
items - written items

beforeWrite

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

Specified by:
beforeWrite in interface ItemWriteListener<S>
Parameters:
items - to be written

onWriteError

public void onWriteError(Exception exception,
                         List<? extends S> items)
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<S>
Parameters:
exception - thrown from ItemWriter
items - attempted to be written.

afterProcess

public void afterProcess(T item,
                         S 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<T,S>
Parameters:
item - to be processed
result - of processing

beforeProcess

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

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

onProcessError

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

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


Copyright © 2009 SpringSource. All Rights Reserved.