3838import org .springframework .batch .core .JobParametersBuilder ;
3939import org .springframework .batch .core .JobParametersIncrementer ;
4040import org .springframework .batch .core .configuration .JobLocator ;
41+ import org .springframework .batch .core .configuration .JobRegistry ;
4142import org .springframework .batch .core .converter .DefaultJobParametersConverter ;
4243import org .springframework .batch .core .converter .JobParametersConverter ;
4344import org .springframework .batch .core .repository .explore .JobExplorer ;
7475 * can be used to load the job and its context from a single location. All dependencies of
7576 * the launcher will then be satisfied by autowiring by type from the combined application
7677 * 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
7879 * dependency checking is disabled because most of the fields have default values and thus
7980 * don't require dependencies to be fulfilled via autowiring) then an exception will be
8081 * thrown. It should also be noted that even if an exception is thrown by this class, it
163164 * {@link BeanDefinitionStoreException} will be thrown. The same exception will also be
164165 * thrown if there is more than one present. Assuming the JobLauncher has been set
165166 * 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.
168169 * </p>
169170 *
170171 * @author Dave Syer
@@ -183,6 +184,8 @@ public class CommandLineJobRunner {
183184
184185 private JobLocator jobLocator ;
185186
187+ private JobRegistry jobRegistry ;
188+
186189 private static SystemExiter systemExiter = new JvmSystemExiter ();
187190
188191 private static String message = "" ;
@@ -274,11 +277,22 @@ public void exit(int status) {
274277 /**
275278 * {@link JobLocator} to find a job to run.
276279 * @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.
277282 */
283+ @ Deprecated (since = "6.0" , forRemoval = true )
278284 public void setJobLocator (JobLocator jobLocator ) {
279285 this .jobLocator = jobLocator ;
280286 }
281287
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+
282296 /*
283297 * Start a job by obtaining a combined classpath using the job launcher and job paths.
284298 * 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>
348362 }
349363
350364 Job job = null ;
351- if (jobLocator != null ) {
365+ if (jobRegistry != null ) {
352366 try {
353- job = jobLocator .getJob (jobName );
367+ job = jobRegistry .getJob (jobName );
354368 }
355369 catch (NoSuchJobException ignored ) {
356370 }
0 commit comments