@@ -82,6 +82,8 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
82
82
83
83
private long repeatInterval ;
84
84
85
+ private int repeatCount = -1 ;
86
+
85
87
private int priority ;
86
88
87
89
private int misfireInstruction ;
@@ -143,10 +145,9 @@ public void setJobDataAsMap(Map<String, ?> jobDataAsMap) {
143
145
* Set the start delay in milliseconds.
144
146
* <p>The start delay is added to the current system time (when the bean starts)
145
147
* to control the start time of the trigger.
146
- * @param startDelay the start delay, in milliseconds
147
148
*/
148
149
public void setStartDelay (long startDelay ) {
149
- Assert .state (startDelay >= 0 , "Start delay cannot be negative. " );
150
+ Assert .isTrue (startDelay >= 0 , "Start delay cannot be negative" );
150
151
this .startDelay = startDelay ;
151
152
}
152
153
@@ -157,6 +158,14 @@ public void setRepeatInterval(long repeatInterval) {
157
158
this .repeatInterval = repeatInterval ;
158
159
}
159
160
161
+ /**
162
+ * Specify the number of times this trigger is supposed to fire.
163
+ * <p>Default is to repeat indefinitely.
164
+ */
165
+ public void setRepeatCount (int repeatCount ) {
166
+ this .repeatCount = repeatCount ;
167
+ }
168
+
160
169
/**
161
170
* Specify the priority of this trigger.
162
171
*/
@@ -216,6 +225,7 @@ else if (this.startTime == null) {
216
225
sti.setJobDataMap(this.jobDataMap);
217
226
sti.setStartTime(this.startTime);
218
227
sti.setRepeatInterval(this.repeatInterval);
228
+ sti.setRepeatCount(this.repeatCount);
219
229
sti.setPriority(this.priority);
220
230
sti.setMisfireInstruction(this.misfireInstruction);
221
231
this.simpleTrigger = sti;
@@ -248,7 +258,7 @@ else if (this.startTime == null) {
248
258
pvs .add ("jobDataMap" , this .jobDataMap );
249
259
pvs .add ("startTime" , this .startTime );
250
260
pvs .add ("repeatInterval" , this .repeatInterval );
251
- pvs .add ("repeatCount" , - 1 );
261
+ pvs .add ("repeatCount" , this . repeatCount );
252
262
pvs .add ("priority" , this .priority );
253
263
pvs .add ("misfireInstruction" , this .misfireInstruction );
254
264
bw .setPropertyValues (pvs );
0 commit comments