|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.repeat.exception.SimpleLimitExceptionHandler
public class SimpleLimitExceptionHandler
Simple implementation of exception handler which looks for given exception types. If one of the types is found then a counter is incremented and the limit is checked to determine if it has been exceeded and the Throwable should be re-thrown. Also allows to specify list of 'fatal' exceptions that are never subject to counting, but are immediately re-thrown. The fatal list has higher priority so the two lists needn't be exclusive.
| Constructor Summary | |
|---|---|
SimpleLimitExceptionHandler()
Default constructor for the SimpleLimitExceptionHandler. |
|
SimpleLimitExceptionHandler(int limit)
Convenience constructor for the SimpleLimitExceptionHandler to
set the limit. |
|
| Method Summary | |
|---|---|
void |
handleException(RepeatContext context,
Throwable throwable)
Rethrows only if the limit is breached for this context on the exception type specified. |
void |
setExceptionClasses(Class[] classes)
Setter for the Throwable exceptionClasses that this handler counts. |
void |
setFatalExceptionClasses(Class[] fatalExceptionClasses)
Setter for the Throwable exceptionClasses that shouldn't be counted, but rethrown immediately. |
void |
setLimit(int limit)
The limit on the given exception type within a single context before it is rethrown. |
void |
setUseParent(boolean useParent)
Flag to indicate the the exception counters should be shared between sibling contexts in a nested batch (i.e. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleLimitExceptionHandler(int limit)
SimpleLimitExceptionHandler to
set the limit.
public SimpleLimitExceptionHandler()
SimpleLimitExceptionHandler.
| Method Detail |
|---|
public void setUseParent(boolean useParent)
useParent - true if the parent context should be used to store the
counters.
public void handleException(RepeatContext context,
Throwable throwable)
throws 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.
Throwable - implementations are free to re-throw the exceptionsetExceptionClasses(Class[]),
setLimit(int),
ExceptionHandler.handleException(org.springframework.batch.repeat.RepeatContext,
Throwable)public void setLimit(int limit)
limit - public void setExceptionClasses(Class[] classes)
Exception. If more exceptionClasses are specified
handler uses single counter that is incremented when one of the
recognized exception exceptionClasses is handled.
public void setFatalExceptionClasses(Class[] fatalExceptionClasses)
setExceptionClasses(Class[]).
fatalExceptionClasses - defaults to Error
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||