Class CompositeRepeatListener
java.lang.Object
org.springframework.batch.repeat.listener.CompositeRepeatListener
- All Implemented Interfaces:
RepeatListener
Allows a user to register one or more RepeatListeners to be notified on batch events.
- Author:
- Dave Syer
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorCompositeRepeatListener(List<RepeatListener> listeners) Convenience constructor for setting theRepeatListeners.CompositeRepeatListener(RepeatListener... listeners) Convenience constructor for setting theRepeatListeners. -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(RepeatContext context, RepeatStatus result) Called by the framework after each item has been processed, unless the item processing results in an exception.voidbefore(RepeatContext context) Called by the framework before each batch item.voidclose(RepeatContext context) Called once at the end of a complete batch, after normal or abnormal completion (i.e. even after an exception).voidonError(RepeatContext context, Throwable e) Called when a repeat callback fails by throwing an exception.voidopen(RepeatContext context) Called once at the start of a complete batch, before any items are processed.voidregister(RepeatListener listener) Register additional listener.voidsetListeners(List<RepeatListener> listeners) Public setter for the listeners.voidsetListeners(RepeatListener[] listeners) Public setter for the listeners.
-
Constructor Details
-
CompositeRepeatListener
public CompositeRepeatListener()Default constructor -
CompositeRepeatListener
Convenience constructor for setting theRepeatListeners.- Parameters:
listeners-Listof RepeatListeners to be used by the CompositeRepeatListener.
-
CompositeRepeatListener
Convenience constructor for setting theRepeatListeners.- Parameters:
listeners- array of RepeatListeners to be used by the CompositeRepeatListener.
-
-
Method Details
-
setListeners
Public setter for the listeners.- Parameters:
listeners-Listof RepeatListeners to be used by the CompositeRepeatListener.
-
setListeners
Public setter for the listeners.- Parameters:
listeners- array of RepeatListeners to be used by the CompositeRepeatListener.
-
register
Register additional listener.- Parameters:
listener- the RepeatListener to be added to the list of listeners to be notified.
-
after
Description copied from interface:RepeatListenerCalled by the framework after each item has been processed, unless the item processing results in an exception. This method is called as soon as the result is known.- Specified by:
afterin interfaceRepeatListener- Parameters:
context- the current batch contextresult- the result of the callback
-
before
Description copied from interface:RepeatListenerCalled by the framework before each batch item. Implementers can halt a batch by setting the complete flag on the context.- Specified by:
beforein interfaceRepeatListener- Parameters:
context- the current batch context.
-
close
Description copied from interface:RepeatListenerCalled once at the end of a complete batch, after normal or abnormal completion (i.e. even after an exception). Implementers can use this method to clean up any resources.- Specified by:
closein interfaceRepeatListener- Parameters:
context- the current batch context.
-
onError
Description copied from interface:RepeatListenerCalled when a repeat callback fails by throwing an exception. There will be one call to this method for each exception thrown during a repeat operation (e.g. a chunk).
There is no need to re-throw the exception here - that will be done by the enclosing framework.- Specified by:
onErrorin interfaceRepeatListener- Parameters:
context- the current batch contexte- the error that was encountered in an item callback.
-
open
Description copied from interface:RepeatListenerCalled once at the start of a complete batch, before any items are processed. Implementers can use this method to acquire any resources that might be needed during processing. Implementers can halt the current operation by setting the complete flag on the context. To halt all enclosing batches (the whole job), the would need to use the parent context (recursively).- Specified by:
openin interfaceRepeatListener- Parameters:
context- the current batch context
-