org.springframework.batch.core.listener
Class StepListenerSupport

java.lang.Object
  extended by org.springframework.batch.core.listener.StepListenerSupport
All Implemented Interfaces:
ChunkListener, ItemReadListener, ItemWriteListener, StepExecutionListener, StepListener

public class StepListenerSupport
extends Object
implements StepExecutionListener, ChunkListener, ItemReadListener, ItemWriteListener

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 afterRead(Object item)
          Called after ItemReader.read()
 ExitStatus afterStep(StepExecution stepExecution)
          Give a listener a chance to modify the exit status from a step.
 void afterWrite(Object item)
          Called after ItemWriter.write(Object) If the item is last in a chunk, 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 beforeRead()
          Called before ItemReader.read()
 void beforeStep(StepExecution stepExecution)
          Initialise the state of the listener with the StepExecution from the current scope.
 void beforeWrite(Object item)
          Called before ItemWriter.write(Object)
 ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e)
          The value returned will be combined with the normal exit status using ExitStatus.and(ExitStatus).
 void onReadError(Exception ex)
          Called if an error occurs while trying to read.
 void onWriteError(Exception ex, Object 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

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 successful execution of step's processing logic. Throwing exception in this method will cause step to fail.

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
Initialise 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)
Description copied from interface: StepExecutionListener
The value returned will be combined with the normal exit status using ExitStatus.and(ExitStatus).

Specified by:
onErrorInStep in interface StepExecutionListener
e - an exception thrown by the step execution
Returns:
an exit status to be combined with the normal one, or null

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(Object item)
Description copied from interface: ItemReadListener
Called after ItemReader.read()

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

beforeRead

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

Specified by:
beforeRead in interface ItemReadListener

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

afterWrite

public void afterWrite(Object item)
Description copied from interface: ItemWriteListener
Called after ItemWriter.write(Object) If the item is last in a chunk, this will be called before any transaction is committed, and before ChunkListener.afterChunk()

Specified by:
afterWrite in interface ItemWriteListener
Parameters:
item - written item

beforeWrite

public void beforeWrite(Object item)
Description copied from interface: ItemWriteListener
Called before ItemWriter.write(Object)

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

onWriteError

public void onWriteError(Exception ex,
                         Object item)
Description copied from interface: ItemWriteListener
Called if an error occurs while trying to write.

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


Copyright © 2009 SpringSource. All Rights Reserved.