Class StepExecutionSimpleCompletionPolicy
java.lang.Object
org.springframework.batch.core.resource.StepExecutionSimpleCompletionPolicy
- All Implemented Interfaces:
StepExecutionListener,StepListener,CompletionPolicy
public class StepExecutionSimpleCompletionPolicy
extends Object
implements StepExecutionListener, CompletionPolicy
A CompletionPolicy that picks up a commit interval from JobParameters
by listening to the start of a step. Use anywhere that a CompletionPolicy can
be used (usually at the chunk level in a step), and inject as a
StepExecutionListener into the surrounding step. N.B. only after the step has
started will the completion policy be usable.
It is easier and probably preferable to simply declare the chunk with a commit-interval
that is a late-binding expression (e.g.
#{jobParameters['commit.interval']}). That feature is available from of
Spring Batch 2.1.7.
- Author:
- Dave Syer, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeStep(StepExecution stepExecution) Set up aSimpleCompletionPolicywith a commit interval taken from theJobParameters.booleanisComplete(RepeatContext context) booleanisComplete(RepeatContext context, RepeatStatus result) voidsetKeyName(String keyName) Public setter for the key name of a Long value in theJobParametersthat will contain a commit interval.start(RepeatContext parent) toString()Delegates to the wrappedCompletionPolicyif set, otherwise returns the value ofsetKeyName(String).voidupdate(RepeatContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.batch.core.StepExecutionListener
afterStep
-
Constructor Details
-
StepExecutionSimpleCompletionPolicy
public StepExecutionSimpleCompletionPolicy()
-
-
Method Details
-
setKeyName
Public setter for the key name of a Long value in theJobParametersthat will contain a commit interval. Defaults to "commit.interval".- Parameters:
keyName- the keyName to set
-
beforeStep
Set up aSimpleCompletionPolicywith a commit interval taken from theJobParameters. If there is a Long parameter with the given key name, the intValue of this parameter is used. If not an exception will be thrown.- Specified by:
beforeStepin interfaceStepExecutionListener- Parameters:
stepExecution- instance ofStepExecution.- See Also:
-
isComplete
- Specified by:
isCompletein interfaceCompletionPolicy- Returns:
- true if the commit interval has been reached or the result indicates completion
- See Also:
-
isComplete
- Specified by:
isCompletein interfaceCompletionPolicy- Returns:
- if the commit interval has been reached
- See Also:
-
start
- Specified by:
startin interfaceCompletionPolicy- Returns:
- a new
RepeatContext - See Also:
-
update
- Specified by:
updatein interfaceCompletionPolicy- See Also:
-
toString
Delegates to the wrappedCompletionPolicyif set, otherwise returns the value ofsetKeyName(String).
-