Class StepExecutionSimpleCompletionPolicy

java.lang.Object
org.springframework.batch.core.resource.StepExecutionSimpleCompletionPolicy
All Implemented Interfaces:
StepExecutionListener, StepListener, CompletionPolicy

@NullUnmarked @Deprecated(since="6.0", forRemoval=true) public class StepExecutionSimpleCompletionPolicy extends Object implements StepExecutionListener, CompletionPolicy
Deprecated, for removal: This API element is subject to removal in a future version.
since 6.0 with no replacement. Scheduled for removal in 6.2 or later.

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
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beforeStep(StepExecution stepExecution)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set up a SimpleCompletionPolicy with a commit interval taken from the JobParameters.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Allow policy to signal completion according to internal state, without having to wait for the callback to complete.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Determine whether a batch is complete given the latest result from the callback.
    void
    setKeyName(String keyName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Public setter for the key name of a Long value in the JobParameters that will contain a commit interval.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new context for the execution of a batch.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Delegates to the wrapped CompletionPolicy if set, otherwise returns the value of setKeyName(String).
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Give implementations the opportunity to update the state of the current batch.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface StepExecutionListener

    afterStep
  • Constructor Details

    • StepExecutionSimpleCompletionPolicy

      public StepExecutionSimpleCompletionPolicy()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • setKeyName

      public void setKeyName(String keyName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Public setter for the key name of a Long value in the JobParameters that will contain a commit interval. Defaults to "commit.interval".
      Parameters:
      keyName - the keyName to set
    • beforeStep

      public void beforeStep(StepExecution stepExecution)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set up a 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.
      Specified by:
      beforeStep in interface StepExecutionListener
      Parameters:
      stepExecution - instance of StepExecution.
      See Also:
    • isComplete

      public boolean isComplete(RepeatContext context, RepeatStatus result)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CompletionPolicy
      Determine whether a batch is complete given the latest result from the callback. If this method returns true then CompletionPolicy.isComplete(RepeatContext) should also (but not necessarily vice versa, since the answer here depends on the result).
      Specified by:
      isComplete in interface CompletionPolicy
      Parameters:
      context - the current batch context.
      result - the result of the latest batch item processing.
      Returns:
      true if the commit interval has been reached or the result indicates completion
      See Also:
    • isComplete

      public boolean isComplete(RepeatContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CompletionPolicy
      Allow policy to signal completion according to internal state, without having to wait for the callback to complete.
      Specified by:
      isComplete in interface CompletionPolicy
      Parameters:
      context - the current batch context.
      Returns:
      if the commit interval has been reached
      See Also:
    • start

      public RepeatContext start(RepeatContext parent)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CompletionPolicy
      Create a new context for the execution of a batch. N.B. implementations should not return the parent from this method - they must create a new context to meet the specific needs of the policy. The best way to do this might be to override an existing implementation and use the RepeatContext to store state in its attributes.
      Specified by:
      start in interface CompletionPolicy
      Parameters:
      parent - the current context if one is already in progress.
      Returns:
      a new RepeatContext
      See Also:
    • update

      public void update(RepeatContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CompletionPolicy
      Give implementations the opportunity to update the state of the current batch. Will be called once per callback, after it has been launched, but not necessarily after it completes (if the batch is asynchronous).
      Specified by:
      update in interface CompletionPolicy
      Parameters:
      context - the value returned by start.
      See Also:
    • toString

      public String toString()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Delegates to the wrapped CompletionPolicy if set, otherwise returns the value of setKeyName(String).
      Overrides:
      toString in class Object