Class StepContext

  • All Implemented Interfaces:
    org.springframework.core.AttributeAccessor

    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.
    Author:
    Dave Syer, Michael Minella, Mahmoud Ben Hassine
    • Method Detail

      • getStepName

        public java.lang.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).
        Returns:
        the step name identifier of the current StepExecution
      • getJobName

        public java.lang.String getJobName()
        Convenient accessor for current job name identifier.
        Returns:
        the job name identifier of the enclosing JobInstance associated with the current StepExecution
      • getSystemProperties

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

        public java.util.Map<java.lang.String,​java.lang.Object> getStepExecutionContext()
        Returns:
        a map containing the items from the step ExecutionContext
      • getJobExecutionContext

        public java.util.Map<java.lang.String,​java.lang.Object> getJobExecutionContext()
        Returns:
        a map containing the items from the job ExecutionContext
      • getJobParameters

        public java.util.Map<java.lang.String,​java.lang.Object> getJobParameters()
        Returns:
        a map containing the items from the JobParameters
      • getPartitionPlan

        public java.util.Map<java.lang.String,​java.lang.Object> getPartitionPlan()
      • registerDestructionCallback

        public void registerDestructionCallback​(java.lang.String name,
                                                java.lang.Runnable callback)
        Allow clients to register callbacks for clean up on close.
        Parameters:
        name - the callback id (unique attribute key in this context)
        callback - a callback to execute on close
      • 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.
      • getId

        public java.lang.String getId()
        Returns:
        unique identifier for this context based on the step execution