Class LogOrRethrowExceptionHandler
- java.lang.Object
- org.springframework.batch.repeat.exception.LogOrRethrowExceptionHandler
- All Implemented Interfaces:
ExceptionHandler
public class LogOrRethrowExceptionHandler extends java.lang.Object implements ExceptionHandler
Implementation ofExceptionHandler
based on anClassifier
. The classifier determines whether to log the exception or rethrow it. The keys in the classifier must be the same as the static enum in this class.- Author:
- Dave Syer
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LogOrRethrowExceptionHandler.Level
Logging levels for the handler.
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
logger
Constructor Summary
Constructors Constructor Description LogOrRethrowExceptionHandler()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handleException(RepeatContext context, java.lang.Throwable throwable)
Classify the throwables and decide whether to rethrow based on the result.void
setExceptionClassifier(org.springframework.classify.Classifier<java.lang.Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
Setter for theClassifier
used by this handler.
Method Detail
setExceptionClassifier
public void setExceptionClassifier(org.springframework.classify.Classifier<java.lang.Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
Setter for theClassifier
used by this handler. The default is to map all throwable instances toLogOrRethrowExceptionHandler.Level.RETHROW
.- Parameters:
exceptionClassifier
- the ExceptionClassifier to use
handleException
public void handleException(RepeatContext context, java.lang.Throwable throwable) throws java.lang.Throwable
Classify the throwables and decide whether to rethrow based on the result. The context is not used.- Specified by:
handleException
in interfaceExceptionHandler
- Parameters:
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.- Throws:
java.lang.Throwable
- thrown ifexceptionClassifier
is classified asLogOrRethrowExceptionHandler.Level.RETHROW
.- See Also:
ExceptionHandler.handleException(RepeatContext, Throwable)