|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.quartz.impl.triggers Class AbstractTrigger<T extends Trigger>
java.lang.Object org.quartz.impl.triggers.AbstractTrigger<T>
- All Implemented Interfaces:
- Serializable, Cloneable, Comparable<Trigger>, org.quartz.spi.MutableTrigger, org.quartz.spi.OperableTrigger, Trigger
- Direct Known Subclasses:
- CalendarIntervalTriggerImpl, CronTriggerImpl, SimpleTriggerImpl
public abstract class AbstractTrigger<T extends Trigger>
- extends Object
- implements org.quartz.spi.OperableTrigger
The base abstract class to be extended by all Trigger
s.
Triggers
s have a name and group associated with them, which
should uniquely identify them within a single Scheduler
.
Trigger
s are the 'mechanism' by which Job
s
are scheduled. Many Trigger
s can point to the same Job
,
but a single Trigger
can only point to one Job
.
Triggers can 'send' parameters/data to Job
s by placing contents
into the JobDataMap
on the Trigger
.
- Author:
- James House, Sharada Jambula
- See Also:
SimpleTrigger
,CronTrigger
,NthIncludedDayTrigger
,TriggerUtils
,JobDataMap
,JobExecutionContext
, 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.Trigger |
---|
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY |
Constructor Summary | |
---|---|
AbstractTrigger()
Create a Trigger with no specified name, group, or
JobDetail . |
|
AbstractTrigger(String name)
Create a Trigger with the given name, and default group. |
|
AbstractTrigger(String name,
String group)
Create a Trigger with the given name, and group. |
|
AbstractTrigger(String name,
String group,
String jobName,
String jobGroup)
Create a Trigger with the given name, and group. |
Method Summary | |
---|---|
Object |
clone()
|
int |
compareTo(Trigger other)
Compare the next fire time of this Trigger to that of
another by comparing their keys, or in other words, sorts them
according to the natural (i.e. |
abstract Date |
computeFirstFireTime(Calendar calendar)
This method should not be used by the Quartz client. |
boolean |
equals(Object o)
Trigger equality is based upon the equality of the TriggerKey. |
Trigger.CompletedExecutionInstruction |
executionComplete(JobExecutionContext context,
JobExecutionException result)
This method should not be used by the Quartz client. |
String |
getCalendarName()
Get the name of the
Calendar associated with this
Trigger. |
String |
getDescription()
Return the description given to the Trigger instance by
its creator (if any). |
abstract Date |
getEndTime()
Get the time at which the Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
abstract Date |
getFinalFireTime()
Returns the last time at which the Trigger will fire, if
the Trigger will repeat indefinitely, null will be returned. |
String |
getFireInstanceId()
This method should not be used by the Quartz client. |
abstract Date |
getFireTimeAfter(Date afterTime)
Returns the next time at which the Trigger will fire,
after the given time. |
String |
getFullJobName()
Returns the 'full name' of the Job that the Trigger
points to, in the format "group.name". |
String |
getFullName()
Returns the 'full name' of the Trigger in the format
"group.name". |
String |
getGroup()
Get the group of this Trigger . |
JobDataMap |
getJobDataMap()
Get the JobDataMap that is associated with the
Trigger . |
String |
getJobGroup()
Get the name of the associated
JobDetail 's
group. |
JobKey |
getJobKey()
|
String |
getJobName()
Get the name of the associated
JobDetail . |
TriggerKey |
getKey()
|
int |
getMisfireInstruction()
Get the instruction the Scheduler should be given for
handling misfire situations for this Trigger - the
concrete Trigger type that you are using will have
defined a set of additional MISFIRE_INSTRUCTION_XXX
constants that may be passed to this method. |
String |
getName()
Get the name of this Trigger . |
abstract Date |
getNextFireTime()
Returns the next time at which the Trigger is scheduled to fire. |
abstract Date |
getPreviousFireTime()
Returns the previous time at which the Trigger fired. |
int |
getPriority()
The priority of a Trigger acts as a tiebreaker such that if
two Trigger s have the same scheduled fire time, then the
one with the higher priority will get first access to a worker
thread. |
abstract ScheduleBuilder<T> |
getScheduleBuilder()
Get a ScheduleBuilder that is configured to produce a
schedule identical to this trigger's schedule. |
abstract Date |
getStartTime()
Get the time at which the Trigger should occur. |
TriggerBuilder<T> |
getTriggerBuilder()
Get a TriggerBuilder that is configured to produce a
Trigger identical to this one. |
int |
hashCode()
|
abstract boolean |
mayFireAgain()
Used by the
Scheduler to determine whether or not
it is possible for this Trigger to fire again. |
void |
setCalendarName(String calendarName)
Associate the
Calendar with the given name with
this Trigger. |
void |
setDescription(String description)
Set a description for the Trigger instance - may be
useful for remembering/displaying the purpose of the trigger, though the
description has no meaning to Quartz. |
abstract 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 |
setFireInstanceId(String id)
This method should not be used by the Quartz client. |
void |
setGroup(String group)
Set the name of this Trigger . |
void |
setJobDataMap(JobDataMap jobDataMap)
Set the JobDataMap to be associated with the
Trigger . |
void |
setJobGroup(String jobGroup)
Set the name of the associated
JobDetail 's
group. |
void |
setJobKey(JobKey key)
|
void |
setJobName(String jobName)
Set the name of the associated
JobDetail . |
void |
setKey(TriggerKey key)
|
void |
setMisfireInstruction(int misfireInstruction)
Set the instruction the Scheduler should be given for
handling misfire situations for this Trigger - the
concrete Trigger type that you are using will have
defined a set of additional MISFIRE_INSTRUCTION_XXX
constants that may be passed to this method. |
void |
setName(String name)
Set the name of this Trigger . |
void |
setPriority(int priority)
The priority of a Trigger acts as a tie breaker such that if
two Trigger s have the same scheduled fire time, then Quartz
will do its best to give the one with the higher priority first access
to a worker thread. |
abstract void |
setStartTime(Date startTime)
The time at which the trigger's scheduling should start. |
String |
toString()
Return a simple string representation of this object. |
abstract void |
triggered(Calendar calendar)
This method should not be used by the Quartz client. |
abstract void |
updateAfterMisfire(Calendar cal)
This method should not be used by the Quartz client. |
abstract void |
updateWithNewCalendar(Calendar cal,
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 abstract boolean |
validateMisfireInstruction(int misfireInstruction)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.quartz.spi.OperableTrigger |
---|
setNextFireTime, setPreviousFireTime |
Constructor Detail |
---|
AbstractTrigger
public AbstractTrigger()
Create a
Trigger
with no specified name, group, orJobDetail
.Note that the
setName(String)
,setGroup(String)
and thesetJobName(String)
andsetJobGroup(String)
methods must be called before theTrigger
can be placed into aScheduler
.
AbstractTrigger
public AbstractTrigger(String name)
Create a
Trigger
with the given name, and default group.Note that the
setJobName(String)
andsetJobGroup(String)
methods must be called before theTrigger
can be placed into aScheduler
.- Parameters:
group
- ifnull
, Scheduler.DEFAULT_GROUP will be used.- Throws:
IllegalArgumentException
- if name is null or empty, or the group is an empty string.
AbstractTrigger
public AbstractTrigger(String name, String group)
Create a
Trigger
with the given name, and group.Note that the
setJobName(String)
andsetJobGroup(String)
methods must be called before theTrigger
can be placed into aScheduler
.- Parameters:
group
- ifnull
, Scheduler.DEFAULT_GROUP will be used.- Throws:
IllegalArgumentException
- if name is null or empty, or the group is an empty string.
AbstractTrigger
public AbstractTrigger(String name, String group, String jobName, String jobGroup)
Create a
Trigger
with the given name, and group.- Parameters:
group
- ifnull
, Scheduler.DEFAULT_GROUP will be used.- Throws:
IllegalArgumentException
- if name is null or empty, or the group is an empty string.
Method Detail |
---|
getName
public String getName()
Get the name of this
Trigger
.
setName
public void setName(String name)
Set the name of this
Trigger
.- Throws:
IllegalArgumentException
- if name is null or empty.
getGroup
public String getGroup()
Get the group of this
Trigger
.
setGroup
public void setGroup(String group)
Set the name of this
Trigger
.- Parameters:
group
- ifnull
, Scheduler.DEFAULT_GROUP will be used.- Throws:
IllegalArgumentException
- if group is an empty string.
setKey
public void setKey(TriggerKey key)
- Specified by:
setKey
in interfaceorg.quartz.spi.MutableTrigger
getJobName
public String getJobName()
Get the name of the associated
JobDetail
.
setJobName
public void setJobName(String jobName)
Set the name of the associated
JobDetail
.- Throws:
IllegalArgumentException
- if jobName is null or empty.
getJobGroup
public String getJobGroup()
Get the name of the associated
JobDetail
's group.
setJobGroup
public void setJobGroup(String jobGroup)
Set the name of the associated
JobDetail
's group.- Parameters:
jobGroup
- ifnull
, Scheduler.DEFAULT_GROUP will be used.- Throws:
IllegalArgumentException
- if group is an empty string.
setJobKey
public void setJobKey(JobKey key)
- Specified by:
setJobKey
in interfaceorg.quartz.spi.MutableTrigger
getFullName
public String getFullName()
Returns the 'full name' of the
Trigger
in the format "group.name".
getKey
public TriggerKey getKey()
getJobKey
public JobKey getJobKey()
getFullJobName
public String getFullJobName()
Returns the 'full name' of the
Job
that theTrigger
points to, in the format "group.name".
getDescription
public String getDescription()
Return the description given to the
Trigger
instance by its creator (if any).- Specified by:
getDescription
in interfaceTrigger
- Returns:
- null if no description was set.
setDescription
public void setDescription(String description)
Set a description for the
Trigger
instance - may be useful for remembering/displaying the purpose of the trigger, though the description has no meaning to Quartz.- Specified by:
setDescription
in interfaceorg.quartz.spi.MutableTrigger
setCalendarName
public void setCalendarName(String calendarName)
Associate the
Calendar
with the given name with this Trigger.- Specified by:
setCalendarName
in interfaceorg.quartz.spi.MutableTrigger
- Parameters:
calendarName
- usenull
to dis-associate a Calendar.
getCalendarName
public String getCalendarName()
Get the name of the
Calendar
associated with this Trigger.- Specified by:
getCalendarName
in interfaceTrigger
- Returns:
null
if there is no associated Calendar.
getJobDataMap
public JobDataMap getJobDataMap()
Get the
JobDataMap
that is associated with theTrigger
.Changes made to this map during job execution are not re-persisted, and in fact typically result in an
IllegalStateException
.- Specified by:
getJobDataMap
in interfaceTrigger
setJobDataMap
public void setJobDataMap(JobDataMap jobDataMap)
Set the
JobDataMap
to be associated with theTrigger
.- Specified by:
setJobDataMap
in interfaceorg.quartz.spi.MutableTrigger
getPriority
public int getPriority()
- The priority of a
Trigger
acts as a tiebreaker such that if twoTrigger
s have the same scheduled fire time, then the one with the higher priority will get first access to a worker thread.If not explicitly set, the default value is
5
. - Specified by:
getPriority
in interfaceTrigger
- See Also:
Trigger.DEFAULT_PRIORITY
setPriority
public void setPriority(int priority)
- The priority of a
Trigger
acts as a tie breaker such that if twoTrigger
s have the same scheduled fire time, then Quartz will do its best to give the one with the higher priority first access to a worker thread.If not explicitly set, the default value is
5
. - Specified by:
setPriority
in interfaceorg.quartz.spi.MutableTrigger
- See Also:
Trigger.DEFAULT_PRIORITY
triggered
public abstract void triggered(Calendar calendar)
This method should not be used by the Quartz client.
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
computeFirstFireTime
public abstract Date computeFirstFireTime(Calendar calendar)
This method should not be used by the Quartz client.
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
- 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
).
executionComplete
public Trigger.CompletedExecutionInstruction executionComplete(JobExecutionContext context, JobExecutionException result)
This method should not be used by the Quartz client.
Called after the
Scheduler
has executed theJobDetail
associated with theTrigger
in order to get the final instruction code from the trigger.- Specified by:
executionComplete
in interfaceorg.quartz.spi.OperableTrigger
- Parameters:
context
- is theJobExecutionContext
that was used by theJob
'sexecute(xx)
method.result
- is theJobExecutionException
thrown by theJob
, if any (may be null).- Returns:
- one of the CompletedExecutionInstruction constants.
- See Also:
Trigger.CompletedExecutionInstruction
,triggered(Calendar)
mayFireAgain
public abstract boolean mayFireAgain()
Used by the
Scheduler
to determine whether or not it is possible for thisTrigger
to fire again.If the returned value is
false
then theScheduler
may remove theTrigger
from theJobStore
.- Specified by:
mayFireAgain
in interfaceTrigger
getStartTime
public abstract Date getStartTime()
Get the time at which the
Trigger
should occur.- Specified by:
getStartTime
in interfaceTrigger
setStartTime
public abstract void setStartTime(Date startTime)
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
setEndTime
public abstract 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).- Specified by:
setEndTime
in interfaceorg.quartz.spi.MutableTrigger
- See Also:
TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(AbstractTrigger, Calendar, int)
getEndTime
public abstract Date getEndTime()
Get the time at which the
Trigger
should quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).- Specified by:
getEndTime
in interfaceTrigger
- See Also:
getFinalFireTime()
getNextFireTime
public abstract 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
- See Also:
TriggerUtils#computeFireTimesBetween(AbstractTrigger, Calendar, Date, Date)
getPreviousFireTime
public abstract Date getPreviousFireTime()
Returns the previous time at which the
Trigger
fired. If the trigger has not yet fired,null
will be returned.- Specified by:
getPreviousFireTime
in interfaceTrigger
getFireTimeAfter
public abstract Date getFireTimeAfter(Date afterTime)
Returns the next time at which the
Trigger
will fire, after the given time. If the trigger will not fire after the given time,null
will be returned.- Specified by:
getFireTimeAfter
in interfaceTrigger
getFinalFireTime
public abstract Date getFinalFireTime()
Returns the last time at which the
Trigger
will fire, if the Trigger will repeat indefinitely, null will be returned.Note that the return time *may* be in the past.
- Specified by:
getFinalFireTime
in interfaceTrigger
setMisfireInstruction
public void setMisfireInstruction(int misfireInstruction)
Set the instruction the
Scheduler
should be given for handling misfire situations for thisTrigger
- the concreteTrigger
type that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXX
constants that may be passed to this method.If not explicitly set, the default value is
MISFIRE_INSTRUCTION_SMART_POLICY
.- Specified by:
setMisfireInstruction
in interfaceorg.quartz.spi.MutableTrigger
validateMisfireInstruction
protected abstract boolean validateMisfireInstruction(int misfireInstruction)
getMisfireInstruction
public int getMisfireInstruction()
Get the instruction the
Scheduler
should be given for handling misfire situations for thisTrigger
- the concreteTrigger
type that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXX
constants that may be passed to this method.If not explicitly set, the default value is
MISFIRE_INSTRUCTION_SMART_POLICY
.- Specified by:
getMisfireInstruction
in interfaceTrigger
updateAfterMisfire
public abstract void updateAfterMisfire(Calendar cal)
This method should not be used by the Quartz client.
To be implemented by the concrete classes that extend this class.
The implementation should update the
Trigger
's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theTrigger
was created.- Specified by:
updateAfterMisfire
in interfaceorg.quartz.spi.OperableTrigger
updateWithNewCalendar
public abstract void updateWithNewCalendar(Calendar cal, long misfireThreshold)
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
- Parameters:
cal
-
validate
public void validate() throws SchedulerException
Validates whether the properties of the
JobDetail
are valid for submission into aScheduler
.- Specified by:
validate
in interfaceorg.quartz.spi.OperableTrigger
- Throws:
IllegalStateException
- if a required property (such as Name, Group, Class) is not set.SchedulerException
setFireInstanceId
public void setFireInstanceId(String id)
This method should not be used by the Quartz client.
Usable by
JobStore
implementations, in order to facilitate 'recognizing' instances of firedTrigger
s as their jobs complete execution.- Specified by:
setFireInstanceId
in interfaceorg.quartz.spi.OperableTrigger
getFireInstanceId
public String getFireInstanceId()
This method should not be used by the Quartz client.
- Specified by:
getFireInstanceId
in interfaceorg.quartz.spi.OperableTrigger
toString
public String toString()
compareTo
public int compareTo(Trigger other)
Compare the next fire time of this
Trigger
to that of another by comparing their keys, or in other words, sorts them according to the natural (i.e. alphabetical) order of their keys.- Specified by:
compareTo
in interfaceComparable<Trigger>
- Specified by:
compareTo
in interfaceTrigger
equals
public boolean equals(Object o)
- Trigger equality is based upon the equality of the TriggerKey.
- Returns:
- true if the key of this Trigger equals that of the given Trigger.
hashCode
public int hashCode()
clone
public Object clone()
getTriggerBuilder
public TriggerBuilder<T> getTriggerBuilder()
- Description copied from interface:
Trigger
- Get a
TriggerBuilder
that is configured to produce aTrigger
identical to this one. - Specified by:
getTriggerBuilder
in interfaceTrigger
- See Also:
Trigger.getScheduleBuilder()
getScheduleBuilder
public abstract ScheduleBuilder<T> getScheduleBuilder()
- Description copied from interface:
Trigger
- Get a
ScheduleBuilder
that is configured to produce a schedule identical to this trigger's schedule. - Specified by:
getScheduleBuilder
in interfaceTrigger
- See Also:
Trigger.getTriggerBuilder()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2001-2011, Terracotta, Inc.