11/*
2- * Copyright 2006-2023 the original author or authors.
2+ * Copyright 2006-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
4040 */
4141public interface JobExplorer {
4242
43+ /*
44+ * ===================================================================================
45+ * Job operations
46+ * ===================================================================================
47+ */
48+
49+ /**
50+ * Query the repository for all unique {@link JobInstance} names (sorted
51+ * alphabetically).
52+ * @return the list of job names that have been executed.
53+ */
54+ List <String > getJobNames ();
55+
56+ /*
57+ * ===================================================================================
58+ * Job instance operations
59+ * ===================================================================================
60+ */
61+
4362 /**
4463 * Fetch {@link JobInstance} values in descending order of creation (and, therefore,
4564 * usually, of first execution).
@@ -50,6 +69,16 @@ public interface JobExplorer {
5069 */
5170 List <JobInstance > getJobInstances (String jobName , int start , int count );
5271
72+ /**
73+ * Fetch {@link JobInstance} values in descending order of creation (and, therefore,
74+ * usually of first execution) with a 'like' or wildcard criteria.
75+ * @param jobName The name of the job for which to query.
76+ * @param start The start index of the instances to return.
77+ * @param count The maximum number of instances to return.
78+ * @return a list of {@link JobInstance} for the requested job name.
79+ */
80+ List <JobInstance > findJobInstancesByJobName (String jobName , int start , int count );
81+
5382 /**
5483 * Find the last job instance, by ID, for the given job.
5584 * @param jobName The name of the job.
@@ -62,31 +91,6 @@ default JobInstance getLastJobInstance(String jobName) {
6291 throw new UnsupportedOperationException ();
6392 }
6493
65- /**
66- * Retrieve a {@link JobExecution} by its ID. The complete object graph for this
67- * execution should be returned (unless otherwise indicated), including the parent
68- * {@link JobInstance} and associated {@link ExecutionContext} and
69- * {@link StepExecution} instances (also including their execution contexts).
70- * @param executionId The job execution ID.
71- * @return the {@link JobExecution} that has this ID or {@code null} if not found.
72- */
73- @ Nullable
74- JobExecution getJobExecution (@ Nullable Long executionId );
75-
76- /**
77- * Retrieve a {@link StepExecution} by its ID and parent {@link JobExecution} ID. The
78- * execution context for the step should be available in the result, and the parent
79- * job execution should have its primitive properties, but it may not contain the job
80- * instance information.
81- * @param jobExecutionId The parent job execution ID.
82- * @param stepExecutionId The step execution ID.
83- * @return the {@link StepExecution} that has this ID or {@code null} if not found.
84- *
85- * @see #getJobExecution(Long)
86- */
87- @ Nullable
88- StepExecution getStepExecution (@ Nullable Long jobExecutionId , @ Nullable Long stepExecutionId );
89-
9094 /**
9195 * @param instanceId {@link Long} The ID for the {@link JobInstance} to obtain.
9296 * @return the {@code JobInstance} that has this ID, or {@code null} if not found.
@@ -107,6 +111,34 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
107111 throw new UnsupportedOperationException ();
108112 }
109113
114+ /**
115+ * Query the repository for the number of unique {@link JobInstance} objects
116+ * associated with the supplied job name.
117+ * @param jobName The name of the job for which to query.
118+ * @return the number of {@link JobInstance}s that exist within the associated job
119+ * repository.
120+ * @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
121+ * jobName specified.
122+ */
123+ long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException ;
124+
125+ /*
126+ * ===================================================================================
127+ * Job execution operations
128+ * ===================================================================================
129+ */
130+
131+ /**
132+ * Retrieve a {@link JobExecution} by its ID. The complete object graph for this
133+ * execution should be returned (unless otherwise indicated), including the parent
134+ * {@link JobInstance} and associated {@link ExecutionContext} and
135+ * {@link StepExecution} instances (also including their execution contexts).
136+ * @param executionId The job execution ID.
137+ * @return the {@link JobExecution} that has this ID or {@code null} if not found.
138+ */
139+ @ Nullable
140+ JobExecution getJobExecution (@ Nullable Long executionId );
141+
110142 /**
111143 * Retrieve job executions by their job instance. The corresponding step executions
112144 * may not be fully hydrated (for example, their execution context may be missing),
@@ -142,32 +174,24 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
142174 */
143175 Set <JobExecution > findRunningJobExecutions (@ Nullable String jobName );
144176
145- /**
146- * Query the repository for all unique {@link JobInstance} names (sorted
147- * alphabetically).
148- * @return the list of job names that have been executed.
149- */
150- List <String > getJobNames ();
151-
152- /**
153- * Fetch {@link JobInstance} values in descending order of creation (and, therefore,
154- * usually of first execution) with a 'like' or wildcard criteria.
155- * @param jobName The name of the job for which to query.
156- * @param start The start index of the instances to return.
157- * @param count The maximum number of instances to return.
158- * @return a list of {@link JobInstance} for the requested job name.
177+ /*
178+ * ===================================================================================
179+ * Step execution operations
180+ * ===================================================================================
159181 */
160- List <JobInstance > findJobInstancesByJobName (String jobName , int start , int count );
161182
162183 /**
163- * Query the repository for the number of unique {@link JobInstance} objects
164- * associated with the supplied job name.
165- * @param jobName The name of the job for which to query.
166- * @return the number of {@link JobInstance}s that exist within the associated job
167- * repository.
168- * @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
169- * jobName specified.
184+ * Retrieve a {@link StepExecution} by its ID and parent {@link JobExecution} ID. The
185+ * execution context for the step should be available in the result, and the parent
186+ * job execution should have its primitive properties, but it may not contain the job
187+ * instance information.
188+ * @param jobExecutionId The parent job execution ID.
189+ * @param stepExecutionId The step execution ID.
190+ * @return the {@link StepExecution} that has this ID or {@code null} if not found.
191+ *
192+ * @see #getJobExecution(Long)
170193 */
171- long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException ;
194+ @ Nullable
195+ StepExecution getStepExecution (@ Nullable Long jobExecutionId , @ Nullable Long stepExecutionId );
172196
173197}
0 commit comments