15
15
*/
16
16
package org .springframework .batch .core .explore ;
17
17
18
+ import java .util .Collections ;
18
19
import java .util .List ;
19
20
import java .util .Set ;
20
21
@@ -51,7 +52,9 @@ public interface JobExplorer {
51
52
* alphabetically).
52
53
* @return the list of job names that have been executed.
53
54
*/
54
- List <String > getJobNames ();
55
+ default List <String > getJobNames () {
56
+ return Collections .emptyList ();
57
+ }
55
58
56
59
/*
57
60
* ===================================================================================
@@ -67,7 +70,9 @@ public interface JobExplorer {
67
70
* @param count The maximum number of instances to return.
68
71
* @return the {@link JobInstance} values up to a maximum of count values.
69
72
*/
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
+ }
71
76
72
77
/**
73
78
* Fetch {@link JobInstance} values in descending order of creation (and, therefore,
@@ -79,8 +84,51 @@ public interface JobExplorer {
79
84
* @deprecated Since v6.0 and scheduled for removal in v6.2. Use
80
85
* {@link #getJobInstances(String, int, int)}
81
86
*/
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
+ }
84
132
85
133
/**
86
134
* Find the last job instance, by ID, for the given job.
@@ -94,13 +142,6 @@ default JobInstance getLastJobInstance(String jobName) {
94
142
throw new UnsupportedOperationException ();
95
143
}
96
144
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
-
104
145
/**
105
146
* @param jobName {@link String} name of the job.
106
147
* @param jobParameters {@link JobParameters} parameters for the job instance.
@@ -123,7 +164,9 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
123
164
* @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
124
165
* jobName specified.
125
166
*/
126
- long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException ;
167
+ default long getJobInstanceCount (@ Nullable String jobName ) throws NoSuchJobException {
168
+ throw new UnsupportedOperationException ();
169
+ }
127
170
128
171
/*
129
172
* ===================================================================================
@@ -140,7 +183,9 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
140
183
* @return the {@link JobExecution} that has this ID or {@code null} if not found.
141
184
*/
142
185
@ Nullable
143
- JobExecution getJobExecution (@ Nullable Long executionId );
186
+ default JobExecution getJobExecution (@ Nullable Long executionId ) {
187
+ throw new UnsupportedOperationException ();
188
+ }
144
189
145
190
/**
146
191
* Retrieve job executions by their job instance. The corresponding step executions
@@ -150,7 +195,23 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
150
195
* @param jobInstance The {@link JobInstance} to query.
151
196
* @return the list of all executions for the specified {@link JobInstance}.
152
197
*/
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
+ }
154
215
155
216
/**
156
217
* Find the last {@link JobExecution} that has been created for a given
@@ -167,6 +228,16 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
167
228
throw new UnsupportedOperationException ();
168
229
}
169
230
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
+
170
241
/**
171
242
* Retrieve running job executions. The corresponding step executions may not be fully
172
243
* hydrated (for example, their execution context may be missing), depending on the
@@ -175,7 +246,9 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
175
246
* @param jobName The name of the job.
176
247
* @return the set of running executions for jobs with the specified name.
177
248
*/
178
- Set <JobExecution > findRunningJobExecutions (@ Nullable String jobName );
249
+ default Set <JobExecution > findRunningJobExecutions (@ Nullable String jobName ) {
250
+ return Collections .emptySet ();
251
+ }
179
252
180
253
/*
181
254
* ===================================================================================
@@ -195,6 +268,27 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
195
268
* @see #getJobExecution(Long)
196
269
*/
197
270
@ 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
+ }
199
293
200
294
}
0 commit comments