public abstract class AbstractStep extends java.lang.Object implements Step, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanNameAware
Step
implementation that provides common behavior to subclasses, including registering and calling
listeners.STEP_TYPE_KEY
Constructor and Description |
---|
AbstractStep()
Default constructor.
|
AbstractStep(java.lang.String name)
Convenient constructor for setting only the name property.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
close(ExecutionContext ctx)
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.
|
protected abstract void |
doExecute(StepExecution stepExecution)
Extension point for subclasses to execute business logic.
|
protected void |
doExecutionRegistration(StepExecution stepExecution)
Registers the
StepExecution for property resolution via StepScope |
protected void |
doExecutionRelease()
Releases the most recent
StepExecution |
void |
execute(StepExecution stepExecution)
Template method for step execution logic - calls abstract methods for resource initialization (
open(ExecutionContext) ), execution logic (doExecute(StepExecution) ) and resource closing (
close(ExecutionContext) ). |
protected StepExecutionListener |
getCompositeListener() |
protected JobRepository |
getJobRepository() |
java.lang.String |
getName() |
int |
getStartLimit() |
boolean |
isAllowStartIfComplete() |
protected void |
open(ExecutionContext ctx)
Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or
acquire resources.
|
void |
registerStepExecutionListener(StepExecutionListener listener)
Register a step listener for callbacks at the appropriate stages in a step execution.
|
void |
setAllowStartIfComplete(boolean allowStartIfComplete)
Public setter for flag that determines whether the step should start again if it is already complete.
|
void |
setBeanName(java.lang.String name)
Set the name property if it is not already set.
|
void |
setJobRepository(JobRepository jobRepository)
Public setter for
JobRepository . |
void |
setName(java.lang.String name)
Set the name property.
|
void |
setStartLimit(int startLimit)
Public setter for the startLimit.
|
void |
setStepExecutionListeners(StepExecutionListener[] listeners)
Register each of the objects as listeners.
|
java.lang.String |
toString() |
public AbstractStep()
public AbstractStep(java.lang.String name)
name
- Name of the steppublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the name of the Step
.setBeanName(java.lang.String)
public void setBeanName(java.lang.String name)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
BeanNameAware.setBeanName(java.lang.String)
public int getStartLimit()
getStartLimit
in interface Step
public void setStartLimit(int startLimit)
startLimit
- the startLimit to setpublic boolean isAllowStartIfComplete()
isAllowStartIfComplete
in interface Step
public void setAllowStartIfComplete(boolean allowStartIfComplete)
allowStartIfComplete
- the value of the flag to setprotected abstract void doExecute(StepExecution stepExecution) throws java.lang.Exception
ExitStatus
on the
StepExecution
before returning.stepExecution
- the current step contextjava.lang.Exception
- checked exception thrown by implementationprotected void open(ExecutionContext ctx) throws java.lang.Exception
ctx
- the ExecutionContext
to usejava.lang.Exception
- checked exception thrown by implementationprotected void close(ExecutionContext ctx) throws java.lang.Exception
ctx
- the ExecutionContext
to usejava.lang.Exception
- checked exception thrown by implementationpublic final void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException
open(ExecutionContext)
), execution logic (doExecute(StepExecution)
) and resource closing (
close(ExecutionContext)
).execute
in interface Step
stepExecution
- an entity representing the step to be executedJobInterruptedException
- if the step is interrupted externallyUnexpectedJobExecutionException
protected void doExecutionRelease()
StepExecution
protected void doExecutionRegistration(StepExecution stepExecution)
StepExecution
for property resolution via StepScope
stepExecution
- StepExecution to use when hydrating the StepScoped beanspublic void registerStepExecutionListener(StepExecutionListener listener)
listener
- a StepExecutionListener
public void setStepExecutionListeners(StepExecutionListener[] listeners)
listeners
- an array of listener objects of known types.protected StepExecutionListener getCompositeListener()
public void setJobRepository(JobRepository jobRepository)
JobRepository
.jobRepository
- is a mandatory dependence (no default).protected JobRepository getJobRepository()
public java.lang.String toString()
toString
in class java.lang.Object