All Implemented Interfaces:

public class StepContext extends SynchronizedAttributeAccessor
A context object that can be used to interrogate the current StepExecution and some of its associated properties using expressions based on bean paths. Has public getters for the step execution and convenience methods for accessing commonly used properties like the ExecutionContext associated with the step or its enclosing job execution.
Dave Syer, Michael Minella, Mahmoud Ben Hassine, Nicolas Widart
  • Constructor Details

  • Method Details

    • getStepName

      public String getStepName()
      Convenient accessor for current step name identifier. Usually this is the same as the bean name of the step that is executing (but might not be e.g. in a partition).
      the step name identifier of the current StepExecution
    • getJobName

      public String getJobName()
      Convenient accessor for current job name identifier.
      the job name identifier of the enclosing JobInstance associated with the current StepExecution
    • getJobInstanceId

      public Long getJobInstanceId()
      Convenient accessor for current JobInstance identifier.
      the identifier of the enclosing JobInstance associated with the current StepExecution
    • getSystemProperties

      public Properties getSystemProperties()
      Convenient accessor for System properties to make it easy to access them from placeholder expressions.
      the current System properties
    • getStepExecutionContext

      public Map<String,Object> getStepExecutionContext()
      a map containing the items from the step ExecutionContext
    • getJobExecutionContext

      public Map<String,Object> getJobExecutionContext()
      a map containing the items from the job ExecutionContext
    • getJobParameters

      public Map<String,Object> getJobParameters()
      a map containing the items from the JobParameters
    • registerDestructionCallback

      public void registerDestructionCallback(String name, Runnable callback)
      Allow clients to register callbacks for clean up on close.
      name - the callback id (unique attribute key in this context)
      callback - a callback to execute on close
    • removeAttribute

      @Nullable public Object removeAttribute(String name)
      Override base class behaviour to ensure destruction callbacks are unregistered as well as the default behaviour.
      Specified by:
      removeAttribute in interface org.springframework.core.AttributeAccessor
      removeAttribute in class SynchronizedAttributeAccessor
      See Also:
    • close

      public void close()
      Clean up the context at the end of a step execution. Must be called once at the end of a step execution to honour the destruction callback contract from the StepScope.
    • getStepExecution

      public StepExecution getStepExecution()
      The current StepExecution that is active in this context.
      the current StepExecution
    • getId

      public String getId()
      unique identifier for this context based on the step execution
    • equals

      public boolean equals(Object other)
      Extend the base class method to include the step execution itself as a key (i.e. two contexts are only equal if their step executions are the same).
      equals in class SynchronizedAttributeAccessor
      See Also:
    • hashCode

      public int hashCode()
      Overrides the default behaviour to provide a hash code based only on the step execution.
      hashCode in class SynchronizedAttributeAccessor
      See Also:
    • toString

      public String toString()
      toString in class SynchronizedAttributeAccessor