类 RethrowOnThresholdExceptionHandler
- java.lang.Object
- org.springframework.batch.repeat.exception.RethrowOnThresholdExceptionHandler
- 所有已实现的接口:
ExceptionHandler
public class RethrowOnThresholdExceptionHandler extends java.lang.Object implements ExceptionHandler
Implementation ofExceptionHandlerthat rethrows when exceptions of a given type reach a threshold. Requires anClassifierthat maps exception types to unique keys, and also a map from those keys to threshold values (Integer type).- 作者:
- Dave Syer
构造器概要
构造器 构造器 说明 RethrowOnThresholdExceptionHandler()Set up the exception handler.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidhandleException(RepeatContext context, java.lang.Throwable throwable)Classify the throwables and decide whether to re-throw based on the result.voidsetThresholds(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.voidsetUseParent(boolean useParent)Flag to indicate the the exception counters should be shared between sibling contexts in a nested batch.
构造器详细资料
RethrowOnThresholdExceptionHandler
public RethrowOnThresholdExceptionHandler()
Set up the exception handler. Creates a default exception handler and threshold that maps all exceptions to a threshold of 0 - all exceptions are rethrown by default.
方法详细资料
setUseParent
public void setUseParent(boolean useParent)
Flag to indicate the the exception counters should be shared between sibling contexts in a nested batch. Default is false.- 参数:
useParent- true if the parent context should be used to store the counters.
setThresholds
public 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.- 参数:
thresholds- the threshold value map.
handleException
public void handleException(RepeatContext context, java.lang.Throwable throwable) throws java.lang.Throwable
Classify the throwables and decide whether to re-throw based on the result. The context is used to accumulate the number of exceptions of the same type according to the classifier.- 指定者:
handleException在接口中ExceptionHandler- 参数:
context- the currentRepeatContext. 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)