38
38
import org .springframework .batch .core .JobParametersBuilder ;
39
39
import org .springframework .batch .core .JobParametersIncrementer ;
40
40
import org .springframework .batch .core .configuration .JobLocator ;
41
+ import org .springframework .batch .core .configuration .JobRegistry ;
41
42
import org .springframework .batch .core .converter .DefaultJobParametersConverter ;
42
43
import org .springframework .batch .core .converter .JobParametersConverter ;
43
44
import org .springframework .batch .core .repository .explore .JobExplorer ;
74
75
* can be used to load the job and its context from a single location. All dependencies of
75
76
* the launcher will then be satisfied by autowiring by type from the combined application
76
77
* context. Default values are provided for all fields except the {@link JobLauncher} and
77
- * {@link JobLocator } . Therefore, if autowiring fails to set it (it should be noted that
78
+ * {@link JobRegistry } . Therefore, if autowiring fails to set it (it should be noted that
78
79
* dependency checking is disabled because most of the fields have default values and thus
79
80
* don't require dependencies to be fulfilled via autowiring) then an exception will be
80
81
* thrown. It should also be noted that even if an exception is thrown by this class, it
163
164
* {@link BeanDefinitionStoreException} will be thrown. The same exception will also be
164
165
* thrown if there is more than one present. Assuming the JobLauncher has been set
165
166
* correctly, the jobIdentifier argument will be used to obtain an actual {@link Job}. If
166
- * a {@link JobLocator } has been set, then it will be used, if not the beanFactory will be
167
- * asked, using the jobIdentifier as the bean id.
167
+ * a {@link JobRegistry } has been set, then it will be used, if not the beanFactory will
168
+ * be asked, using the jobIdentifier as the bean id.
168
169
* </p>
169
170
*
170
171
* @author Dave Syer
@@ -183,6 +184,8 @@ public class CommandLineJobRunner {
183
184
184
185
private JobLocator jobLocator ;
185
186
187
+ private JobRegistry jobRegistry ;
188
+
186
189
private static SystemExiter systemExiter = new JvmSystemExiter ();
187
190
188
191
private static String message = "" ;
@@ -274,11 +277,22 @@ public void exit(int status) {
274
277
/**
275
278
* {@link JobLocator} to find a job to run.
276
279
* @param jobLocator a {@link JobLocator}
280
+ * @deprecated since 6.0 in favor of {{@link #setJobRegistry(JobRegistry)}}. Scheduled
281
+ * for removal in 6.2 or later.
277
282
*/
283
+ @ Deprecated (since = "6.0" , forRemoval = true )
278
284
public void setJobLocator (JobLocator jobLocator ) {
279
285
this .jobLocator = jobLocator ;
280
286
}
281
287
288
+ /**
289
+ * Set the {@link JobRegistry}.
290
+ * @param jobRegistry a {@link JobRegistry}
291
+ */
292
+ public void setJobRegistry (JobRegistry jobRegistry ) {
293
+ this .jobRegistry = jobRegistry ;
294
+ }
295
+
282
296
/*
283
297
* Start a job by obtaining a combined classpath using the job launcher and job paths.
284
298
* If a JobLocator has been set, then use it to obtain an actual job, if not ask the
@@ -348,9 +362,9 @@ int start(String jobPath, String jobIdentifier, String[] parameters, Set<String>
348
362
}
349
363
350
364
Job job = null ;
351
- if (jobLocator != null ) {
365
+ if (jobRegistry != null ) {
352
366
try {
353
- job = jobLocator .getJob (jobName );
367
+ job = jobRegistry .getJob (jobName );
354
368
}
355
369
catch (NoSuchJobException ignored ) {
356
370
}
0 commit comments