Class JobStep
java.lang.Object
org.springframework.batch.core.step.AbstractStep
org.springframework.batch.core.step.job.JobStep
- All Implemented Interfaces:
Step,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
A
Step that delegates to a Job to do its work. This is a great tool for
managing dependencies between jobs, and also to modularise complex step logic into
something that is testable in isolation. The job is executed with parameters that can
be extracted from the step execution, hence this step can also be usefully used as the
worker in a parallel or partitioned execution.- Author:
- Dave Syer
-
Field Summary
Fields inherited from interface org.springframework.batch.core.Step
STEP_TYPE_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voiddoExecute(StepExecution stepExecution) Execute the job provided by delegating to theJobLauncherto prevent duplicate executions.voidTheJobto delegate to in this step.voidsetJobLauncher(JobLauncher jobLauncher) AJobLauncheris required to be able to run the enclosedJob.voidsetJobParametersExtractor(JobParametersExtractor jobParametersExtractor) TheJobParametersExtractoris used to extractJobParametersExtractorfrom theStepExecutionto run theJob.Methods inherited from class org.springframework.batch.core.step.AbstractStep
close, doExecutionRegistration, doExecutionRelease, execute, getCompositeListener, getJobRepository, getName, getStartLimit, isAllowStartIfComplete, open, registerStepExecutionListener, setAllowStartIfComplete, setBeanName, setJobRepository, setMeterRegistry, setName, setObservationConvention, setObservationRegistry, setStartLimit, setStepExecutionListeners, toString
-
Constructor Details
-
JobStep
public JobStep()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Overrides:
afterPropertiesSetin classAbstractStep- Throws:
Exception
-
setJob
TheJobto delegate to in this step.- Parameters:
job- aJob
-
setJobLauncher
AJobLauncheris required to be able to run the enclosedJob.- Parameters:
jobLauncher- theJobLauncherto set
-
setJobParametersExtractor
TheJobParametersExtractoris used to extractJobParametersExtractorfrom theStepExecutionto run theJob. By default an instance will be provided that simply copies theJobParametersfrom the parent job.- Parameters:
jobParametersExtractor- theJobParametersExtractorto set
-
doExecute
Execute the job provided by delegating to theJobLauncherto prevent duplicate executions. The job parameters will be generated by theJobParametersExtractorprovided (if any), otherwise empty. On a restart, the job parameters will be the same as the last (failed) execution.- Specified by:
doExecutein classAbstractStep- Parameters:
stepExecution- the current step context- Throws:
Exception- checked exception thrown by implementation- See Also:
-