|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.batch.repeat.exception.RethrowOnThresholdExceptionHandler
public class RethrowOnThresholdExceptionHandler
Implementation of ExceptionHandler
that rethrows when exceptions of a
given type reach a threshold. Requires an ExceptionClassifier
that
maps exception types to unique keys, and also a map from those keys to
threshold values (Integer type).
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
RethrowOnThresholdExceptionHandler()
Set up the exception handler. |
Method Summary | |
---|---|
void |
handleException(RepeatContext context,
Throwable throwable)
Classify the throwables and decide whether to re-throw based on the result. |
void |
setExceptionClassifier(ExceptionClassifier exceptionClassifier)
Setter for the ExceptionClassifier used by this handler. |
void |
setThresholds(Map thresholds)
A map from classifier keys to a threshold value of type Integer. |
void |
setUseParent(boolean useParent)
Flag to indicate the the exception counters should be shared between sibling contexts in a nested batch. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public RethrowOnThresholdExceptionHandler()
Method Detail |
---|
public void setUseParent(boolean useParent)
useParent
- true if the parent context should be used to store the
counters.public void setThresholds(Map thresholds)
ExceptionClassifier
implementation used.
thresholds
- the threshold value map.public void setExceptionClassifier(ExceptionClassifier exceptionClassifier)
ExceptionClassifier
used by this handler. The
default is to map all throwable instances to
ExceptionClassifierSupport.DEFAULT
, which are then mapped to a
threshold of 0 by the setThresholds(Map)
map.
exceptionClassifier
- public void handleException(RepeatContext context, Throwable throwable) throws Throwable
handleException
in interface ExceptionHandler
context
- the current RepeatContext
. Can be used to store
state (via attributes), for example to count the number of occurrences of
a particular exception type and implement a threshold policy.throwable
- an exception.
Throwable
ExceptionHandler.handleException(RepeatContext, Throwable)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |