diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java index eb2644c5f7..b205e6d73a 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java @@ -145,10 +145,9 @@ public class CronTriggerFactoryBean implements FactoryBean, BeanNam * Set the start delay in milliseconds. *

The start delay is added to the current system time (when the bean starts) * to control the start time of the trigger. - * @param startDelay the start delay, in milliseconds */ public void setStartDelay(long startDelay) { - Assert.state(startDelay >= 0, "Start delay cannot be negative."); + Assert.isTrue(startDelay >= 0, "Start delay cannot be negative"); this.startDelay = startDelay; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java index 9de1924948..5baffd047d 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java @@ -82,6 +82,8 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea private long repeatInterval; + private int repeatCount = -1; + private int priority; private int misfireInstruction; @@ -143,10 +145,9 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea * Set the start delay in milliseconds. *

The start delay is added to the current system time (when the bean starts) * to control the start time of the trigger. - * @param startDelay the start delay, in milliseconds */ public void setStartDelay(long startDelay) { - Assert.state(startDelay >= 0, "Start delay cannot be negative."); + Assert.isTrue(startDelay >= 0, "Start delay cannot be negative"); this.startDelay = startDelay; } @@ -157,6 +158,14 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea this.repeatInterval = repeatInterval; } + /** + * Specify the number of times this trigger is supposed to fire. + *

Default is to repeat indefinitely. + */ + public void setRepeatCount(int repeatCount) { + this.repeatCount = repeatCount; + } + /** * Specify the priority of this trigger. */ @@ -216,6 +225,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea sti.setJobDataMap(this.jobDataMap); sti.setStartTime(this.startTime); sti.setRepeatInterval(this.repeatInterval); + sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); this.simpleTrigger = sti; @@ -248,7 +258,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea pvs.add("jobDataMap", this.jobDataMap); pvs.add("startTime", this.startTime); pvs.add("repeatInterval", this.repeatInterval); - pvs.add("repeatCount", -1); + pvs.add("repeatCount", this.repeatCount); pvs.add("priority", this.priority); pvs.add("misfireInstruction", this.misfireInstruction); bw.setPropertyValues(pvs);