public class MulticasterBatchListener<T,S> extends java.lang.Object implements StepExecutionListener, ChunkListener, ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>, SkipListener<T,S>, javax.batch.api.chunk.listener.RetryReadListener, javax.batch.api.chunk.listener.RetryProcessListener, javax.batch.api.chunk.listener.RetryWriteListener
ROLLBACK_EXCEPTION_KEY
Constructor and Description |
---|
MulticasterBatchListener()
Initialize the listener instance.
|
Modifier and Type | Method and Description |
---|---|
void |
afterChunk(ChunkContext context)
Callback after the chunk is executed, outside the transaction.
|
void |
afterChunkError(ChunkContext context)
Callback after a chunk has been marked for rollback.
|
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(java.util.List<? extends S> items)
Called after
ItemWriter.write(java.util.List) This will be
called before any transaction is committed, and before
ChunkListener.afterChunk(ChunkContext) |
void |
beforeChunk(ChunkContext context)
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(java.util.List<? extends S> items)
Called before
ItemWriter.write(java.util.List) |
void |
onProcessError(T item,
java.lang.Exception ex)
Called if an exception was thrown from
ItemProcessor.process(Object) . |
void |
onReadError(java.lang.Exception ex)
Called if an error occurs while trying to read.
|
void |
onRetryProcessException(java.lang.Object item,
java.lang.Exception ex) |
void |
onRetryReadException(java.lang.Exception ex) |
void |
onRetryWriteException(java.util.List<java.lang.Object> items,
java.lang.Exception ex) |
void |
onSkipInProcess(T item,
java.lang.Throwable t)
This item failed on processing with the given exception, and a skip was called
for.
|
void |
onSkipInRead(java.lang.Throwable t)
Callback for a failure on read that is legal, so is not going to be
re-thrown.
|
void |
onSkipInWrite(S item,
java.lang.Throwable t)
This item failed on write with the given exception, and a skip was called
for.
|
void |
onWriteError(java.lang.Exception ex,
java.util.List<? extends S> items)
Called if an error occurs while trying to write.
|
void |
register(StepListener listener)
Register the listener for callbacks on the appropriate interfaces
implemented.
|
void |
setListeners(java.util.List<? extends StepListener> listeners)
Register each of the objects as listeners.
|
public MulticasterBatchListener()
public void setListeners(java.util.List<? extends StepListener> listeners)
MulticasterBatchListener
broadcast to the individual listeners.listeners
- listener objects of types known to the multicaster.public void register(StepListener listener)
StepListener
can be provided, or an
ItemStream
. Other types will be ignored.public void afterProcess(T item, S result)
ItemProcessListener
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.afterProcess
in interface ItemProcessListener<T,S>
item
- result
- CompositeItemProcessListener.afterProcess(java.lang.Object,
java.lang.Object)
public void beforeProcess(T item)
ItemProcessListener
ItemProcessor.process(Object)
.beforeProcess
in interface ItemProcessListener<T,S>
item
- CompositeItemProcessListener.beforeProcess(java.lang.Object)
public void onProcessError(T item, java.lang.Exception ex)
ItemProcessListener
ItemProcessor.process(Object)
.onProcessError
in interface ItemProcessListener<T,S>
item
- ex
- CompositeItemProcessListener.onProcessError(java.lang.Object,
java.lang.Exception)
public ExitStatus afterStep(StepExecution stepExecution)
StepExecutionListener
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.afterStep
in interface StepExecutionListener
ExitStatus
to combine with the normal value. Return
null to leave the old value unchanged.CompositeStepExecutionListener.afterStep(StepExecution)
public void beforeStep(StepExecution stepExecution)
StepExecutionListener
StepExecution
from
the current scope.beforeStep
in interface StepExecutionListener
stepExecution
- CompositeStepExecutionListener.beforeStep(org.springframework.batch.core.StepExecution)
public void afterChunk(ChunkContext context)
ChunkListener
afterChunk
in interface ChunkListener
context
- The current ChunkContext
CompositeChunkListener.afterChunk(ChunkContext context)
public void beforeChunk(ChunkContext context)
ChunkListener
beforeChunk
in interface ChunkListener
context
- The current ChunkContext
CompositeChunkListener.beforeChunk(ChunkContext context)
public void afterRead(T item)
ItemReadListener
ItemReader.read()
afterRead
in interface ItemReadListener<T>
item
- CompositeItemReadListener.afterRead(java.lang.Object)
public void beforeRead()
ItemReadListener
ItemReader.read()
beforeRead
in interface ItemReadListener<T>
CompositeItemReadListener.beforeRead()
public void onReadError(java.lang.Exception ex)
ItemReadListener
onReadError
in interface ItemReadListener<T>
ex
- CompositeItemReadListener.onReadError(java.lang.Exception)
public void afterWrite(java.util.List<? extends S> items)
ItemWriteListener
ItemWriter.write(java.util.List)
This will be
called before any transaction is committed, and before
ChunkListener.afterChunk(ChunkContext)
afterWrite
in interface ItemWriteListener<S>
items
- written itemsItemWriteListener.afterWrite(List)
public void beforeWrite(java.util.List<? extends S> items)
ItemWriteListener
ItemWriter.write(java.util.List)
beforeWrite
in interface ItemWriteListener<S>
items
- ItemWriteListener.beforeWrite(List)
public void onWriteError(java.lang.Exception ex, java.util.List<? extends S> items)
ItemWriteListener
onWriteError
in interface ItemWriteListener<S>
ex
- items
- ItemWriteListener.onWriteError(Exception, List)
public void onSkipInRead(java.lang.Throwable t)
SkipListener
onSkipInRead
in interface SkipListener<T,S>
t
- CompositeSkipListener.onSkipInRead(java.lang.Throwable)
public void onSkipInWrite(S item, java.lang.Throwable t)
SkipListener
onSkipInWrite
in interface SkipListener<T,S>
item
- t
- CompositeSkipListener.onSkipInWrite(java.lang.Object,
java.lang.Throwable)
public void onSkipInProcess(T item, java.lang.Throwable t)
SkipListener
onSkipInProcess
in interface SkipListener<T,S>
item
- t
- CompositeSkipListener.onSkipInProcess(Object,
Throwable)
public void afterChunkError(ChunkContext context)
ChunkListener
afterChunkError
in interface ChunkListener
context
- the chunk context containing the exception that caused
the underlying rollback.public void onRetryReadException(java.lang.Exception ex) throws java.lang.Exception
onRetryReadException
in interface javax.batch.api.chunk.listener.RetryReadListener
java.lang.Exception
public void onRetryProcessException(java.lang.Object item, java.lang.Exception ex) throws java.lang.Exception
onRetryProcessException
in interface javax.batch.api.chunk.listener.RetryProcessListener
java.lang.Exception
public void onRetryWriteException(java.util.List<java.lang.Object> items, java.lang.Exception ex) throws java.lang.Exception
onRetryWriteException
in interface javax.batch.api.chunk.listener.RetryWriteListener
java.lang.Exception