public class SimpleLimitExceptionHandler extends java.lang.Object implements ExceptionHandler, org.springframework.beans.factory.InitializingBean
Constructor and Description |
---|
SimpleLimitExceptionHandler()
Default constructor for the
SimpleLimitExceptionHandler . |
SimpleLimitExceptionHandler(int limit)
Convenience constructor for the
SimpleLimitExceptionHandler to
set the limit. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Apply the provided properties to create a delegate handler.
|
void |
handleException(RepeatContext context,
java.lang.Throwable throwable)
Rethrows only if the limit is breached for this context on the exception
type specified.
|
void |
setExceptionClasses(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> classes)
Setter for the exception classes that this handler counts.
|
void |
setFatalExceptionClasses(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> fatalExceptionClasses)
Setter for the exception classes 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.
|
public SimpleLimitExceptionHandler(int limit)
SimpleLimitExceptionHandler
to
set the limit.limit
- the limitpublic SimpleLimitExceptionHandler()
SimpleLimitExceptionHandler
.public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()
public void setUseParent(boolean useParent)
useParent
- true if the parent context should be used to store the
counters.public void handleException(RepeatContext context, java.lang.Throwable throwable) throws java.lang.Throwable
handleException
in interface ExceptionHandler
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.java.lang.Throwable
- implementations are free to re-throw the exceptionsetExceptionClasses(Collection)
,
setLimit(int)
,
ExceptionHandler.handleException(org.springframework.batch.repeat.RepeatContext,
Throwable)
public void setLimit(int limit)
limit
- the limitpublic void setExceptionClasses(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> classes)
Exception
. If more exceptionClasses are specified handler uses
single counter that is incremented when one of the recognized exception
exceptionClasses is handled.classes
- exceptionClassespublic void setFatalExceptionClasses(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> fatalExceptionClasses)
setExceptionClasses(Collection)
.fatalExceptionClasses
- defaults to Error