|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
org.quartz.impl.triggers Class CalendarIntervalTriggerImpl
java.lang.Objectorg.quartz.impl.triggers.AbstractTrigger
org.quartz.impl.triggers.CalendarIntervalTriggerImpl
- All Implemented Interfaces:
- Serializable, Cloneable, Comparable<Trigger>, CalendarIntervalTrigger, CoreTrigger, org.quartz.spi.MutableTrigger, org.quartz.spi.OperableTrigger, Trigger
public class CalendarIntervalTriggerImpl
- extends AbstractTrigger
- implements CalendarIntervalTrigger, CoreTrigger
A concrete Trigger that is used to fire a JobDetail
based upon repeating calendar time intervals.
The trigger will fire every N (see setRepeatInterval(int) ) units of calendar time
(see #setRepeatIntervalUnit(IntervalUnit)) as specified in the trigger's definition.
This trigger can achieve schedules that are not possible with SimpleTrigger (e.g
because months are not a fixed number of seconds) or CronTrigger (e.g. because
"every 5 months" is not an even divisor of 12).
If you use an interval unit of MONTH then care should be taken when setting
a startTime value that is on a day near the end of the month. For example,
if you choose a start time that occurs on January 31st, and have a trigger with unit
MONTH and interval 1, then the next fire time will be February 28th,
and the next time after that will be March 28th - and essentially each subsequent firing will
occur on the 28th of the month, even if a 31st day exists. If you want a trigger that always
fires on the last day of the month - regardless of the number of days in the month,
you should use CronTrigger.
- Since:
- 1.7
- Author:
- James House
- See Also:
Trigger,CronTrigger,SimpleTrigger,NthIncludedDayTrigger,TriggerUtils, Serialized Form
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.quartz.Trigger |
|---|
Trigger.CompletedExecutionInstruction, Trigger.TriggerState, Trigger.TriggerTimeComparator |
| Field Summary |
|---|
| Fields inherited from interface org.quartz.CalendarIntervalTrigger |
|---|
MISFIRE_INSTRUCTION_DO_NOTHING, MISFIRE_INSTRUCTION_FIRE_ONCE_NOW |
| Fields inherited from interface org.quartz.Trigger |
|---|
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY |
| Constructor Summary | |
|---|---|
CalendarIntervalTriggerImpl()
Create a DateIntervalTrigger with no settings. |
|
CalendarIntervalTriggerImpl(String name,
DateBuilder.IntervalUnit intervalUnit,
int repeatInterval)
Create a DateIntervalTrigger that will occur immediately, and
repeat at the the given interval. |
|
CalendarIntervalTriggerImpl(String name,
Date startTime,
Date endTime,
DateBuilder.IntervalUnit intervalUnit,
int repeatInterval)
Create a DateIntervalTrigger that will occur at the given time,
and repeat at the the given interval until the given end time. |
|
CalendarIntervalTriggerImpl(String name,
String group,
DateBuilder.IntervalUnit intervalUnit,
int repeatInterval)
Create a DateIntervalTrigger that will occur immediately, and
repeat at the the given interval. |
|
CalendarIntervalTriggerImpl(String name,
String group,
Date startTime,
Date endTime,
DateBuilder.IntervalUnit intervalUnit,
int repeatInterval)
Create a DateIntervalTrigger that will occur at the given time,
and repeat at the the given interval until the given end time. |
|
CalendarIntervalTriggerImpl(String name,
String group,
String jobName,
String jobGroup,
Date startTime,
Date endTime,
DateBuilder.IntervalUnit intervalUnit,
int repeatInterval)
Create a DateIntervalTrigger that will occur at the given time,
fire the identified Job and repeat at the the given
interval until the given end time. |
|
| Method Summary | |
|---|---|
Date |
computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a Trigger is first
added to the scheduler, in order to have the Trigger
compute its first fire time, based on any associated calendar. |
Date |
getEndTime()
Get the time at which the DateIntervalTrigger should quit
repeating. |
Date |
getFinalFireTime()
Returns the final time at which the DateIntervalTrigger will
fire, if there is no end time set, null will be returned. |
Date |
getFireTimeAfter(Date afterTime)
Returns the next time at which the DateIntervalTrigger will
fire, after the given time. |
protected Date |
getFireTimeAfter(Date afterTime,
boolean ignoreEndTime)
|
Date |
getNextFireTime()
Returns the next time at which the Trigger is scheduled to fire. |
Date |
getPreviousFireTime()
Returns the previous time at which the DateIntervalTrigger
fired. |
int |
getRepeatInterval()
Get the the time interval that will be added to the DateIntervalTrigger's
fire time (in the set repeat interval unit) in order to calculate the time of the
next trigger repeat. |
DateBuilder.IntervalUnit |
getRepeatIntervalUnit()
Get the interval unit - the time unit on with the interval applies. |
ScheduleBuilder<CalendarIntervalTrigger> |
getScheduleBuilder()
Get a ScheduleBuilder that is configured to produce a
schedule identical to this trigger's schedule. |
Date |
getStartTime()
Get the time at which the DateIntervalTrigger should occur. |
int |
getTimesTriggered()
Get the number of times the DateIntervalTrigger has already
fired. |
boolean |
hasAdditionalProperties()
|
boolean |
mayFireAgain()
Determines whether or not the DateIntervalTrigger will occur
again. |
void |
setEndTime(Date endTime)
Set the time at which the DateIntervalTrigger should quit
repeating (and be automatically deleted). |
void |
setNextFireTime(Date nextFireTime)
Set the next time at which the DateIntervalTrigger should fire. |
void |
setPreviousFireTime(Date previousFireTime)
Set the previous time at which the DateIntervalTrigger fired. |
void |
setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the DateIntervalTrigger's
fire time (in the set repeat interval unit) in order to calculate the time of the
next trigger repeat. |
void |
setRepeatIntervalUnit(DateBuilder.IntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies. |
void |
setStartTime(Date startTime)
Set the time at which the DateIntervalTrigger should occur. |
void |
setTimesTriggered(int timesTriggered)
Set the number of times the DateIntervalTrigger has already
fired. |
void |
triggered(Calendar calendar)
Called when the Scheduler has decided to 'fire'
the trigger (execute the associated Job), in order to
give the Trigger a chance to update itself for its next
triggering (if any). |
void |
updateAfterMisfire(Calendar cal)
Updates the DateIntervalTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the DateIntervalTrigger
was created. |
void |
updateWithNewCalendar(Calendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client. |
void |
validate()
Validates whether the properties of the JobDetail are
valid for submission into a Scheduler. |
protected boolean |
validateMisfireInstruction(int misfireInstruction)
|
| Methods inherited from class org.quartz.impl.triggers.AbstractTrigger |
|---|
clone, compareTo, equals, executionComplete, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobKey, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerBuilder, hashCode, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobKey, setJobName, setKey, setMisfireInstruction, setName, setPriority, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.quartz.CalendarIntervalTrigger |
|---|
getTriggerBuilder |
| Methods inherited from interface org.quartz.Trigger |
|---|
compareTo, equals, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPriority |
| Constructor Detail |
|---|
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl()
Create a
DateIntervalTriggerwith no settings.
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl(String name, DateBuilder.IntervalUnit intervalUnit, int repeatInterval)
Create a
DateIntervalTriggerthat will occur immediately, and repeat at the the given interval.
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl(String name, String group, DateBuilder.IntervalUnit intervalUnit, int repeatInterval)
Create a
DateIntervalTriggerthat will occur immediately, and repeat at the the given interval.
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl(String name, Date startTime, Date endTime, DateBuilder.IntervalUnit intervalUnit, int repeatInterval)
Create a
DateIntervalTriggerthat will occur at the given time, and repeat at the the given interval until the given end time.- Parameters:
startTime- ADateset to the time for theTriggerto fire.endTime- ADateset to the time for theTriggerto quit repeat firing.intervalUnit- The repeat interval unit (minutes, days, months, etc).repeatInterval- The number of milliseconds to pause between the repeat firing.
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl(String name, String group, Date startTime, Date endTime, DateBuilder.IntervalUnit intervalUnit, int repeatInterval)
Create a
DateIntervalTriggerthat will occur at the given time, and repeat at the the given interval until the given end time.- Parameters:
startTime- ADateset to the time for theTriggerto fire.endTime- ADateset to the time for theTriggerto quit repeat firing.intervalUnit- The repeat interval unit (minutes, days, months, etc).repeatInterval- The number of milliseconds to pause between the repeat firing.
CalendarIntervalTriggerImpl
public CalendarIntervalTriggerImpl(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, DateBuilder.IntervalUnit intervalUnit, int repeatInterval)
Create a
DateIntervalTriggerthat will occur at the given time, fire the identifiedJoband repeat at the the given interval until the given end time.- Parameters:
startTime- ADateset to the time for theTriggerto fire.endTime- ADateset to the time for theTriggerto quit repeat firing.intervalUnit- The repeat interval unit (minutes, days, months, etc).repeatInterval- The number of milliseconds to pause between the repeat firing.
| Method Detail |
|---|
getStartTime
public Date getStartTime()
Get the time at which the
DateIntervalTriggershould occur.- Specified by:
getStartTimein interfaceTrigger- Specified by:
getStartTimein classAbstractTrigger
setStartTime
public void setStartTime(Date startTime)
Set the time at which the
DateIntervalTriggershould occur.- Specified by:
setStartTimein interfaceorg.quartz.spi.MutableTrigger- Specified by:
setStartTimein classAbstractTrigger
- Throws:
IllegalArgumentException- if startTime isnull.
getEndTime
public Date getEndTime()
Get the time at which the
DateIntervalTriggershould quit repeating.- Specified by:
getEndTimein interfaceTrigger- Specified by:
getEndTimein classAbstractTrigger
- See Also:
getFinalFireTime()
setEndTime
public void setEndTime(Date endTime)
Set the time at which the
DateIntervalTriggershould quit repeating (and be automatically deleted).- Specified by:
setEndTimein interfaceorg.quartz.spi.MutableTrigger- Specified by:
setEndTimein classAbstractTrigger
- Throws:
IllegalArgumentException- if endTime is before start time.- See Also:
TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(AbstractTrigger, Calendar, int)
getRepeatIntervalUnit
public DateBuilder.IntervalUnit getRepeatIntervalUnit()
- Description copied from interface:
CalendarIntervalTrigger Get the interval unit - the time unit on with the interval applies.
- Specified by:
getRepeatIntervalUnitin interfaceCalendarIntervalTrigger
setRepeatIntervalUnit
public void setRepeatIntervalUnit(DateBuilder.IntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies.
getRepeatInterval
public int getRepeatInterval()
- Description copied from interface:
CalendarIntervalTrigger Get the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.- Specified by:
getRepeatIntervalin interfaceCalendarIntervalTrigger
setRepeatInterval
public void setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.- Throws:
IllegalArgumentException- if repeatInterval is < 1
getTimesTriggered
public int getTimesTriggered()
- Description copied from interface:
CalendarIntervalTrigger Get the number of times the
DateIntervalTriggerhas already fired.- Specified by:
getTimesTriggeredin interfaceCalendarIntervalTrigger
setTimesTriggered
public void setTimesTriggered(int timesTriggered)
Set the number of times the
DateIntervalTriggerhas already fired.
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction)
- Specified by:
validateMisfireInstructionin classAbstractTrigger
updateAfterMisfire
public void updateAfterMisfire(Calendar cal)
Updates the
DateIntervalTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theDateIntervalTriggerwas created.If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then the following scheme will be used:
- The instruction will be interpreted as
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
- The instruction will be interpreted as
- Specified by:
updateAfterMisfirein interfaceorg.quartz.spi.OperableTrigger- Specified by:
updateAfterMisfirein classAbstractTrigger
triggered
public void triggered(Calendar calendar)
Called when the
Schedulerhas decided to 'fire' the trigger (execute the associatedJob), in order to give theTriggera chance to update itself for its next triggering (if any).- Specified by:
triggeredin interfaceorg.quartz.spi.OperableTrigger- Specified by:
triggeredin classAbstractTrigger
updateWithNewCalendar
public void updateWithNewCalendar(Calendar calendar, long misfireThreshold)
- Description copied from class:
AbstractTrigger This method should not be used by the Quartz client.
To be implemented by the concrete class.
The implementation should update the
Trigger's state based on the given new version of the associatedCalendar(the state should be updated so that it's next fire time is appropriate given the Calendar's new settings).- Specified by:
updateWithNewCalendarin interfaceorg.quartz.spi.OperableTrigger- Specified by:
updateWithNewCalendarin classAbstractTrigger
- See Also:
org.quartz.Trigger#updateWithNewCalendar(org.quartz.Calendar, long)
computeFirstFireTime
public Date computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a
Triggeris first added to the scheduler, in order to have theTriggercompute its first fire time, based on any associated calendar.After this method has been called,
getNextFireTime()should return a valid answer.- Specified by:
computeFirstFireTimein interfaceorg.quartz.spi.OperableTrigger- Specified by:
computeFirstFireTimein classAbstractTrigger
- Returns:
- the first time at which the
Triggerwill be fired by the scheduler, which is also the same valuegetNextFireTime()will return (until after the first firing of theTrigger).
getNextFireTime
public Date getNextFireTime()
Returns the next time at which the
Triggeris scheduled to fire. If the trigger will not fire again,nullwill be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).The value returned is not guaranteed to be valid until after the
Triggerhas been added to the scheduler.- Specified by:
getNextFireTimein interfaceTrigger- Specified by:
getNextFireTimein classAbstractTrigger
- See Also:
TriggerUtils#computeFireTimesBetween(AbstractTrigger, Calendar, Date, Date)
getPreviousFireTime
public Date getPreviousFireTime()
Returns the previous time at which the
DateIntervalTriggerfired. If the trigger has not yet fired,nullwill be returned.- Specified by:
getPreviousFireTimein interfaceTrigger- Specified by:
getPreviousFireTimein classAbstractTrigger
setNextFireTime
public void setNextFireTime(Date nextFireTime)
Set the next time at which the
DateIntervalTriggershould fire.This method should not be invoked by client code.
- Specified by:
setNextFireTimein interfaceorg.quartz.spi.OperableTrigger
setPreviousFireTime
public void setPreviousFireTime(Date previousFireTime)
Set the previous time at which the
DateIntervalTriggerfired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTimein interfaceorg.quartz.spi.OperableTrigger
getFireTimeAfter
public Date getFireTimeAfter(Date afterTime)
Returns the next time at which the
DateIntervalTriggerwill fire, after the given time. If the trigger will not fire after the given time,nullwill be returned.- Specified by:
getFireTimeAfterin interfaceTrigger- Specified by:
getFireTimeAfterin classAbstractTrigger
getFireTimeAfter
protected Date getFireTimeAfter(Date afterTime, boolean ignoreEndTime)
getFinalFireTime
public Date getFinalFireTime()
Returns the final time at which the
DateIntervalTriggerwill fire, if there is no end time set, null will be returned.Note that the return time may be in the past.
- Specified by:
getFinalFireTimein interfaceTrigger- Specified by:
getFinalFireTimein classAbstractTrigger
mayFireAgain
public boolean mayFireAgain()
Determines whether or not the
DateIntervalTriggerwill occur again.- Specified by:
mayFireAgainin interfaceTrigger- Specified by:
mayFireAgainin classAbstractTrigger
validate
public void validate()
throws SchedulerException
Validates whether the properties of the
JobDetailare valid for submission into aScheduler.- Specified by:
validatein interfaceorg.quartz.spi.OperableTrigger- Overrides:
validatein classAbstractTrigger
- Throws:
IllegalStateException- if a required property (such as Name, Group, Class) is not set.SchedulerException
getScheduleBuilder
public ScheduleBuilder<CalendarIntervalTrigger> getScheduleBuilder()
- Get a
ScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule. - Specified by:
getScheduleBuilderin interfaceTrigger- Specified by:
getScheduleBuilderin classAbstractTrigger
- See Also:
AbstractTrigger.getTriggerBuilder()
hasAdditionalProperties
public boolean hasAdditionalProperties()
- Specified by:
hasAdditionalPropertiesin interfaceCoreTrigger
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2001-2011, Terracotta, Inc.
