|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.core.job.AbstractJob
public abstract class AbstractJob
Abstract implementation of the Job
interface. Common dependencies such as a
JobRepository
, JobExecutionListener
s, and various configuration
parameters are set here. Therefore, common error handling and listener calling
activities are abstracted away from implementations.
Field Summary | |
---|---|
protected static Log |
logger
|
Constructor Summary | |
---|---|
AbstractJob()
Default constructor. |
|
AbstractJob(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. |
String |
getName()
|
abstract Step |
getStep(String stepName)
Retrieve the step with the given name. |
abstract Collection<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(String name)
Set the name property if it is not already set. |
void |
setJobExecutionListeners(JobExecutionListener[] listeners)
Public setter for injecting JobExecutionListener s. |
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(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. |
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 Log logger
Constructor Detail |
---|
public AbstractJob()
public AbstractJob(String name)
name
- Method Detail |
---|
public void afterPropertiesSet() throws Exception
JobRepository
.
afterPropertiesSet
in interface InitializingBean
Exception
InitializingBean.afterPropertiesSet()
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
BeanNameAware.setBeanName(java.lang.String)
public void setName(String name)
setBeanName(java.lang.String)
public String getName()
getName
in interface Job
public abstract Step getStep(String stepName)
getStep
in interface StepLocator
stepName
-
public abstract Collection<String> getStepNames()
getStepNames
in interface StepLocator
public void setRestartable(boolean restartable)
restartable
- the value of the flag to set (default true)public boolean isRestartable()
Job
isRestartable
in interface Job
Job.isRestartable()
public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer)
JobParametersIncrementer
.
jobParametersIncrementer
- the JobParametersIncrementer
to
setpublic JobParametersIncrementer getJobParametersIncrementer()
Job
getJobParametersIncrementer
in interface Job
public void setJobExecutionListeners(JobExecutionListener[] listeners)
JobExecutionListener
s. 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 JobExecutionListener
public 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 Job
execution
- 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 String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |