Class AbstractStep

  • All Implemented Interfaces:
    Step, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
    Direct Known Subclasses:
    DecisionStep, DelegateStep, FlowStep, JobStep, PartitionStep, TaskletStep

    public abstract class AbstractStep
    extends java.lang.Object
    implements Step, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanNameAware
    A Step implementation that provides common behavior to subclasses, including registering and calling listeners.
    Author:
    Dave Syer, Ben Hale, Robert Kasanicky, Michael Minella, Chris Schaefer, Mahmoud Ben Hassine
    • Constructor Detail

      • AbstractStep

        public AbstractStep()
        Default constructor.
      • AbstractStep

        public AbstractStep​(java.lang.String name)
        Convenient constructor for setting only the name property.
        Parameters:
        name - Name of the step
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Step
        Returns:
        the name of this step.
      • setName

        public void setName​(java.lang.String name)
        Set the name property. Always overrides the default value if this object is a Spring bean.
        Parameters:
        name - the name of the Step.
        See Also:
        setBeanName(java.lang.String)
      • setBeanName

        public void setBeanName​(java.lang.String name)
        Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent bean has a name, then its children need an explicit name as well, otherwise they will not be unique.
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
        See Also:
        BeanNameAware.setBeanName(java.lang.String)
      • getStartLimit

        public int getStartLimit()
        Specified by:
        getStartLimit in interface Step
        Returns:
        the number of times a job can be started with the same identifier.
      • setStartLimit

        public void setStartLimit​(int startLimit)
        Public setter for the startLimit.
        Parameters:
        startLimit - the startLimit to set
      • isAllowStartIfComplete

        public boolean isAllowStartIfComplete()
        Specified by:
        isAllowStartIfComplete in interface Step
        Returns:
        true if a step that is already marked as complete can be started again.
      • setAllowStartIfComplete

        public void setAllowStartIfComplete​(boolean allowStartIfComplete)
        Public setter for flag that determines whether the step should start again if it is already complete. Defaults to false.
        Parameters:
        allowStartIfComplete - the value of the flag to set
      • doExecute

        protected abstract void doExecute​(StepExecution stepExecution)
                                   throws java.lang.Exception
        Extension point for subclasses to execute business logic. Subclasses should set the ExitStatus on the StepExecution before returning.
        Parameters:
        stepExecution - the current step context
        Throws:
        java.lang.Exception - checked exception thrown by implementation
      • open

        protected void open​(ExecutionContext ctx)
                     throws java.lang.Exception
        Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or acquire resources. Does nothing by default.
        Parameters:
        ctx - the ExecutionContext to use
        Throws:
        java.lang.Exception - checked exception thrown by implementation
      • close

        protected void close​(ExecutionContext ctx)
                      throws java.lang.Exception
        Extension point for subclasses to provide callbacks to their collaborators at the end of a step (right at the end of the finally block), to close or release resources. Does nothing by default.
        Parameters:
        ctx - the ExecutionContext to use
        Throws:
        java.lang.Exception - checked exception thrown by implementation
      • doExecutionRelease

        protected void doExecutionRelease()
        Releases the most recent StepExecution
      • doExecutionRegistration

        protected void doExecutionRegistration​(StepExecution stepExecution)
        Registers the StepExecution for property resolution via StepScope
        Parameters:
        stepExecution - StepExecution to use when hydrating the StepScoped beans
      • registerStepExecutionListener

        public void registerStepExecutionListener​(StepExecutionListener listener)
        Register a step listener for callbacks at the appropriate stages in a step execution.
        Parameters:
        listener - a StepExecutionListener
      • setStepExecutionListeners

        public void setStepExecutionListeners​(StepExecutionListener[] listeners)
        Register each of the objects as listeners.
        Parameters:
        listeners - an array of listener objects of known types.
      • getCompositeListener

        protected StepExecutionListener getCompositeListener()
        Returns:
        composite listener that delegates to all registered listeners.
      • setJobRepository

        public void setJobRepository​(JobRepository jobRepository)
        Public setter for JobRepository.
        Parameters:
        jobRepository - is a mandatory dependence (no default).
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object