org.springframework.batch.repeat.exception
Class LogOrRethrowExceptionHandler

java.lang.Object
  extended by org.springframework.batch.repeat.exception.LogOrRethrowExceptionHandler
All Implemented Interfaces:
ExceptionHandler

public class LogOrRethrowExceptionHandler
extends Object
implements ExceptionHandler

Implementation of ExceptionHandler based on an Classifier. 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
static class LogOrRethrowExceptionHandler.Level
          Logging levels for the handler.
 
Field Summary
protected  Log logger
           
 
Constructor Summary
LogOrRethrowExceptionHandler()
           
 
Method Summary
 void handleException(RepeatContext context, Throwable throwable)
          Classify the throwables and decide whether to rethrow based on the result.
 void setExceptionClassifier(Classifier<Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
          Setter for the Classifier used by this handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

LogOrRethrowExceptionHandler

public LogOrRethrowExceptionHandler()
Method Detail

setExceptionClassifier

public void setExceptionClassifier(Classifier<Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
Setter for the Classifier used by this handler. The default is to map all throwable instances to LogOrRethrowExceptionHandler.Level.RETHROW.

Parameters:
exceptionClassifier - the ExceptionClassifier to use

handleException

public void handleException(RepeatContext context,
                            Throwable throwable)
                     throws Throwable
Classify the throwables and decide whether to rethrow based on the result. The context is not used.

Specified by:
handleException in interface ExceptionHandler
Parameters:
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.
Throws:
Throwable
See Also:
ExceptionHandler.handleException(RepeatContext, Throwable)


Copyright © 2013 SpringSource. All Rights Reserved.