|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy
public class LimitCheckingItemSkipPolicy
SkipPolicy
that determines whether or not reading should continue
based upon how many items have been skipped. This is extremely useful
behavior, as it allows you to skip records, but will throw a
SkipLimitExceededException
if a set limit has been exceeded. For
example, it is generally advisable to skip FlatFileParseException
s,
however, if the vast majority of records are causing exceptions, the file is
likely bad.
Furthermore, it is also likely that you only want to skip certain exceptions.
FlatFileParseException
is a good example of an exception you will
likely want to skip, but a FileNotFoundException
should cause
immediate termination of the Step
. A Classifier
is used to
determine whether a particular exception is skippable or not.
Constructor Summary | |
---|---|
LimitCheckingItemSkipPolicy()
Convenience constructor that assumes all exception types are fatal. |
|
LimitCheckingItemSkipPolicy(int skipLimit,
Classifier<Throwable,Boolean> skippableExceptionClassifier)
|
|
LimitCheckingItemSkipPolicy(int skipLimit,
Map<Class<? extends Throwable>,Boolean> skippableExceptions)
|
Method Summary | |
---|---|
void |
setSkipLimit(int skipLimit)
The absolute number of skips (of skippable exceptions) that can be tolerated before a failure. |
void |
setSkippableExceptionClassifier(Classifier<Throwable,Boolean> skippableExceptionClassifier)
The classifier that will be used to decide on skippability. |
void |
setSkippableExceptionMap(Map<Class<? extends Throwable>,Boolean> skippableExceptions)
Set up the classifier through a convenient map from throwable class to boolean (true if skippable). |
boolean |
shouldSkip(Throwable t,
int skipCount)
Given the provided exception and skip count, determine whether or not processing should continue for the given exception. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LimitCheckingItemSkipPolicy()
public LimitCheckingItemSkipPolicy(int skipLimit, Map<Class<? extends Throwable>,Boolean> skippableExceptions)
skipLimit
- the number of skippable exceptions that are allowed to
be skippedskippableExceptions
- exception classes that can be skipped
(non-critical)public LimitCheckingItemSkipPolicy(int skipLimit, Classifier<Throwable,Boolean> skippableExceptionClassifier)
skipLimit
- the number of skippable exceptions that are allowed to
be skippedskippableExceptionClassifier
- exception classifier for those that
can be skipped (non-critical)Method Detail |
---|
public void setSkipLimit(int skipLimit)
skipLimit
- the skip limit to setpublic void setSkippableExceptionClassifier(Classifier<Throwable,Boolean> skippableExceptionClassifier)
skippableExceptionClassifier
- the skippableExceptionClassifier to
setpublic void setSkippableExceptionMap(Map<Class<? extends Throwable>,Boolean> skippableExceptions)
skippableExceptions
- the skippable exceptions to setpublic boolean shouldSkip(Throwable t, int skipCount)
StepExecution
skipCount is greater than the skipLimit, then a
SkipLimitExceededException
will be thrown.
shouldSkip
in interface SkipPolicy
t
- exception encountered while readingskipCount
- currently running count of skips
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |