1515 */
1616package org .springframework .batch .core .explore ;
1717
18+ import java .util .Collections ;
1819import java .util .List ;
1920import java .util .Set ;
2021
@@ -51,7 +52,9 @@ public interface JobExplorer {
5152 * alphabetically).
5253 * @return the list of job names that have been executed.
5354 */
54- List <String > getJobNames ();
55+ default List <String > getJobNames () {
56+ return Collections .emptyList ();
57+ }
5558
5659 /*
5760 * ===================================================================================
@@ -67,7 +70,9 @@ public interface JobExplorer {
6770 * @param count The maximum number of instances to return.
6871 * @return the {@link JobInstance} values up to a maximum of count values.
6972 */
70- List <JobInstance > getJobInstances (String jobName , int start , int count );
73+ default List <JobInstance > getJobInstances (String jobName , int start , int count ) {
74+ return Collections .emptyList ();
75+ }
7176
7277 /**
7378 * Fetch {@link JobInstance} values in descending order of creation (and, therefore,
@@ -79,8 +84,51 @@ public interface JobExplorer {
7984 * @deprecated Since v6.0 and scheduled for removal in v6.2. Use
8085 * {@link #getJobInstances(String, int, int)}
8186 */
82- @ Deprecated (forRemoval = true )
83- List <JobInstance > findJobInstancesByJobName (String jobName , int start , int count );
87+ @ Deprecated (since = "6.0" , forRemoval = true )
88+ default List <JobInstance > findJobInstancesByJobName (String jobName , int start , int count ) {
89+ return Collections .emptyList ();
90+ }
91+
92+ /**
93+ * Fetch the last job instances with the provided name, sorted backwards by primary
94+ * key, using a 'like' criteria
95+ * @param jobName {@link String} containing the name of the job.
96+ * @param start int containing the offset of where list of job instances results
97+ * should begin.
98+ * @param count int containing the number of job instances to return.
99+ * @return a list of {@link JobInstance} for the job name requested.
100+ * @since 5.0
101+ * @deprecated since v6.0 and scheduled for removal in v6.2. Use
102+ * {@link #getJobInstances(String, int, int)}
103+ */
104+ @ Deprecated (since = "6.0" , forRemoval = true )
105+ default List <JobInstance > findJobInstancesByName (String jobName , int start , int count ) {
106+ return Collections .emptyList ();
107+ }
108+
109+ /**
110+ * Check if an instance of this job already exists with the parameters provided.
111+ * @param jobName the name of the job
112+ * @param jobParameters the parameters to match
113+ * @return true if a {@link JobInstance} already exists for this job name and job
114+ * parameters
115+ * @deprecated Since v6.0 and scheduled for removal in v6.2. Use
116+ * {@link #getJobInstance(String, JobParameters)} and check for {@code null} result
117+ * instead.
118+ */
119+ @ Deprecated (since = "6.0" , forRemoval = true )
120+ default boolean isJobInstanceExists (String jobName , JobParameters jobParameters ) {
121+ return getJobInstance (jobName , jobParameters ) != null ;
122+ }
123+
124+ /**
125+ * @param instanceId {@link Long} The ID for the {@link JobInstance} to obtain.
126+ * @return the {@code JobInstance} that has this ID, or {@code null} if not found.
127+ */
128+ @ Nullable
129+ default JobInstance getJobInstance (@ Nullable Long instanceId ) {
130+ throw new UnsupportedOperationException ();
131+ }
84132
85133 /**
86134 * Find the last job instance, by ID, for the given job.
@@ -94,13 +142,6 @@ default JobInstance getLastJobInstance(String jobName) {
94142 throw new UnsupportedOperationException ();
95143 }
96144
97- /**
98- * @param instanceId {@link Long} The ID for the {@link JobInstance} to obtain.
99- * @return the {@code JobInstance} that has this ID, or {@code null} if not found.
100- */
101- @ Nullable
102- JobInstance getJobInstance (@ Nullable Long instanceId );
103-
104145 /**
105146 * @param jobName {@link String} name of the job.
106147 * @param jobParameters {@link JobParameters} parameters for the job instance.
@@ -123,7 +164,9 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
123164 * @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
124165 * jobName specified.
125166 */
126- long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException ;
167+ default long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException {
168+ throw new UnsupportedOperationException ();
169+ }
127170
128171 /*
129172 * ===================================================================================
@@ -140,7 +183,9 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
140183 * @return the {@link JobExecution} that has this ID or {@code null} if not found.
141184 */
142185 @ Nullable
143- JobExecution getJobExecution (@ Nullable Long executionId );
186+ default JobExecution getJobExecution (@ Nullable Long executionId ) {
187+ throw new UnsupportedOperationException ();
188+ }
144189
145190 /**
146191 * Retrieve job executions by their job instance. The corresponding step executions
@@ -150,7 +195,23 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
150195 * @param jobInstance The {@link JobInstance} to query.
151196 * @return the list of all executions for the specified {@link JobInstance}.
152197 */
153- List <JobExecution > getJobExecutions (JobInstance jobInstance );
198+ default List <JobExecution > getJobExecutions (JobInstance jobInstance ) {
199+ return Collections .emptyList ();
200+ }
201+
202+ /**
203+ * Return all {@link JobExecution}s for given {@link JobInstance}, sorted backwards by
204+ * creation order (so the first element is the most recent).
205+ * @param jobInstance parent {@link JobInstance} of the {@link JobExecution}s to find.
206+ * @return {@link List} containing JobExecutions for the jobInstance.
207+ * @since 5.0
208+ * @deprecated since v6.0 and scheduled for removal in v6.2. Use
209+ * {@link #getJobExecutions(JobInstance)}
210+ */
211+ @ Deprecated (since = "6.0" , forRemoval = true )
212+ default List <JobExecution > findJobExecutions (JobInstance jobInstance ) {
213+ return Collections .emptyList ();
214+ }
154215
155216 /**
156217 * Find the last {@link JobExecution} that has been created for a given
@@ -167,6 +228,16 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
167228 throw new UnsupportedOperationException ();
168229 }
169230
231+ /**
232+ * @param jobName the name of the job that might have run
233+ * @param jobParameters parameters identifying the {@link JobInstance}
234+ * @return the last execution of job if exists, null otherwise
235+ */
236+ @ Nullable
237+ default JobExecution getLastJobExecution (String jobName , JobParameters jobParameters ) {
238+ throw new UnsupportedOperationException ();
239+ }
240+
170241 /**
171242 * Retrieve running job executions. The corresponding step executions may not be fully
172243 * hydrated (for example, their execution context may be missing), depending on the
@@ -175,7 +246,9 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
175246 * @param jobName The name of the job.
176247 * @return the set of running executions for jobs with the specified name.
177248 */
178- Set <JobExecution > findRunningJobExecutions (@ Nullable String jobName );
249+ default Set <JobExecution > findRunningJobExecutions (@ Nullable String jobName ) {
250+ return Collections .emptySet ();
251+ }
179252
180253 /*
181254 * ===================================================================================
@@ -195,6 +268,27 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
195268 * @see #getJobExecution(Long)
196269 */
197270 @ Nullable
198- StepExecution getStepExecution (@ Nullable Long jobExecutionId , @ Nullable Long stepExecutionId );
271+ default StepExecution getStepExecution (@ Nullable Long jobExecutionId , @ Nullable Long stepExecutionId ) {
272+ throw new UnsupportedOperationException ();
273+ }
274+
275+ /**
276+ * @param jobInstance {@link JobInstance} instance containing the step executions.
277+ * @param stepName the name of the step execution that might have run.
278+ * @return the last execution of step for the given job instance.
279+ */
280+ @ Nullable
281+ default StepExecution getLastStepExecution (JobInstance jobInstance , String stepName ) {
282+ throw new UnsupportedOperationException ();
283+ }
284+
285+ /**
286+ * @param jobInstance {@link JobInstance} instance containing the step executions.
287+ * @param stepName the name of the step execution that might have run.
288+ * @return the execution count of the step within the given job instance.
289+ */
290+ default long getStepExecutionCount (JobInstance jobInstance , String stepName ) {
291+ throw new UnsupportedOperationException ();
292+ }
199293
200294}
0 commit comments