|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.repeat.policy.CompletionPolicySupport org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy org.springframework.batch.repeat.policy.CountingCompletionPolicy
public abstract class CountingCompletionPolicy
Abstract base class for policies that need to count the number of occurrences of some event (e.g. an exception type in the context), and terminate based on a limit for the counter. The value of the counter can be stored between batches in a nested context, so that the termination decision is based on the aggregate of a number of sibling batches.
Nested Class Summary | |
---|---|
protected class |
CountingCompletionPolicy.CountingBatchContext
|
Field Summary | |
---|---|
static String |
COUNT
Session key for global counter. |
Constructor Summary | |
---|---|
CountingCompletionPolicy()
|
Method Summary | |
---|---|
protected int |
doUpdate(RepeatContext context)
Extension point for subclasses. |
protected abstract int |
getCount(RepeatContext context)
Extension point for subclasses. |
boolean |
isComplete(RepeatContext context)
Always false. |
void |
setMaxCount(int maxCount)
Setter for maximum value of count before termination. |
void |
setUseParent(boolean useParent)
Flag to indicate whether the count is at the level of the parent context, or just local to the context. |
RepeatContext |
start(RepeatContext parent)
Build a new RepeatContextSupport and return it. |
void |
update(RepeatContext context)
Increment the context so the counter is up to date. |
Methods inherited from class org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy |
---|
isComplete |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COUNT
Constructor Detail |
---|
public CountingCompletionPolicy()
Method Detail |
---|
public void setUseParent(boolean useParent)
useParent
- whether to use the parent context to cache the total
count. Default value is false.public void setMaxCount(int maxCount)
maxCount
- the maximum number of counts before termination. Default
0 so termination is immediate.protected abstract int getCount(RepeatContext context)
context
- the current context, specific to the subclass.
protected int doUpdate(RepeatContext context)
setUseParent(boolean)
is true.
context
- the current context.
public final boolean isComplete(RepeatContext context)
DefaultResultCompletionPolicy
isComplete
in interface CompletionPolicy
isComplete
in class DefaultResultCompletionPolicy
context
- the current batch context.
CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext)
public RepeatContext start(RepeatContext parent)
CompletionPolicySupport
RepeatContextSupport
and return it.
start
in interface CompletionPolicy
start
in class CompletionPolicySupport
parent
- the current context if one is already in progress.
CompletionPolicy.start(RepeatContext)
public final void update(RepeatContext context)
CompletionPolicySupport
update
in interface CompletionPolicy
update
in class CompletionPolicySupport
context
- the value returned by start.CompletionPolicy.update(org.springframework.batch.repeat.RepeatContext)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |