public abstract class AbstractStep extends 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.Constructor and Description |
---|
AbstractStep()
Default constructor.
|
AbstractStep(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.
|
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() |
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(String name)
Set the name property if it is not already set.
|
void |
setJobRepository(JobRepository jobRepository)
Public setter for
JobRepository . |
void |
setName(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.
|
String |
toString() |
public AbstractStep()
public AbstractStep(String name)
name
- public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public String getName()
public void setName(String name)
setBeanName(java.lang.String)
public void setBeanName(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 Exception
ExitStatus
on the StepExecution
before
returning.stepExecution
- the current step contextException
protected void open(ExecutionContext ctx) throws Exception
ctx
- the ExecutionContext
to useException
protected void close(ExecutionContext ctx) throws Exception
ctx
- the ExecutionContext
to useException
public 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
public 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()
Copyright © 2013 SpringSource. All rights reserved.