/** * Called when the <CODE>Scheduler</CODE> has decided to 'fire' the trigger * (execute the associated <CODE>Job</CODE>), in order to give the * <CODE>Trigger</CODE> a chance to update itself for its next triggering * (if any). */ public void triggered(Calendar calendar) { this.calendar = calendar; this.previousFireTime = this.nextFireTime; this.nextFireTime = getFireTimeAfter(this.nextFireTime); }
/** * Called when the <CODE>Scheduler</CODE> has decided to 'fire' the trigger * (execute the associated <CODE>Job</CODE>), in order to give the * <CODE>Trigger</CODE> a chance to update itself for its next triggering * (if any). */ public void triggered(Calendar calendar) { this.calendar = calendar; this.previousFireTime = this.nextFireTime; this.nextFireTime = getFireTimeAfter(this.nextFireTime); }
/** * Called when the <CODE>Scheduler</CODE> has decided to 'fire' the trigger * (execute the associated <CODE>Job</CODE>), in order to give the * <CODE>Trigger</CODE> a chance to update itself for its next triggering * (if any). */ public void triggered(Calendar calendar) { this.calendar = calendar; this.previousFireTime = this.nextFireTime; this.nextFireTime = getFireTimeAfter(this.nextFireTime); }
/** * Called by the scheduler at the time a <CODE>Trigger</code> is first * added to the scheduler, in order to have the <CODE>Trigger</CODE> * compute its first fire time, based on any associated calendar. * <P> * After this method has been called, <CODE>getNextFireTime()</CODE> * should return a valid answer. * </p> * * @return the first time at which the <CODE>Trigger</CODE> will be fired * by the scheduler, which is also the same value * {@link #getNextFireTime()} will return (until after the first * firing of the <CODE>Trigger</CODE>). */ public Date computeFirstFireTime(Calendar calendar) { this.calendar = calendar; this.nextFireTime = getFireTimeAfter(new Date(this.startTime.getTime() - 1000l)); return this.nextFireTime; }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * given new version of the associated <CODE>Calendar</CODE>. * * @param calendar a new or updated calendar to use for the trigger * @param misfireThreshold the amount of time (in milliseconds) that must * be between "now" and the time the next * firing of the trigger is supposed to occur. */ public void updateWithNewCalendar(Calendar calendar, long misfireThreshold) { Date now = new Date(); long diff; this.calendar = calendar; this.nextFireTime = getFireTimeAfter(this.previousFireTime); if ((this.nextFireTime != null) && (this.nextFireTime.before(now))) { diff = now.getTime() - this.nextFireTime.getTime(); if (diff >= misfireThreshold) { this.nextFireTime = getFireTimeAfter(this.nextFireTime); } } }
/** * Called by the scheduler at the time a <CODE>Trigger</code> is first * added to the scheduler, in order to have the <CODE>Trigger</CODE> * compute its first fire time, based on any associated calendar. * <P> * After this method has been called, <CODE>getNextFireTime()</CODE> * should return a valid answer. * </p> * * @return the first time at which the <CODE>Trigger</CODE> will be fired * by the scheduler, which is also the same value * {@link #getNextFireTime()} will return (until after the first * firing of the <CODE>Trigger</CODE>). */ public Date computeFirstFireTime(Calendar calendar) { this.calendar = calendar; this.nextFireTime = getFireTimeAfter(new Date(this.startTime.getTime() - 1000l)); return this.nextFireTime; }
/** * Called by the scheduler at the time a <CODE>Trigger</code> is first * added to the scheduler, in order to have the <CODE>Trigger</CODE> * compute its first fire time, based on any associated calendar. * <P> * After this method has been called, <CODE>getNextFireTime()</CODE> * should return a valid answer. * </p> * * @return the first time at which the <CODE>Trigger</CODE> will be fired * by the scheduler, which is also the same value * {@link #getNextFireTime()} will return (until after the first * firing of the <CODE>Trigger</CODE>). */ public Date computeFirstFireTime(Calendar calendar) { this.calendar = calendar; this.nextFireTime = getFireTimeAfter(new Date(this.startTime.getTime() - 1000l)); return this.nextFireTime; }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * given new version of the associated <CODE>Calendar</CODE>. * * @param calendar a new or updated calendar to use for the trigger * @param misfireThreshold the amount of time (in milliseconds) that must * be between "now" and the time the next * firing of the trigger is supposed to occur. */ public void updateWithNewCalendar(Calendar calendar, long misfireThreshold) { Date now = new Date(); long diff; this.calendar = calendar; this.nextFireTime = getFireTimeAfter(this.previousFireTime); if ((this.nextFireTime != null) && (this.nextFireTime.before(now))) { diff = now.getTime() - this.nextFireTime.getTime(); if (diff >= misfireThreshold) { this.nextFireTime = getFireTimeAfter(this.nextFireTime); } } }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * given new version of the associated <CODE>Calendar</CODE>. * * @param calendar a new or updated calendar to use for the trigger * @param misfireThreshold the amount of time (in milliseconds) that must * be between "now" and the time the next * firing of the trigger is supposed to occur. */ public void updateWithNewCalendar(Calendar calendar, long misfireThreshold) { Date now = new Date(); long diff; this.calendar = calendar; this.nextFireTime = getFireTimeAfter(this.previousFireTime); if ((this.nextFireTime != null) && (this.nextFireTime.before(now))) { diff = now.getTime() - this.nextFireTime.getTime(); if (diff >= misfireThreshold) { this.nextFireTime = getFireTimeAfter(this.nextFireTime); } } }
/** * Returns the last time the <CODE>NthIncludedDayTrigger</CODE> will fire. * If the trigger will not fire at any point between <CODE>startTime</CODE> * and <CODE>endTime</CODE>, or there is not <code>endTime</code>, * <CODE>null</CODE> will be returned. * * @return the last time the trigger will fire, or null if there is no * last time. */ public Date getFinalFireTime() { if(endTime == null) return null; Date finalTime = null; java.util.Calendar currCal = java.util.Calendar.getInstance(); currCal.setTime(this.endTime); while ((finalTime == null) && (this.startTime.before(currCal.getTime()))) { currCal.add(java.util.Calendar.DATE, -1); finalTime = getFireTimeAfter(currCal.getTime()); } return finalTime; }
/** * Returns the last time the <CODE>NthIncludedDayTrigger</CODE> will fire. * If the trigger will not fire at any point between <CODE>startTime</CODE> * and <CODE>endTime</CODE>, or there is not <code>endTime</code>, * <CODE>null</CODE> will be returned. * * @return the last time the trigger will fire, or null if there is no * last time. */ public Date getFinalFireTime() { if(endTime == null) return null; Date finalTime = null; java.util.Calendar currCal = java.util.Calendar.getInstance(); currCal.setTime(this.endTime); while ((finalTime == null) && (this.startTime.before(currCal.getTime()))) { currCal.add(java.util.Calendar.DATE, -1); finalTime = getFireTimeAfter(currCal.getTime()); } return finalTime; }
/** * Returns the last time the <CODE>NthIncludedDayTrigger</CODE> will fire. * If the trigger will not fire at any point between <CODE>startTime</CODE> * and <CODE>endTime</CODE>, or there is not <code>endTime</code>, * <CODE>null</CODE> will be returned. * * @return the last time the trigger will fire, or null if there is no * last time. */ public Date getFinalFireTime() { if(endTime == null) return null; Date finalTime = null; java.util.Calendar currCal = java.util.Calendar.getInstance(); currCal.setTime(this.endTime); while ((finalTime == null) && (this.startTime.before(currCal.getTime()))) { currCal.add(java.util.Calendar.DATE, -1); finalTime = getFireTimeAfter(currCal.getTime()); } return finalTime; }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * MISFIRE_INSTRUCTION_XXX that was selected when the * <CODE>NthIncludedDayTrigger</CODE> was created * <P> * If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, * then the instruction will be interpreted as * {@link #MISFIRE_INSTRUCTION_FIRE_ONCE_NOW}. * * @param calendar a new or updated calendar to use for the trigger */ public void updateAfterMisfire(Calendar calendar) { int instruction = getMisfireInstruction(); this.calendar = calendar; if (instruction == MISFIRE_INSTRUCTION_SMART_POLICY) { instruction = MISFIRE_INSTRUCTION_FIRE_ONCE_NOW; } if (instruction == MISFIRE_INSTRUCTION_DO_NOTHING) { this.nextFireTime = getFireTimeAfter(new Date()); } else if (instruction == MISFIRE_INSTRUCTION_FIRE_ONCE_NOW) { this.nextFireTime = new Date(); } }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * MISFIRE_INSTRUCTION_XXX that was selected when the * <CODE>NthIncludedDayTrigger</CODE> was created * <P> * If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, * then the instruction will be interpreted as * {@link #MISFIRE_INSTRUCTION_FIRE_ONCE_NOW}. * * @param calendar a new or updated calendar to use for the trigger */ public void updateAfterMisfire(Calendar calendar) { int instruction = getMisfireInstruction(); this.calendar = calendar; if (instruction == MISFIRE_INSTRUCTION_SMART_POLICY) { instruction = MISFIRE_INSTRUCTION_FIRE_ONCE_NOW; } if (instruction == MISFIRE_INSTRUCTION_DO_NOTHING) { this.nextFireTime = getFireTimeAfter(new Date()); } else if (instruction == MISFIRE_INSTRUCTION_FIRE_ONCE_NOW) { this.nextFireTime = new Date(); } }
/** * Updates the <CODE>NthIncludedDayTrigger</CODE>'s state based on the * MISFIRE_INSTRUCTION_XXX that was selected when the * <CODE>NthIncludedDayTrigger</CODE> was created * <P> * If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, * then the instruction will be interpreted as * {@link #MISFIRE_INSTRUCTION_FIRE_ONCE_NOW}. * * @param calendar a new or updated calendar to use for the trigger */ public void updateAfterMisfire(Calendar calendar) { int instruction = getMisfireInstruction(); this.calendar = calendar; if (instruction == MISFIRE_INSTRUCTION_SMART_POLICY) { instruction = MISFIRE_INSTRUCTION_FIRE_ONCE_NOW; } if (instruction == MISFIRE_INSTRUCTION_DO_NOTHING) { this.nextFireTime = getFireTimeAfter(new Date()); } else if (instruction == MISFIRE_INSTRUCTION_FIRE_ONCE_NOW) { this.nextFireTime = new Date(); } }