|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.core.job.AbstractJob
public abstract class AbstractJob
Abstract implementation of the Job interface. Common dependencies such as a
JobRepository, JobExecutionListeners, and various configuration
parameters are set here. Therefore, common error handling and listener calling
activities are abstracted away from implementations.
| Field Summary | |
|---|---|
protected static org.apache.commons.logging.Log |
logger
|
| Constructor Summary | |
|---|---|
AbstractJob()
Default constructor. |
|
AbstractJob(java.lang.String name)
Convenience constructor to immediately add name (which is mandatory but not final). |
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Assert mandatory properties: JobRepository. |
protected abstract void |
doExecute(JobExecution execution)
Extension point for subclasses allowing them to concentrate on processing logic and ignore listeners and repository calls. |
void |
execute(JobExecution execution)
Run the specified job, handling all listener and repository calls, and delegating the actual processing to doExecute(JobExecution). |
JobParametersIncrementer |
getJobParametersIncrementer()
If clients need to generate new parameters for the next execution in a sequence they can use this incrementer. |
java.lang.String |
getName()
|
abstract Step |
getStep(java.lang.String stepName)
Retrieve the step with the given name. |
abstract java.util.Collection<java.lang.String> |
getStepNames()
Retrieve the step names. |
protected StepExecution |
handleStep(Step step,
JobExecution execution)
Convenience method for subclasses to delegate the handling of a specific step in the context of the current JobExecution. |
boolean |
isRestartable()
Flag to indicate if this job can be restarted, at least in principle. |
void |
registerJobExecutionListener(JobExecutionListener listener)
Register a single listener for the JobExecutionListener
callbacks. |
void |
setBeanName(java.lang.String name)
Set the name property if it is not already set. |
void |
setJobExecutionListeners(JobExecutionListener[] listeners)
Public setter for injecting JobExecutionListeners. |
void |
setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer)
Public setter for the JobParametersIncrementer. |
void |
setJobRepository(JobRepository jobRepository)
Public setter for the JobRepository that is needed to manage the
state of the batch meta domain (jobs, steps, executions) during the life
of a job. |
void |
setName(java.lang.String name)
Set the name property. |
void |
setRestartable(boolean restartable)
Boolean flag to prevent categorically a job from restarting, even if it has failed previously. |
java.lang.String |
toString()
|
protected void |
updateStepExecution(StepExecution stepExecution)
Convenience method for subclasses so they can change the state of a StepExecution if necessary. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log logger
| Constructor Detail |
|---|
public AbstractJob()
public AbstractJob(java.lang.String name)
name - | Method Detail |
|---|
public void afterPropertiesSet()
throws java.lang.Exception
JobRepository.
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.ExceptionInitializingBean.afterPropertiesSet()public void setBeanName(java.lang.String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwareBeanNameAware.setBeanName(java.lang.String)public void setName(java.lang.String name)
setBeanName(java.lang.String)public java.lang.String getName()
getName in interface Jobpublic abstract Step getStep(java.lang.String stepName)
getStep in interface StepLocatorstepName -
public abstract java.util.Collection<java.lang.String> getStepNames()
getStepNames in interface StepLocatorpublic void setRestartable(boolean restartable)
restartable - the value of the flag to set (default true)public boolean isRestartable()
Job
isRestartable in interface JobJob.isRestartable()public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer)
JobParametersIncrementer.
jobParametersIncrementer - the JobParametersIncrementer to
setpublic JobParametersIncrementer getJobParametersIncrementer()
Job
getJobParametersIncrementer in interface Jobpublic void setJobExecutionListeners(JobExecutionListener[] listeners)
JobExecutionListeners. They will all
be given the listener callbacks at the appropriate point in the job.
listeners - the listeners to set.public void registerJobExecutionListener(JobExecutionListener listener)
JobExecutionListener
callbacks.
listener - a JobExecutionListenerpublic void setJobRepository(JobRepository jobRepository)
JobRepository that is needed to manage the
state of the batch meta domain (jobs, steps, executions) during the life
of a job.
jobRepository -
protected abstract void doExecute(JobExecution execution)
throws JobExecutionException
handleStep(Step, JobExecution).
execution - the current JobExecution
JobExecutionException - to signal a fatal batch framework error
(not a business or validation exception)public final void execute(JobExecution execution)
doExecute(JobExecution).
execute in interface Jobexecution - a JobExecution
StartLimitExceededException - if start limit of one of the steps
was exceededJob.execute(JobExecution)
protected final StepExecution handleStep(Step step,
JobExecution execution)
throws JobInterruptedException,
JobRestartException,
StartLimitExceededException
JobExecution. Clients of this
method do not need access to the JobRepository, nor do they need
to worry about populating the execution context on a restart, nor
detecting the interrupted state (in job or step execution).
step - the Step to executeexecution - the current JobExecution
StepExecution corresponding to this step
JobInterruptedException - if the JobExecution has been
interrupted, and in particular if BatchStatus.ABANDONED or
BatchStatus.STOPPING is detected
StartLimitExceededException - if the start limit has been exceeded
for this step
JobRestartException - if the job is in an inconsistent state from
an earlier failureprotected void updateStepExecution(StepExecution stepExecution)
StepExecution if necessary. Use with care (and not at all
preferably) and only before or after a step is executed.
stepExecution - public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||