public class SimpleStepHandler extends java.lang.Object implements StepHandler, org.springframework.beans.factory.InitializingBean
StepHandler
that manages repository and restart
concerns.Constructor and Description |
---|
SimpleStepHandler()
Convenient default constructor for configuration usage.
|
SimpleStepHandler(JobRepository jobRepository) |
SimpleStepHandler(JobRepository jobRepository,
ExecutionContext executionContext) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Check mandatory properties (jobRepository).
|
protected JobRepository |
getJobRepository() |
StepExecution |
handleStep(Step step,
JobExecution execution)
Handle a step and return the execution for it.
|
void |
setExecutionContext(ExecutionContext executionContext)
A context containing values to be added to the step execution before it
is handled.
|
void |
setJobRepository(JobRepository jobRepository) |
protected boolean |
shouldStart(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.
|
public SimpleStepHandler()
public SimpleStepHandler(JobRepository jobRepository)
jobRepository
- a JobRepository
public SimpleStepHandler(JobRepository jobRepository, ExecutionContext executionContext)
jobRepository
- a JobRepository
executionContext
- the ExecutionContext
for the current Steppublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()
protected JobRepository getJobRepository()
public void setJobRepository(JobRepository jobRepository)
jobRepository
- the jobRepository to setpublic void setExecutionContext(ExecutionContext executionContext)
executionContext
- the execution context to setpublic StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException, JobRestartException, StartLimitExceededException
StepHandler
JobExecution
, but should manage the persistence of the
StepExecution
if required (e.g. at least it needs to be added to
a repository before the step can be executed).handleStep
in interface StepHandler
step
- a Step
execution
- a JobExecution
JobInterruptedException
- if there is an interruptionJobRestartException
- if there is a problem restarting a failed
stepStartLimitExceededException
- if the step exceeds its start limitJob.execute(JobExecution)
,
Step.execute(StepExecution)
protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step) throws JobRestartException, StartLimitExceededException
lastStepExecution
- the last step executionjobExecution
- the JobExecution
instance to be evaluated.step
- the Step
instance to be evaluated.StartLimitExceededException
- if the start limit has been exceeded
for this stepJobRestartException
- if the job is in an inconsistent state from
an earlier failure