|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.quartz.impl.triggers Class CronTriggerImpl
java.lang.Object org.quartz.impl.triggers.AbstractTrigger<CronTrigger> org.quartz.impl.triggers.CronTriggerImpl
- All Implemented Interfaces:
- Serializable, Cloneable, Comparable<Trigger>, CronTrigger, CoreTrigger, org.quartz.spi.MutableTrigger, org.quartz.spi.OperableTrigger, Trigger
public class CronTriggerImpl
- extends AbstractTrigger<CronTrigger>
- implements CronTrigger, CoreTrigger
A concrete Trigger
that is used to fire a JobDetail
at given moments in time, defined with Unix 'cron-like' definitions.
- Author:
- Sharada Jambula, James House, Contributions from Mads Henderson
- See Also:
- Serialized Form
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.quartz.Trigger |
---|
Trigger.CompletedExecutionInstruction, Trigger.TriggerState, Trigger.TriggerTimeComparator |
Field Summary | |
---|---|
protected static int |
YEAR_TO_GIVEUP_SCHEDULING_AT
|
Fields inherited from interface org.quartz.CronTrigger |
---|
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 | |
---|---|
CronTriggerImpl()
Create a CronTrigger with no settings. |
|
CronTriggerImpl(String name)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String cronExpression)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String jobName,
String jobGroup)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String jobName,
String jobGroup,
Date startTime,
Date endTime,
String cronExpression)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String jobName,
String jobGroup,
Date startTime,
Date endTime,
String cronExpression,
TimeZone timeZone)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String jobName,
String jobGroup,
String cronExpression)
Deprecated. use a TriggerBuilder instead |
|
CronTriggerImpl(String name,
String group,
String jobName,
String jobGroup,
String cronExpression,
TimeZone timeZone)
Deprecated. use a TriggerBuilder instead |
Method Summary | |
---|---|
Object |
clone()
|
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. |
String |
getCronExpression()
|
Date |
getEndTime()
Get the time at which the CronTrigger should quit
repeating - even if repeastCount isn't yet satisfied. |
String |
getExpressionSummary()
|
Date |
getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the CronTrigger will fire. |
Date |
getFireTimeAfter(Date afterTime)
Returns the next time at which the CronTrigger will fire,
after the given time. |
Date |
getNextFireTime()
Returns the next time at which the Trigger is scheduled to fire. |
Date |
getPreviousFireTime()
Returns the previous time at which the CronTrigger
fired. |
ScheduleBuilder<CronTrigger> |
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 CronTrigger should occur. |
protected Date |
getTimeAfter(Date afterTime)
|
protected Date |
getTimeBefore(Date endTime)
NOT YET IMPLEMENTED: Returns the time before the given time that this CronTrigger will fire. |
TimeZone |
getTimeZone()
Returns the time zone for which the cronExpression of
this CronTrigger will be resolved. |
boolean |
hasAdditionalProperties()
Used by extensions of CronTrigger to imply that there are additional properties, specifically so that extensions can choose whether to be stored as a serialized blob, or as a flattened CronTrigger table. |
boolean |
mayFireAgain()
Determines whether or not the CronTrigger will occur
again. |
void |
setCronExpression(CronExpression cronExpression)
Set the CronExpression to the given one. |
void |
setCronExpression(String cronExpression)
|
void |
setEndTime(Date endTime)
Set the time at which the Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
void |
setNextFireTime(Date nextFireTime)
Sets the next time at which the CronTrigger will fire. |
void |
setPreviousFireTime(Date previousFireTime)
Set the previous time at which the CronTrigger fired. |
void |
setStartTime(Date startTime)
The time at which the trigger's scheduling should start. |
void |
setTimeZone(TimeZone timeZone)
Sets the time zone for which the cronExpression of this
CronTrigger will be resolved. |
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 CronTrigger 's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the CronTrigger
was created. |
void |
updateWithNewCalendar(Calendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client. |
protected boolean |
validateMisfireInstruction(int misfireInstruction)
|
boolean |
willFireOn(Calendar test)
Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger. |
boolean |
willFireOn(Calendar test,
boolean dayOnly)
Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger. |
Methods inherited from class org.quartz.impl.triggers.AbstractTrigger |
---|
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, validate |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.quartz.CronTrigger |
---|
getTriggerBuilder |
Methods inherited from interface org.quartz.Trigger |
---|
compareTo, equals, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPriority |
Field Detail |
---|
YEAR_TO_GIVEUP_SCHEDULING_AT
protected static final int YEAR_TO_GIVEUP_SCHEDULING_AT
Constructor Detail |
---|
CronTriggerImpl
public CronTriggerImpl()
Create a
CronTrigger
with no settings.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name)
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name and default group.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group)
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name and group.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String cronExpression) throws ParseException
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name, group and expression.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
- Throws:
ParseException
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String jobName, String jobGroup)
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name and group, and associated with the identifiedJobDetail
.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String jobName, String jobGroup, String cronExpression) throws ParseException
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name and group, associated with the identifiedJobDetail
, and with the given "cron" expression.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
- Throws:
ParseException
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String jobName, String jobGroup, String cronExpression, TimeZone timeZone) throws ParseException
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with the given name and group, associated with the identifiedJobDetail
, and with the given "cron" expression resolved with respect to theTimeZone
.- Throws:
ParseException
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, String cronExpression) throws ParseException
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
that will occur at the given time, until the given end time.If null, the start-time will also be set to the current time, the time zone will be set the the system's default.
- Parameters:
startTime
- ADate
set to the time for theTrigger
to fire.endTime
- ADate
set to the time for theTrigger
to quit repeat firing.- Throws:
ParseException
CronTriggerImpl
@Deprecated public CronTriggerImpl(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, String cronExpression, TimeZone timeZone) throws ParseException
- Deprecated. use a TriggerBuilder instead
Create a
CronTrigger
with fire time dictated by thecronExpression
resolved with respect to the specifiedtimeZone
occurring from thestartTime
until the givenendTime
.If null, the start-time will also be set to the current time. If null, the time zone will be set to the system's default.
- Parameters:
name
- of theTrigger
group
- of theTrigger
jobName
- name of theJobDetail
executed on firetimejobGroup
- group of theJobDetail
executed on firetimestartTime
- ADate
set to the earliest time for theTrigger
to start firing.endTime
- ADate
set to the time for theTrigger
to quit repeat firing.cronExpression
- A cron expression dictating the firing sequence of theTrigger
timeZone
- Specifies for which time zone thecronExpression
should be interpreted, i.e. the expression 0 0 10 * * ?, is resolved to 10:00 am in this time zone.- Throws:
ParseException
- if thecronExpression
is invalid.
Method Detail |
---|
clone
public Object clone()
- Specified by:
clone
in interfaceorg.quartz.spi.MutableTrigger
- Overrides:
clone
in classAbstractTrigger<CronTrigger>
setCronExpression
public void setCronExpression(String cronExpression) throws ParseException
- Throws:
ParseException
getCronExpression
public String getCronExpression()
- Specified by:
getCronExpression
in interfaceCronTrigger
setCronExpression
public void setCronExpression(CronExpression cronExpression)
- Set the CronExpression to the given one. The TimeZone on the passed-in
CronExpression over-rides any that was already set on the Trigger.
- Parameters:
cronExpression
-
getStartTime
public Date getStartTime()
Get the time at which the
CronTrigger
should occur.- Specified by:
getStartTime
in interfaceTrigger
- Specified by:
getStartTime
in classAbstractTrigger<CronTrigger>
setStartTime
public void setStartTime(Date startTime)
- Description copied from class:
AbstractTrigger
The time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date.
Setting a value in the past may cause a new trigger to compute a first fire time that is in the past, which may cause an immediate misfire of the trigger.
- Specified by:
setStartTime
in interfaceorg.quartz.spi.MutableTrigger
- Specified by:
setStartTime
in classAbstractTrigger<CronTrigger>
getEndTime
public Date getEndTime()
Get the time at which the
CronTrigger
should quit repeating - even if repeastCount isn't yet satisfied.- Specified by:
getEndTime
in interfaceTrigger
- Specified by:
getEndTime
in classAbstractTrigger<CronTrigger>
- See Also:
getFinalFireTime()
setEndTime
public void setEndTime(Date endTime)
- Description copied from class:
AbstractTrigger
Set the time at which the
Trigger
should quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).- Specified by:
setEndTime
in interfaceorg.quartz.spi.MutableTrigger
- Specified by:
setEndTime
in classAbstractTrigger<CronTrigger>
- See Also:
TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(AbstractTrigger, Calendar, int)
getNextFireTime
public Date getNextFireTime()
Returns the next time at which the
Trigger
is scheduled to fire. If the trigger will not fire again,null
will 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
Trigger
has been added to the scheduler.- Specified by:
getNextFireTime
in interfaceTrigger
- Specified by:
getNextFireTime
in classAbstractTrigger<CronTrigger>
- See Also:
TriggerUtils#computeFireTimesBetween(Trigger, org.quartz.Calendar , Date, Date)
getPreviousFireTime
public Date getPreviousFireTime()
Returns the previous time at which the
CronTrigger
fired. If the trigger has not yet fired,null
will be returned.- Specified by:
getPreviousFireTime
in interfaceTrigger
- Specified by:
getPreviousFireTime
in classAbstractTrigger<CronTrigger>
setNextFireTime
public void setNextFireTime(Date nextFireTime)
Sets the next time at which the
CronTrigger
will fire. This method should not be invoked by client code.- Specified by:
setNextFireTime
in interfaceorg.quartz.spi.OperableTrigger
setPreviousFireTime
public void setPreviousFireTime(Date previousFireTime)
Set the previous time at which the
CronTrigger
fired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTime
in interfaceorg.quartz.spi.OperableTrigger
getTimeZone
public TimeZone getTimeZone()
- Description copied from interface:
CronTrigger
Returns the time zone for which the
cronExpression
of thisCronTrigger
will be resolved.- Specified by:
getTimeZone
in interfaceCronTrigger
setTimeZone
public void setTimeZone(TimeZone timeZone)
Sets the time zone for which the
cronExpression
of thisCronTrigger
will be resolved.If
setCronExpression(CronExpression)
is called after this method, the TimeZon setting on the CronExpression will "win". However ifsetCronExpression(String)
is called after this method, the time zone applied by this method will remain in effect, since the String cron expression does not carry a time zone!
getFireTimeAfter
public Date getFireTimeAfter(Date afterTime)
Returns the next time at which the
CronTrigger
will fire, after the given time. If the trigger will not fire after the given time,null
will be returned.Note that the date returned is NOT validated against the related org.quartz.Calendar (if any)
- Specified by:
getFireTimeAfter
in interfaceTrigger
- Specified by:
getFireTimeAfter
in classAbstractTrigger<CronTrigger>
getFinalFireTime
public Date getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the
CronTrigger
will fire.Note that the return time *may* be in the past. and the date returned is not validated against org.quartz.calendar
- Specified by:
getFinalFireTime
in interfaceTrigger
- Specified by:
getFinalFireTime
in classAbstractTrigger<CronTrigger>
mayFireAgain
public boolean mayFireAgain()
Determines whether or not the
CronTrigger
will occur again.- Specified by:
mayFireAgain
in interfaceTrigger
- Specified by:
mayFireAgain
in classAbstractTrigger<CronTrigger>
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction)
- Specified by:
validateMisfireInstruction
in classAbstractTrigger<CronTrigger>
updateAfterMisfire
public void updateAfterMisfire(Calendar cal)
Updates the
CronTrigger
's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theCronTrigger
was 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:
updateAfterMisfire
in interfaceorg.quartz.spi.OperableTrigger
- Specified by:
updateAfterMisfire
in classAbstractTrigger<CronTrigger>
willFireOn
public boolean willFireOn(Calendar test)
Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.
Equivalent to calling
willFireOn(cal, false)
.- Parameters:
test
- the date to compare- See Also:
willFireOn(Calendar, boolean)
willFireOn
public boolean willFireOn(Calendar test, boolean dayOnly)
Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.
Note that the value returned is NOT validated against the related org.quartz.Calendar (if any)
- Parameters:
test
- the date to comparedayOnly
- if set to true, the method will only determine if the trigger will fire during the day represented by the given Calendar (hours, minutes and seconds will be ignored).- See Also:
willFireOn(Calendar)
triggered
public void triggered(Calendar calendar)
Called when the
Scheduler
has decided to 'fire' the trigger (execute the associatedJob
), in order to give theTrigger
a chance to update itself for its next triggering (if any).- Specified by:
triggered
in interfaceorg.quartz.spi.OperableTrigger
- Specified by:
triggered
in classAbstractTrigger<CronTrigger>
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:
updateWithNewCalendar
in interfaceorg.quartz.spi.OperableTrigger
- Specified by:
updateWithNewCalendar
in classAbstractTrigger<CronTrigger>
- See Also:
org.quartz.Trigger#updateWithNewCalendar(org.quartz.Calendar, long)
computeFirstFireTime
public Date computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a
Trigger
is first added to the scheduler, in order to have theTrigger
compute its first fire time, based on any associated calendar.After this method has been called,
getNextFireTime()
should return a valid answer.- Specified by:
computeFirstFireTime
in interfaceorg.quartz.spi.OperableTrigger
- Specified by:
computeFirstFireTime
in classAbstractTrigger<CronTrigger>
- Returns:
- the first time at which the
Trigger
will be fired by the scheduler, which is also the same valuegetNextFireTime()
will return (until after the first firing of theTrigger
).
getExpressionSummary
public String getExpressionSummary()
- Specified by:
getExpressionSummary
in interfaceCronTrigger
hasAdditionalProperties
public boolean hasAdditionalProperties()
- Used by extensions of CronTrigger to imply that there are additional
properties, specifically so that extensions can choose whether to be
stored as a serialized blob, or as a flattened CronTrigger table.
- Specified by:
hasAdditionalProperties
in interfaceCoreTrigger
getScheduleBuilder
public ScheduleBuilder<CronTrigger> getScheduleBuilder()
- Get a
ScheduleBuilder
that is configured to produce a schedule identical to this trigger's schedule. - Specified by:
getScheduleBuilder
in interfaceTrigger
- Specified by:
getScheduleBuilder
in classAbstractTrigger<CronTrigger>
- See Also:
AbstractTrigger.getTriggerBuilder()
getTimeAfter
protected Date getTimeAfter(Date afterTime)
getTimeBefore
protected Date getTimeBefore(Date endTime)
- NOT YET IMPLEMENTED: Returns the time before the given time
that this
CronTrigger
will fire.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2001-2011, Terracotta, Inc.