Skip to content

Commit aeef8c8

Browse files
committed
added "repeatCount" bean property to Quartz SimpleTriggerFactoryBean
Issue: SPR-9521
1 parent 556c6a7 commit aeef8c8

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,9 +56,7 @@
5656
* @since 3.1
5757
* @see #setName
5858
* @see #setGroup
59-
* @see #setStartTime
60-
* @see #setJobName
61-
* @see #setJobGroup
59+
* @see #setStartDelay
6260
* @see #setJobDetail
6361
* @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers
6462
* @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails
@@ -147,10 +145,9 @@ public void setJobDataAsMap(Map<String, ?> jobDataAsMap) {
147145
* Set the start delay in milliseconds.
148146
* <p>The start delay is added to the current system time (when the bean starts)
149147
* to control the start time of the trigger.
150-
* @param startDelay the start delay, in milliseconds
151148
*/
152149
public void setStartDelay(long startDelay) {
153-
Assert.state(startDelay >= 0, "Start delay cannot be negative.");
150+
Assert.isTrue(startDelay >= 0, "Start delay cannot be negative");
154151
this.startDelay = startDelay;
155152
}
156153

org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,9 +56,7 @@
5656
* @since 3.1
5757
* @see #setName
5858
* @see #setGroup
59-
* @see #setStartTime
60-
* @see #setJobName
61-
* @see #setJobGroup
59+
* @see #setStartDelay
6260
* @see #setJobDetail
6361
* @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers
6462
* @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails
@@ -84,6 +82,8 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
8482

8583
private long repeatInterval;
8684

85+
private int repeatCount = -1;
86+
8787
private int priority;
8888

8989
private int misfireInstruction;
@@ -145,10 +145,9 @@ public void setJobDataAsMap(Map<String, ?> jobDataAsMap) {
145145
* Set the start delay in milliseconds.
146146
* <p>The start delay is added to the current system time (when the bean starts)
147147
* to control the start time of the trigger.
148-
* @param startDelay the start delay, in milliseconds
149148
*/
150149
public void setStartDelay(long startDelay) {
151-
Assert.state(startDelay >= 0, "Start delay cannot be negative.");
150+
Assert.isTrue(startDelay >= 0, "Start delay cannot be negative");
152151
this.startDelay = startDelay;
153152
}
154153

@@ -159,6 +158,14 @@ public void setRepeatInterval(long repeatInterval) {
159158
this.repeatInterval = repeatInterval;
160159
}
161160

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+
162169
/**
163170
* Specify the priority of this trigger.
164171
*/
@@ -218,6 +225,7 @@ else if (this.startTime == null) {
218225
sti.setJobDataMap(this.jobDataMap);
219226
sti.setStartTime(this.startTime);
220227
sti.setRepeatInterval(this.repeatInterval);
228+
sti.setRepeatCount(this.repeatCount);
221229
sti.setPriority(this.priority);
222230
sti.setMisfireInstruction(this.misfireInstruction);
223231
this.simpleTrigger = sti;
@@ -250,7 +258,7 @@ else if (this.startTime == null) {
250258
pvs.add("jobDataMap", this.jobDataMap);
251259
pvs.add("startTime", this.startTime);
252260
pvs.add("repeatInterval", this.repeatInterval);
253-
pvs.add("repeatCount", -1);
261+
pvs.add("repeatCount", this.repeatCount);
254262
pvs.add("priority", this.priority);
255263
pvs.add("misfireInstruction", this.misfireInstruction);
256264
bw.setPropertyValues(pvs);

0 commit comments

Comments
 (0)