44
44
import org .springframework .boot .CommandLineRunner ;
45
45
import org .springframework .context .ApplicationEventPublisher ;
46
46
import org .springframework .context .ApplicationEventPublisherAware ;
47
+ import org .springframework .core .Ordered ;
47
48
import org .springframework .util .PatternMatchUtils ;
48
49
import org .springframework .util .StringUtils ;
49
50
56
57
* @author Jean-Pierre Bergamin
57
58
*/
58
59
public class JobLauncherCommandLineRunner
59
- implements CommandLineRunner , ApplicationEventPublisherAware {
60
+ implements CommandLineRunner , Ordered , ApplicationEventPublisherAware {
61
+
62
+ /**
63
+ * The default order for the command line runner.
64
+ */
65
+ public static final int DEFAULT_ORDER = 0 ;
60
66
61
67
private static final Log logger = LogFactory
62
68
.getLog (JobLauncherCommandLineRunner .class );
@@ -73,6 +79,8 @@ public class JobLauncherCommandLineRunner
73
79
74
80
private Collection <Job > jobs = Collections .emptySet ();
75
81
82
+ private int order = DEFAULT_ORDER ;
83
+
76
84
private ApplicationEventPublisher publisher ;
77
85
78
86
public JobLauncherCommandLineRunner (JobLauncher jobLauncher ,
@@ -81,8 +89,13 @@ public JobLauncherCommandLineRunner(JobLauncher jobLauncher,
81
89
this .jobExplorer = jobExplorer ;
82
90
}
83
91
84
- public void setJobNames (String jobNames ) {
85
- this .jobNames = jobNames ;
92
+ public void setOrder (int order ) {
93
+ this .order = order ;
94
+ }
95
+
96
+ @ Override
97
+ public int getOrder () {
98
+ return this .order ;
86
99
}
87
100
88
101
@ Override
@@ -95,6 +108,10 @@ public void setJobRegistry(JobRegistry jobRegistry) {
95
108
this .jobRegistry = jobRegistry ;
96
109
}
97
110
111
+ public void setJobNames (String jobNames ) {
112
+ this .jobNames = jobNames ;
113
+ }
114
+
98
115
@ Autowired (required = false )
99
116
public void setJobParametersConverter (JobParametersConverter converter ) {
100
117
this .converter = converter ;
0 commit comments