public CalendarBasedTimeout getCalendarTimeout() { if (this.calendarTimeout == null) { this.calendarTimeout = new CalendarBasedTimeout(this.getScheduleExpression()); } return this.calendarTimeout; }
if (this.monthHasDate(nextCal, nextDayOfMonth)) { resetTimeToFirstValues(nextCal); nextCal = this.advanceTillMonthHasDate(nextCal, nextDayOfMonth); resetTimeToFirstValues(nextCal); nextCal = this.computeNextMonth(nextCal); if (nextCal == null) { return null; nextCal = this.advanceTillMonthHasDate(nextCal, nextDayOfMonth);
private Calendar getNextTimeout(Calendar currentCal, boolean increment) { if (this.noMoreTimeouts(currentCal)) { return null; nextCal = this.computeNextTime(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextMonth(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextDate(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextYear(nextCal); if (nextCal == null) { return null; if (this.noMoreTimeouts(nextCal)) { return null;
private Calendar computeNextDate(Calendar nextCal) { if (this.isDayOfMonthWildcard()) { return this.computeNextDayOfWeek(nextCal); } if (this.isDayOfWeekWildcard()) { return this.computeNextDayOfMonth(nextCal); } // both day-of-month and day-of-week are *non-wildcards* Calendar nextDayOfMonthCal = this.computeNextDayOfMonth((Calendar) nextCal.clone()); Calendar nextDayOfWeekCal = this.computeNextDayOfWeek((Calendar) nextCal.clone()); if (nextDayOfMonthCal == null) { return nextDayOfWeekCal; } if (nextDayOfWeekCal == null) { return nextDayOfMonthCal; } return nextDayOfWeekCal.getTime().before(nextDayOfMonthCal.getTime()) ? nextDayOfWeekCal : nextDayOfMonthCal; }
private void setFirstTimeout() { Calendar currentCal = new GregorianCalendar(this.timezone); Date start = this.scheduleExpression.getStart(); if (start != null) { currentCal.setTime(start); } else { resetTimeToFirstValues(currentCal); } this.firstTimeout = getNextTimeout(currentCal, false); }
private Calendar advanceTillMonthHasDate(Calendar cal, Integer date) { resetTimeToFirstValues(cal); // make sure the month can handle the date while (monthHasDate(cal, date) == false) { if (cal.get(Calendar.YEAR) > Year.MAX_YEAR) { return null; } // this month can't handle the date, so advance month to next month // and get the next suitable matching month cal.add(Calendar.MONTH, 1); cal = this.computeNextMonth(cal); if (cal == null) { return null; } date = this.dayOfMonth.getFirstMatch(cal); if (date == null) { return null; } } cal.set(Calendar.DAY_OF_MONTH, date); return cal; }
public Calendar getNextTimeout(Calendar currentCal) { if (this.noMoreTimeouts(currentCal)) { return null; Calendar nextCal = this.copy(currentCal); nextCal = this.computeNextSecond(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextMinute(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextHour(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextMonth(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextDate(nextCal); if (nextCal == null) { return null; nextCal = this.computeNextYear(nextCal); if (nextCal == null) { return null;
private Calendar computeNextDayOfMonth(Calendar currentCal) { if (this.noMoreTimeouts(currentCal)) { return null; Calendar nextCal = this.copy(currentCal); if (this.monthHasDate(nextCal, nextDayOfMonth)) { nextCal.set(Calendar.HOUR_OF_DAY, this.hour.getFirst()); } else { nextCal = this.advanceTillMonthHasDate(nextCal, nextDayOfMonth); nextCal = this.computeNextMonth(nextCal); if (nextCal == null) { return null; nextCal = this.advanceTillMonthHasDate(nextCal, nextDayOfMonth);
this.nullCheckScheduleAttributes(schedule); this.scheduleExpression = this.clone(schedule); setFirstTimeout();
private Calendar advanceTillMonthHasDate(Calendar cal, Integer date) { Calendar copy = this.copy(cal); // make sure the month can handle the date while (monthHasDate(copy, date) == false) { if (copy.get(Calendar.YEAR) > Year.MAX_YEAR) { return null; } // this month can't handle the date, so advance month to next month // and get the next suitable matching month copy.add(Calendar.MONTH, 1); copy = this.computeNextMonth(copy); if (copy == null) { return null; } date = this.dayOfMonth.getFirstMatch(copy); if (date == null) { return null; } copy.set(Calendar.SECOND, this.second.getFirst()); copy.set(Calendar.MINUTE, this.minute.getFirst()); copy.set(Calendar.HOUR_OF_DAY, this.hour.getFirst()); } copy.set(Calendar.DAY_OF_MONTH, date); return copy; }
private Calendar computeNextYear(Calendar currentCal) { if (this.noMoreTimeouts(currentCal)) { return null; Calendar nextCal = this.copy(currentCal); nextCal.set(Calendar.DAY_OF_MONTH, 1); nextCal = this.computeNextDate(nextCal); if (nextCal == null) { return null;
public Calendar getNextTimeout(Calendar currentCal) { return getNextTimeout(currentCal, true); }
s.end(builder.scheduleExprEndDate); s.timezone(builder.scheduleExprTimezone); this.calendarTimeout = new CalendarBasedTimeout(s); Calendar nextTimeout = this.calendarTimeout.getNextTimeout(); if (nextTimeout != null) { this.nextExpiration = nextTimeout.getTime();
/** * This method is similar to {@link #getSchedule()}, except that this method does <i>not</i> check the timer state * and hence does <i>not</i> throw either {@link IllegalStateException} or {@link javax.ejb.NoSuchObjectLocalException} * or {@link javax.ejb.EJBException}. * * @return */ public ScheduleExpression getScheduleExpression() { return this.calendarTimeout.getScheduleExpression(); }
resetTimeToFirstValues(nextCal); nextCal = computeNextMonth(nextCal);
private Calendar computeNextYear(Calendar nextCal) { Integer nextYear = this.year.getNextMatch(nextCal); if (nextYear == null || nextYear > Year.MAX_YEAR) { return null; } int currentYear = nextCal.get(Calendar.YEAR); // if the current year is a match, then nothing else to // do. Just return back the calendar if (currentYear == nextYear) { return nextCal; } // If the next year is lesser than the current year, then // we have no more timeouts for the calendar expression if (nextYear < currentYear) { return null; } // at this point we have chosen a year which is greater than the current // year. // set the chosen year nextCal.set(Calendar.YEAR, nextYear); // since we are moving to a different year (as compared to the current year), // we should reset all other calendar attribute expressions appropriately, to their first possible // values nextCal.set(Calendar.MONTH, this.month.getFirstMatch()); nextCal.set(Calendar.DAY_OF_MONTH, 1); resetTimeToFirstValues(nextCal); // recompute date nextCal = this.computeNextDate(nextCal); return nextCal; }
super(id, timerService, calendarTimeout.getFirstTimeout() == null ? null : calendarTimeout.getFirstTimeout() .getTime(), 0, info, persistent, primaryKey, TimerState.CREATED); this.calendarTimeout = calendarTimeout; Calendar nextTimeout = this.calendarTimeout.getNextTimeout(); if (nextTimeout != null) { this.nextExpiration = nextTimeout.getTime();
this.firstTimeout = this.computeNextSecond(this.firstTimeout); if (this.firstTimeout == null) { return; this.firstTimeout = this.computeNextMinute(this.firstTimeout); if (this.firstTimeout == null) { return; this.firstTimeout = this.computeNextHour(this.firstTimeout); if (this.firstTimeout == null) { return; this.firstTimeout = this.computeNextMonth(this.firstTimeout); if (this.firstTimeout == null) { return; this.firstTimeout = this.computeNextDate(this.firstTimeout); if (this.firstTimeout == null) { return; this.firstTimeout = this.computeNextYear(this.firstTimeout); if (this.firstTimeout != null && this.noMoreTimeouts(this.firstTimeout)) { this.firstTimeout = null;
private Calendar computeNextDate(Calendar currentCal) { if (this.noMoreTimeouts(currentCal)) { return null; } if (this.isDayOfMonthWildcard()) { return this.computeNextDayOfWeek(currentCal); } if (this.isDayOfWeekWildcard()) { return this.computeNextDayOfMonth(currentCal); } // both day-of-month and day-of-week are *non-wildcards* Calendar nextDayOfMonthCal = this.computeNextDayOfMonth(currentCal); Calendar nextDayOfWeekCal = this.computeNextDayOfWeek(currentCal); if (nextDayOfMonthCal == null) { return nextDayOfWeekCal; } if (nextDayOfWeekCal == null) { return nextDayOfMonthCal; } return nextDayOfWeekCal.getTime().before(nextDayOfMonthCal.getTime()) ? nextDayOfWeekCal : nextDayOfMonthCal; }
this.nullCheckScheduleAttributes(schedule); this.scheduleExpression = this.clone(schedule); this.setFirstTimeout();