类 CountingCompletionPolicy
- java.lang.Object
- org.springframework.batch.repeat.policy.CompletionPolicySupport
- org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy
- org.springframework.batch.repeat.policy.CountingCompletionPolicy
- 所有已实现的接口:
CompletionPolicy
public abstract class CountingCompletionPolicy extends DefaultResultCompletionPolicy
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.- 作者:
- Dave Syer
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected class
CountingCompletionPolicy.CountingBatchContext
字段概要
字段 修饰符和类型 字段 说明 static java.lang.String
COUNT
Session key for global counter.
构造器概要
构造器 构造器 说明 CountingCompletionPolicy()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 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 newRepeatContextSupport
and return it.void
update(RepeatContext context)
Increment the context so the counter is up to date.从类继承的方法 org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy
isComplete
字段详细资料
COUNT
public static final java.lang.String COUNT
Session key for global counter.
构造器详细资料
CountingCompletionPolicy
public CountingCompletionPolicy()
方法详细资料
setUseParent
public void setUseParent(boolean useParent)
Flag to indicate whether the count is at the level of the parent context, or just local to the context. If true then the count is aggregated among siblings in a nested batch.- 参数:
useParent
- whether to use the parent context to cache the total count. Default value is false.
setMaxCount
public void setMaxCount(int maxCount)
Setter for maximum value of count before termination.- 参数:
maxCount
- the maximum number of counts before termination. Default 0 so termination is immediate.
getCount
protected abstract int getCount(RepeatContext context)
Extension point for subclasses. Obtain the value of the count in the current context. Subclasses can count the number of attempts or violations and store the result in their context. This policy base class will take care of the termination contract and aggregating at the level of the session if required.- 参数:
context
- the current context, specific to the subclass.- 返回:
- the value of the counter in the context.
doUpdate
protected int doUpdate(RepeatContext context)
Extension point for subclasses. Inspect the context and update the state of a counter in whatever way is appropriate. This will be added to the session-level counter ifsetUseParent(boolean)
is true.- 参数:
context
- the current context.- 返回:
- the change in the value of the counter (default 0).
isComplete
public final boolean isComplete(RepeatContext context)
从类复制的说明:DefaultResultCompletionPolicy
Always false.- 指定者:
isComplete
在接口中CompletionPolicy
- 覆盖:
isComplete
在类中DefaultResultCompletionPolicy
- 参数:
context
- the current batch context.- 返回:
- true if the batch should terminate.
- 另请参阅:
CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext)
start
public RepeatContext start(RepeatContext parent)
从类复制的说明:CompletionPolicySupport
Build a newRepeatContextSupport
and return it.- 指定者:
start
在接口中CompletionPolicy
- 覆盖:
start
在类中CompletionPolicySupport
- 参数:
parent
- the current context if one is already in progress.- 返回:
- a context object that can be used by the implementation to store internal state for a batch.
- 另请参阅:
CompletionPolicy.start(RepeatContext)
update
public final void update(RepeatContext context)
从类复制的说明:CompletionPolicySupport
Increment the context so the counter is up to date. Do nothing else.- 指定者:
update
在接口中CompletionPolicy
- 覆盖:
update
在类中CompletionPolicySupport
- 参数:
context
- the value returned by start.- 另请参阅:
CompletionPolicy.update(org.springframework.batch.repeat.RepeatContext)