/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 minute interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInMinutes(1) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 second interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInSeconds(1) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of seconds. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count, int seconds) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInSeconds(seconds) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of hours. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count, int hours) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInHours(hours) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of hours. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count, int hours) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInHours(hours) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 minute interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInMinutes(1) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 hour interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInHours(1) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of minutes. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count, int minutes) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInMinutes(minutes) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of minutes. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count, int minutes) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInMinutes(minutes) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 second interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInSeconds(1) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with an interval of the given number of seconds. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count, int seconds) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInSeconds(seconds) .withRepeatCount(count - 1); }
/** * Create a SimpleScheduleBuilder set to repeat the given number * of times - 1 with a 1 hour interval. * * <p>Note: Total count = 1 (at start time) + repeat count</p> * * @return the new SimpleScheduleBuilder */ public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count) { if(count < 1) throw new IllegalArgumentException("Total count of firings must be at least one! Given count: " + count); return simpleSchedule() .withIntervalInHours(1) .withRepeatCount(count - 1); }
public TriggerPropertyBundle loadExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(Util.rtp(SELECT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral)); ps.setString(1, triggerKey.getName()); ps.setString(2, triggerKey.getGroup()); rs = ps.executeQuery(); if (rs.next()) { int repeatCount = rs.getInt(COL_REPEAT_COUNT); long repeatInterval = rs.getLong(COL_REPEAT_INTERVAL); int timesTriggered = rs.getInt(COL_TIMES_TRIGGERED); SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withRepeatCount(repeatCount) .withIntervalInMilliseconds(repeatInterval); String[] statePropertyNames = { "timesTriggered" }; Object[] statePropertyValues = { timesTriggered }; return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues); } throw new IllegalStateException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral)); } finally { Util.closeResultSet(rs); Util.closeStatement(ps); } }
public TriggerPropertyBundle loadExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(Util.rtp(SELECT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral)); ps.setString(1, triggerKey.getName()); ps.setString(2, triggerKey.getGroup()); rs = ps.executeQuery(); if (rs.next()) { int repeatCount = rs.getInt(COL_REPEAT_COUNT); long repeatInterval = rs.getLong(COL_REPEAT_INTERVAL); int timesTriggered = rs.getInt(COL_TIMES_TRIGGERED); SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withRepeatCount(repeatCount) .withIntervalInMilliseconds(repeatInterval); String[] statePropertyNames = { "timesTriggered" }; Object[] statePropertyValues = { timesTriggered }; return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues); } throw new IllegalStateException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral)); } finally { Util.closeResultSet(rs); Util.closeStatement(ps); } }
.withIntervalInMilliseconds(interval[0]); if (interval[2] > 0) { sb = sb.withRepeatCount(interval[2].intValue()); } else { sb = sb.repeatForever();
.withRepeatCount(repeatCount);
.withRepeatCount(repeatCount);
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() { SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(getRepeatInterval()) .withRepeatCount(getRepeatCount()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount(); break; } return sb; }
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() { SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(getRepeatInterval()) .withRepeatCount(getRepeatCount()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount(); break; } return sb; }
private Trigger genTriggerInstance(TriggerKey tk, JobDetail jd, Long interval, Integer repeatCount) { return newTrigger().withIdentity(tk).forJob(jd).startNow() .withSchedule(simpleSchedule().withIntervalInMilliseconds (interval).withRepeatCount(repeatCount)) .build(); }