Class SimpleJobExplorer
java.lang.Object
org.springframework.batch.core.explore.support.SimpleJobExplorer
- All Implemented Interfaces:
JobExplorer
Implementation of
JobExplorer
that uses the injected DAOs.- Since:
- 2.0
- Author:
- Dave Syer, Lucas Ward, Michael Minella, Will Schipp, Mahmoud Ben Hassine, Parikshit Dutta, Glenn Renfro
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleJobExplorer
(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao, StepExecutionDao stepExecutionDao, ExecutionContextDao ecDao) Constructor to initialize the jobSimpleJobExplorer
. -
Method Summary
Modifier and TypeMethodDescriptionfindJobInstancesByJobName
(String jobName, int start, int count) FetchJobInstance
values in descending order of creation (and, therefore, usually of first execution) with a 'like' or wildcard criteria.findRunningJobExecutions
(String jobName) Retrieve running job executions.protected ExecutionContextDao
getEcDao()
getJobExecution
(Long executionId) Retrieve aJobExecution
by its ID.protected JobExecutionDao
getJobExecutions
(JobInstance jobInstance) Retrieve job executions by their job instance.getJobInstance
(Long instanceId) getJobInstance
(String jobName, JobParameters jobParameters) long
getJobInstanceCount
(String jobName) Query the repository for the number of uniqueJobInstance
objects associated with the supplied job name.protected JobInstanceDao
getJobInstances
(String jobName, int start, int count) FetchJobInstance
values in descending order of creation (and, therefore, usually, of first execution).Query the repository for all uniqueJobInstance
names (sorted alphabetically).getLastJobExecution
(JobInstance jobInstance) Find the lastJobExecution
that has been created for a givenJobInstance
.getLastJobInstance
(String jobName) Find the last job instance, by ID, for the given job.getStepExecution
(Long jobExecutionId, Long executionId) Retrieve aStepExecution
by its ID and parentJobExecution
ID.protected StepExecutionDao
-
Constructor Details
-
SimpleJobExplorer
public SimpleJobExplorer(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao, StepExecutionDao stepExecutionDao, ExecutionContextDao ecDao) Constructor to initialize the jobSimpleJobExplorer
.- Parameters:
jobInstanceDao
- TheJobInstanceDao
to be used by the repository.jobExecutionDao
- TheJobExecutionDao
to be used by the repository.stepExecutionDao
- TheStepExecutionDao
to be used by the repository.ecDao
- TheExecutionContextDao
to be used by the repository.
-
-
Method Details
-
getJobExecutions
Description copied from interface:JobExplorer
Retrieve job executions by their job instance. The corresponding step executions may not be fully hydrated (for example, their execution context may be missing), depending on the implementation. In that case, useJobExplorer.getStepExecution(Long, Long)
to hydrate them.- Specified by:
getJobExecutions
in interfaceJobExplorer
- Parameters:
jobInstance
- TheJobInstance
to query.- Returns:
- the list of all executions for the specified
JobInstance
.
-
getLastJobExecution
Description copied from interface:JobExplorer
Find the lastJobExecution
that has been created for a givenJobInstance
.- Specified by:
getLastJobExecution
in interfaceJobExplorer
- Parameters:
jobInstance
- TheJobInstance
for which to find the lastJobExecution
.- Returns:
- the last
JobExecution
that has been created for this instance ornull
if no job execution is found for the given job instance.
-
findRunningJobExecutions
Description copied from interface:JobExplorer
Retrieve running job executions. The corresponding step executions may not be fully hydrated (for example, their execution context may be missing), depending on the implementation. In that case, useJobExplorer.getStepExecution(Long, Long)
to hydrate them.- Specified by:
findRunningJobExecutions
in interfaceJobExplorer
- Parameters:
jobName
- The name of the job.- Returns:
- the set of running executions for jobs with the specified name.
-
getJobExecution
Description copied from interface:JobExplorer
Retrieve aJobExecution
by its ID. The complete object graph for this execution should be returned (unless otherwise indicated), including the parentJobInstance
and associatedExecutionContext
andStepExecution
instances (also including their execution contexts).- Specified by:
getJobExecution
in interfaceJobExplorer
- Parameters:
executionId
- The job execution ID.- Returns:
- the
JobExecution
that has this ID ornull
if not found.
-
getStepExecution
@Nullable public StepExecution getStepExecution(@Nullable Long jobExecutionId, @Nullable Long executionId) Description copied from interface:JobExplorer
Retrieve aStepExecution
by its ID and parentJobExecution
ID. The execution context for the step should be available in the result, and the parent job execution should have its primitive properties, but it may not contain the job instance information.- Specified by:
getStepExecution
in interfaceJobExplorer
- Parameters:
jobExecutionId
- The parent job execution ID.executionId
- The step execution ID.- Returns:
- the
StepExecution
that has this ID ornull
if not found. - See Also:
-
getJobInstance
- Specified by:
getJobInstance
in interfaceJobExplorer
- Parameters:
instanceId
-Long
The ID for theJobInstance
to obtain.- Returns:
- the
JobInstance
that has this ID, ornull
if not found.
-
getJobInstance
- Specified by:
getJobInstance
in interfaceJobExplorer
- Parameters:
jobName
-String
name of the job.jobParameters
-JobParameters
parameters for the job instance.- Returns:
- the
JobInstance
with the given name and parameters, ornull
.
-
getLastJobInstance
Description copied from interface:JobExplorer
Find the last job instance, by ID, for the given job.- Specified by:
getLastJobInstance
in interfaceJobExplorer
- Parameters:
jobName
- The name of the job.- Returns:
- the last job instance by Id if any or
null
otherwise.
-
getJobInstances
Description copied from interface:JobExplorer
FetchJobInstance
values in descending order of creation (and, therefore, usually, of first execution).- Specified by:
getJobInstances
in interfaceJobExplorer
- Parameters:
jobName
- The name of the job to query.start
- The start index of the instances to return.count
- The maximum number of instances to return.- Returns:
- the
JobInstance
values up to a maximum of count values.
-
getJobNames
Description copied from interface:JobExplorer
Query the repository for all uniqueJobInstance
names (sorted alphabetically).- Specified by:
getJobNames
in interfaceJobExplorer
- Returns:
- the list of job names that have been executed.
-
getJobInstanceCount
Description copied from interface:JobExplorer
Query the repository for the number of uniqueJobInstance
objects associated with the supplied job name.- Specified by:
getJobInstanceCount
in interfaceJobExplorer
- Parameters:
jobName
- The name of the job for which to query.- Returns:
- the number of
JobInstance
s that exist within the associated job repository. - Throws:
NoSuchJobException
- thrown when there is noJobInstance
for the jobName specified.
-
getJobInstanceDao
- Returns:
- instance of
JobInstanceDao
. - Since:
- 5.1
-
getJobExecutionDao
- Returns:
- instance of
JobExecutionDao
. - Since:
- 5.1
-
getStepExecutionDao
- Returns:
- instance of
StepExecutionDao
. - Since:
- 5.1
-
getEcDao
- Returns:
- instance of
ExecutionContextDao
. - Since:
- 5.1
-
findJobInstancesByJobName
Description copied from interface:JobExplorer
FetchJobInstance
values in descending order of creation (and, therefore, usually of first execution) with a 'like' or wildcard criteria.- Specified by:
findJobInstancesByJobName
in interfaceJobExplorer
- Parameters:
jobName
- The name of the job for which to query.start
- The start index of the instances to return.count
- The maximum number of instances to return.- Returns:
- a list of
JobInstance
for the requested job name.
-