public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSupport implements 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.
CompletionPolicy| Constructor and Description |
|---|
StepExecutionSimpleCompletionPolicy() |
| Modifier and Type | Method and Description |
|---|---|
void |
beforeStep(StepExecution stepExecution)
Set up a
SimpleCompletionPolicy with a commit interval taken from
the JobParameters. |
boolean |
isComplete(RepeatContext context)
Allow policy to signal completion according to internal state, without
having to wait for the callback to complete.
|
boolean |
isComplete(RepeatContext context,
RepeatStatus result)
Determine whether a batch is complete given the latest result from the
callback.
|
void |
setKeyName(java.lang.String keyName)
Public setter for the key name of a Long value in the
JobParameters that will contain a commit interval. |
RepeatContext |
start(RepeatContext parent)
Create a new context for the execution of a batch.
|
java.lang.String |
toString()
Delegates to the wrapped
CompletionPolicy if set, otherwise
returns the value of setKeyName(String). |
void |
update(RepeatContext context)
Give implementations the opportunity to update the state of the current
batch.
|
afterSteppublic void setKeyName(java.lang.String keyName)
JobParameters that will contain a commit interval. Defaults to
"commit.interval".keyName - the keyName to setpublic void beforeStep(StepExecution stepExecution)
SimpleCompletionPolicy with a commit interval taken from
the JobParameters. 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.beforeStep in interface StepExecutionListenerbeforeStep in class StepExecutionListenerSupportStepExecutionListenerSupport.beforeStep(org.springframework.batch.core.StepExecution)public boolean isComplete(RepeatContext context, RepeatStatus result)
CompletionPolicyCompletionPolicy.isComplete(RepeatContext) should also (but not necessarily vice
versa, since the answer here depends on the result).isComplete in interface CompletionPolicycontext - result - CompletionPolicy.isComplete(RepeatContext, RepeatStatus)public boolean isComplete(RepeatContext context)
CompletionPolicyisComplete in interface CompletionPolicycontext - CompletionPolicy.isComplete(org.springframework.batch.repeat.RepeatContext)public RepeatContext start(RepeatContext parent)
CompletionPolicyRepeatContext to store state in its attributes.start in interface CompletionPolicyparent - RepeatContextCompletionPolicy.start(org.springframework.batch.repeat.RepeatContext)public void update(RepeatContext context)
CompletionPolicyupdate in interface CompletionPolicycontext - CompletionPolicy.update(org.springframework.batch.repeat.RepeatContext)public java.lang.String toString()
CompletionPolicy if set, otherwise
returns the value of setKeyName(String).toString in class java.lang.Object