public class RethrowOnThresholdExceptionHandler extends java.lang.Object implements ExceptionHandler
ExceptionHandler that rethrows when exceptions of a
given type reach a threshold. Requires an Classifier that maps
exception types to unique keys, and also a map from those keys to threshold
values (Integer type).| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
protected static org.springframework.batch.repeat.exception.RethrowOnThresholdExceptionHandler.IntegerHolder |
ZERO |
| Constructor and Description |
|---|
RethrowOnThresholdExceptionHandler()
Set up the exception handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
handleException(RepeatContext context,
java.lang.Throwable throwable)
Classify the throwables and decide whether to re-throw based on the
result.
|
void |
setThresholds(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.Integer> thresholds)
A map from exception classes 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.
|
protected static final org.springframework.batch.repeat.exception.RethrowOnThresholdExceptionHandler.IntegerHolder ZERO
protected final org.apache.commons.logging.Log logger
public RethrowOnThresholdExceptionHandler()
public void setUseParent(boolean useParent)
useParent - true if the parent context should be used to store the
counters.public void setThresholds(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.Integer> thresholds)
thresholds - the threshold value map.public void handleException(RepeatContext context, java.lang.Throwable throwable) throws java.lang.Throwable
handleException in interface ExceptionHandlercontext - 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.java.lang.Throwable - is thrown if number of exceptions exceeds threshold.ExceptionHandler.handleException(RepeatContext, Throwable)