Class SimpleCompletionPolicy
java.lang.Object
org.springframework.batch.repeat.policy.CompletionPolicySupport
org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy
org.springframework.batch.repeat.policy.SimpleCompletionPolicy
- All Implemented Interfaces:
- CompletionPolicy
Policy for terminating a batch after a fixed number of operations. Internal state is
 maintained and a counter incremented, so successful use of this policy requires that
 isComplete() is only called once per batch item. Using the standard
 
RepeatTemplate should ensure this contract is kept, but it needs to be
 carefully monitored.- Author:
- Dave Syer
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintbooleanisComplete(RepeatContext context) Terminate if the chunk size has been reached.booleanisComplete(RepeatContext context, RepeatStatus result) Terminate if the chunk size has been reached, or the result is null.voidsetChunkSize(int chunkSize) start(RepeatContext context) Reset the counter.toString()voidupdate(RepeatContext context) Increment the counter in the context.
- 
Field Details- 
DEFAULT_CHUNK_SIZEpublic static final int DEFAULT_CHUNK_SIZE- See Also:
 
 
- 
- 
Constructor Details- 
SimpleCompletionPolicypublic SimpleCompletionPolicy()
- 
SimpleCompletionPolicypublic SimpleCompletionPolicy(int chunkSize) 
 
- 
- 
Method Details- 
setChunkSizepublic void setChunkSize(int chunkSize) 
- 
getChunkSizepublic int getChunkSize()
- 
startReset the counter.- Specified by:
- startin interface- CompletionPolicy
- Overrides:
- startin class- CompletionPolicySupport
- Parameters:
- context- the current context if one is already in progress.
- Returns:
- a context object that can be used by the implementation to store internal state for a batch.
- See Also:
 
- 
isCompleteTerminate if the chunk size has been reached, or the result is null.- Specified by:
- isCompletein interface- CompletionPolicy
- Overrides:
- isCompletein class- DefaultResultCompletionPolicy
- Parameters:
- context- the current batch context.
- result- the result of the latest batch item processing.
- Returns:
- true if the batch should terminate.
- Throws:
- RuntimeException- (normally terminating the batch) if the result is itself an exception.
- See Also:
 
- 
isCompleteTerminate if the chunk size has been reached.- Specified by:
- isCompletein interface- CompletionPolicy
- Overrides:
- isCompletein class- DefaultResultCompletionPolicy
- Parameters:
- context- the current batch context.
- Returns:
- true if the batch should terminate.
- See Also:
 
- 
updateIncrement the counter in the context.- Specified by:
- updatein interface- CompletionPolicy
- Overrides:
- updatein class- CompletionPolicySupport
- Parameters:
- context- the value returned by start.
- See Also:
 
- 
toString
 
-