Example usage for org.springframework.batch.repeat.context RepeatContextCounter increment

List of usage examples for org.springframework.batch.repeat.context RepeatContextCounter increment

Introduction

In this page you can find the example usage for org.springframework.batch.repeat.context RepeatContextCounter increment.

Prototype

final public void increment() 

Source Link

Document

Increment by 1.

Usage

From source file:org.springframework.batch.repeat.exception.RethrowOnThresholdExceptionHandler.java

/**
 * 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.
 * //from  ww w  .j  a  va 2s .c o  m
 * @throws Throwable
 * @see ExceptionHandler#handleException(RepeatContext, Throwable)
 */
@Override
public void handleException(RepeatContext context, Throwable throwable) throws Throwable {

    IntegerHolder key = exceptionClassifier.classify(throwable);

    RepeatContextCounter counter = getCounter(context, key);
    counter.increment();
    int count = counter.getCount();
    int threshold = key.getValue();
    if (count > threshold) {
        throw throwable;
    }

}