Class SimpleStepHandler
java.lang.Object
org.springframework.batch.core.job.SimpleStepHandler
- All Implemented Interfaces:
StepHandler,org.springframework.beans.factory.InitializingBean
public class SimpleStepHandler
extends Object
implements StepHandler, org.springframework.beans.factory.InitializingBean
Implementation of
StepHandler that manages repository and restart concerns.- Author:
- Dave Syer
-
Constructor Summary
ConstructorsConstructorDescriptionConvenient default constructor for configuration usage.SimpleStepHandler(JobRepository jobRepository) SimpleStepHandler(JobRepository jobRepository, ExecutionContext executionContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck mandatory properties (jobRepository).protected JobRepositoryhandleStep(Step step, JobExecution execution) Handle a step and return the execution for it.voidsetExecutionContext(ExecutionContext executionContext) A context containing values to be added to the step execution before it is handled.voidsetJobRepository(JobRepository jobRepository) protected booleanshouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step) Given a step and configuration, return true if the step should start, false if it should not, and throw an exception if the job should finish.
-
Constructor Details
-
SimpleStepHandler
public SimpleStepHandler()Convenient default constructor for configuration usage. -
SimpleStepHandler
- Parameters:
jobRepository- aJobRepository
-
SimpleStepHandler
- Parameters:
jobRepository- aJobRepositoryexecutionContext- theExecutionContextfor the current Step
-
-
Method Details
-
afterPropertiesSet
Check mandatory properties (jobRepository).- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception- See Also:
-
InitializingBean.afterPropertiesSet()
-
getJobRepository
- Returns:
- the used jobRepository
-
setJobRepository
- Parameters:
jobRepository- the jobRepository to set
-
setExecutionContext
A context containing values to be added to the step execution before it is handled.- Parameters:
executionContext- the execution context to set
-
handleStep
public StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException, JobRestartException, StartLimitExceededException Description copied from interface:StepHandlerHandle a step and return the execution for it. Does not save theJobExecution, but should manage the persistence of theStepExecutionif required (e.g. at least it needs to be added to a repository before the step can be executed).- Specified by:
handleStepin interfaceStepHandler- Parameters:
step- aStepexecution- aJobExecution- Returns:
- an execution of the step
- Throws:
JobInterruptedException- if there is an interruptionJobRestartException- if there is a problem restarting a failed stepStartLimitExceededException- if the step exceeds its start limit- See Also:
-
shouldStart
protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step) throws JobRestartException, StartLimitExceededException Given a step and configuration, return true if the step should start, false if it should not, and throw an exception if the job should finish.- Parameters:
lastStepExecution- the last step executionjobExecution- theJobExecutioninstance to be evaluated.step- theStepinstance to be evaluated.- Returns:
- true if step should start, false if it should not.
- Throws:
StartLimitExceededException- if the start limit has been exceeded for this stepJobRestartException- if the job is in an inconsistent state from an earlier failure
-