/** * Creates a new {@link Trigger} without using cron. */ protected Trigger() { this.spec = ""; this.tabs = new CronTabList(Collections.<CronTab>emptyList()); }
/** * Performs syntax check. */ public FormValidation doCheck(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if (msg != null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }
private void updateValidationsForNextRun(Collection<FormValidation> validations, CronTabList ctl) { try { Calendar prev = ctl.previous(); Calendar next = ctl.next(); if (prev != null && next != null) { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); validations.add(FormValidation.ok(Messages.TimerTrigger_would_last_have_run_at_would_next_run_at(fmt.format(prev.getTime()), fmt.format(next.getTime())))); } else { validations.add(FormValidation.warning(Messages.TimerTrigger_no_schedules_so_will_never_run())); } } catch (RareOrImpossibleDateException ex) { validations.add(FormValidation.warning(Messages.TimerTrigger_the_specified_cron_tab_is_rare_or_impossible())); } } }
public static CronTabList create(@Nonnull String format, Hash hash) throws ANTLRException { Vector<CronTab> r = new Vector<>(); int lineNumber = 0; String timezone = null; for (String line : format.split("\\r?\\n")) { lineNumber++; line = line.trim(); if(lineNumber == 1 && line.startsWith("TZ=")) { timezone = getValidTimezone(line.replace("TZ=","")); if(timezone != null) { LOGGER.log(Level.CONFIG, "CRON with timezone {0}", timezone); } else { throw new ANTLRException("Invalid or unsupported timezone '" + timezone + "'"); } continue; } if(line.length()==0 || line.startsWith("#")) continue; // ignorable line try { r.add(new CronTab(line,lineNumber,hash,timezone)); } catch (ANTLRException e) { throw new ANTLRException(Messages.CronTabList_InvalidInput(line,e.toString()),e); } } return new CronTabList(r); }
/** * Creates a new {@link Trigger} that gets {@link #run() run} * periodically. This is useful when your trigger does * some polling work. */ protected Trigger(@Nonnull String cronTabSpec) throws ANTLRException { this.spec = cronTabSpec; this.tabs = CronTabList.create(cronTabSpec); }
private void updateValidationsForSanity(Collection<FormValidation> validations, CronTabList ctl) { String msg = ctl.checkSanity(); if(msg!=null) validations.add(FormValidation.warning(msg)); }
public static CronTabList create(@Nonnull String format) throws ANTLRException { return create(format,null); }
public static CronTabList create(@Nonnull String format, Hash hash) throws ANTLRException { Vector<CronTab> r = new Vector<>(); int lineNumber = 0; String timezone = null; for (String line : format.split("\\r?\\n")) { lineNumber++; line = line.trim(); if(lineNumber == 1 && line.startsWith("TZ=")) { timezone = getValidTimezone(line.replace("TZ=","")); if(timezone != null) { LOGGER.log(Level.CONFIG, "CRON with timezone {0}", timezone); } else { throw new ANTLRException("Invalid or unsupported timezone '" + timezone + "'"); } continue; } if(line.length()==0 || line.startsWith("#")) continue; // ignorable line try { r.add(new CronTab(line,lineNumber,hash,timezone)); } catch (ANTLRException e) { throw new ANTLRException(Messages.CronTabList_InvalidInput(line,e.toString()),e); } } return new CronTabList(r); }
private void updateValidationsForSanity(Collection<FormValidation> validations, CronTabList ctl) { String msg = ctl.checkSanity(); if(msg!=null) validations.add(FormValidation.warning(msg)); }
private void updateValidationsForNextRun(Collection<FormValidation> validations, CronTabList ctl) { try { Calendar prev = ctl.previous(); Calendar next = ctl.next(); if (prev != null && next != null) { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); validations.add(FormValidation.ok(Messages.TimerTrigger_would_last_have_run_at_would_next_run_at(fmt.format(prev.getTime()), fmt.format(next.getTime())))); } else { validations.add(FormValidation.warning(Messages.TimerTrigger_no_schedules_so_will_never_run())); } } catch (RareOrImpossibleDateException ex) { validations.add(FormValidation.warning(Messages.TimerTrigger_the_specified_cron_tab_is_rare_or_impossible())); } } }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if(msg!=null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }
@DataBoundConstructor public SimpleScheduledRetentionStrategy(String startTimeSpec, int upTimeMins, boolean keepUpWhenActive) throws ANTLRException { this.startTimeSpec = startTimeSpec; this.keepUpWhenActive = keepUpWhenActive; this.tabs = CronTabList.create(startTimeSpec); this.lastChecked = new GregorianCalendar(); this.upTimeMins = Math.max(1, upTimeMins); this.lastChecked.add(Calendar.MINUTE, -1); }
LOGGER.log(Level.FINE, "cron checking {0} with spec ‘{1}’", new Object[]{p, t.spec.trim()}); if (t.tabs.check(cal)) { LOGGER.log(Level.CONFIG, "cron triggered {0}", p); try {
/** * Creates a new {@link Trigger} without using cron. */ protected Trigger() { this.spec = ""; this.tabs = new CronTabList(Collections.<CronTab>emptyList()); }
/** * Performs syntax check. */ public FormValidation doCheck(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if (msg != null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }
protected Object readResolve() throws ObjectStreamException { try { tabs = CronTabList.create(spec); } catch (ANTLRException e) { InvalidObjectException x = new InvalidObjectException(e.getMessage()); x.initCause(e); throw x; } return this; }
/** * Creates a new {@link Trigger} without using cron. */ protected Trigger() { this.spec = ""; this.tabs = new CronTabList(Collections.<CronTab>emptyList()); }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if(msg!=null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }