Save This Page
Home » quartz-1.6.0 » org » quartz » [javadoc | source]
org.quartz
public class: CronTrigger [javadoc | source]
java.lang.Object
   org.quartz.Trigger
      org.quartz.CronTrigger

All Implemented Interfaces:
    Cloneable, Serializable, Comparable

A concrete Trigger that is used to fire a org.quartz.JobDetail at given moments in time, defined with Unix 'cron-like' definitions.

For those unfamiliar with "cron", this means being able to create a firing schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".

The format of a "Cron-Expression" string is documented on the org.quartz.CronExpression class.

Here are some full examples:
Expression   Meaning
"0 0 12 * * ?"   Fire at 12pm (noon) every day
"0 15 10 ? * *"   Fire at 10:15am every day
"0 15 10 * * ?"   Fire at 10:15am every day
"0 15 10 * * ? *"   Fire at 10:15am every day
"0 15 10 * * ? 2005"   Fire at 10:15am every day during the year 2005
"0 * 14 * * ?"   Fire every minute starting at 2pm and ending at 2:59pm, every day
"0 0/5 14 * * ?"   Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
"0 0/5 14,18 * * ?"   Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
"0 0-5 14 * * ?"   Fire every minute starting at 2pm and ending at 2:05pm, every day
"0 10,44 14 ? 3 WED"   Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
"0 15 10 ? * MON-FRI"   Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
"0 15 10 15 * ?"   Fire at 10:15am on the 15th day of every month
"0 15 10 L * ?"   Fire at 10:15am on the last day of every month
"0 15 10 ? * 6L"   Fire at 10:15am on the last Friday of every month
"0 15 10 ? * 6L"   Fire at 10:15am on the last Friday of every month
"0 15 10 ? * 6L 2002-2005"   Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
"0 15 10 ? * 6#3"   Fire at 10:15am on the third Friday of every month

Pay attention to the effects of '?' and '*' in the day-of-week and day-of-month fields!

NOTES:

Field Summary
public static final  int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW   

Instructs the Scheduler that upon a mis-fire situation, the CronTrigger wants to be fired now by Scheduler.

 
public static final  int MISFIRE_INSTRUCTION_DO_NOTHING   

Instructs the Scheduler that upon a mis-fire situation, the CronTrigger wants to have it's next-fire-time updated to the next time in the schedule after the current time (taking into account any associated Calendar , but it does not want to be fired now.

 
Fields inherited from org.quartz.Trigger:
INSTRUCTION_NOOP,  INSTRUCTION_RE_EXECUTE_JOB,  INSTRUCTION_SET_TRIGGER_COMPLETE,  INSTRUCTION_DELETE_TRIGGER,  INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE,  INSTRUCTION_SET_TRIGGER_ERROR,  INSTRUCTION_SET_ALL_JOB_TRIGGERS_ERROR,  MISFIRE_INSTRUCTION_SMART_POLICY,  STATE_NORMAL,  STATE_PAUSED,  STATE_COMPLETE,  STATE_ERROR,  STATE_BLOCKED,  STATE_NONE,  DEFAULT_PRIORITY
Constructor:
 public CronTrigger() 
 public CronTrigger(String name,
    String group) 

    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.

 public CronTrigger(String name,
    String group,
    String cronExpression) throws ParseException 

    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.

 public CronTrigger(String name,
    String group,
    String jobName,
    String jobGroup) 

    Create a CronTrigger with the given name and group, and associated with the identified org.quartz.JobDetail .

    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.

 public CronTrigger(String name,
    String group,
    String jobName,
    String jobGroup,
    String cronExpression) throws ParseException 

    Create a CronTrigger with the given name and group, associated with the identified org.quartz.JobDetail , 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.

 public CronTrigger(String name,
    String group,
    String jobName,
    String jobGroup,
    String cronExpression,
    TimeZone timeZone) throws ParseException 

    Create a CronTrigger with the given name and group, associated with the identified org.quartz.JobDetail , and with the given "cron" expression resolved with respect to the TimeZone.

 public CronTrigger(String name,
    String group,
    String jobName,
    String jobGroup,
    Date startTime,
    Date endTime,
    String cronExpression) throws ParseException 

    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 - A Date set to the time for the Trigger to fire.
    endTime - A Date set to the time for the Trigger to quit repeat firing.
 public CronTrigger(String name,
    String group,
    String jobName,
    String jobGroup,
    Date startTime,
    Date endTime,
    String cronExpression,
    TimeZone timeZone) throws ParseException 

    Create a CronTrigger with fire time dictated by the cronExpression resolved with respect to the specified timeZone occuring from the startTime until the given endTime.

    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 the Trigger
    group - of the Trigger
    jobName - name of the org.quartz.JobDetail executed on firetime
    jobGroup - group of the org.quartz.JobDetail executed on firetime
    startTime - A Date set to the earliest time for the Trigger to start firing.
    endTime - A Date set to the time for the Trigger to quit repeat firing.
    cronExpression - A cron expression dictating the firing sequence of the Trigger
    timeZone - Specifies for which time zone the cronExpression should be interprted, i.e. the expression 0 0 10 * * ?, is resolved to 10:00 am in this time zone.
    Throws:
    ParseException - if the cronExpression is invalid.
Method from org.quartz.CronTrigger Summary:
clone,   computeFirstFireTime,   executionComplete,   getCronExpression,   getEndTime,   getExpressionSummary,   getFinalFireTime,   getFireTimeAfter,   getNextFireTime,   getPreviousFireTime,   getStartTime,   getTimeAfter,   getTimeBefore,   getTimeZone,   main,   mayFireAgain,   setCronExpression,   setCronExpression,   setEndTime,   setNextFireTime,   setPreviousFireTime,   setStartTime,   setTimeZone,   triggered,   updateAfterMisfire,   updateWithNewCalendar,   validateMisfireInstruction,   willFireOn,   willFireOn
Methods from org.quartz.Trigger:
addTriggerListener,   clearAllTriggerListeners,   clone,   compareTo,   computeFirstFireTime,   equals,   executionComplete,   getCalendarName,   getDescription,   getEndTime,   getFinalFireTime,   getFireInstanceId,   getFireTimeAfter,   getFullJobName,   getFullName,   getGroup,   getJobDataMap,   getJobGroup,   getJobName,   getKey,   getMisfireInstruction,   getName,   getNextFireTime,   getPreviousFireTime,   getPriority,   getStartTime,   getTriggerListenerNames,   hashCode,   isVolatile,   mayFireAgain,   removeTriggerListener,   setCalendarName,   setDescription,   setEndTime,   setFireInstanceId,   setGroup,   setJobDataMap,   setJobGroup,   setJobName,   setMisfireInstruction,   setName,   setPriority,   setStartTime,   setVolatility,   toString,   triggered,   updateAfterMisfire,   updateWithNewCalendar,   validate,   validateMisfireInstruction
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.quartz.CronTrigger Detail:
 public Object clone() 
 public 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.

    After this method has been called, getNextFireTime() should return a valid answer.

 public int executionComplete(JobExecutionContext context,
    JobExecutionException result) 

    Called after the Scheduler has executed the org.quartz.JobDetail associated with the Trigger in order to get the final instruction code from the trigger.

 public String getCronExpression() 
 public Date getEndTime() 

    Get the time at which the CronTrigger should quit repeating - even if repeastCount isn't yet satisfied.

 public String getExpressionSummary() 
 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

 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)

 public Date getNextFireTime() 

    Returns the next time at which the CronTrigger will fire. If the trigger will not fire again, null will be returned. The value returned is not guaranteed to be valid until after the Trigger has been added to the scheduler.

 public Date getPreviousFireTime() 

    Returns the previous time at which the CronTrigger will fire. If the trigger has not yet fired, null will be returned.

 public 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.
 public TimeZone getTimeZone() 

    Returns the time zone for which the cronExpression of this CronTrigger will be resolved.

 public static  void main(String[] args) throws Exception 
 public boolean mayFireAgain() 

    Determines whether or not the CronTrigger will occur again.

 public  void setCronExpression(String cronExpression) throws ParseException 
 public  void setCronExpression(CronExpression cronExpression) 
 public  void setEndTime(Date endTime) 
 public  void setNextFireTime(Date nextFireTime) 

    Sets the next time at which the CronTrigger will fire. This method should not be invoked by client code.

 public  void setPreviousFireTime(Date previousFireTime) 

    Set the previous time at which the CronTrigger fired.

    This method should not be invoked by client code.

 public  void setStartTime(Date startTime) 
 public  void setTimeZone(TimeZone timeZone) 

    Sets the time zone for which the cronExpression of this CronTrigger will be resolved.

 public  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).

 public  void updateAfterMisfire(Calendar cal) 

    Updates the CronTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when the CronTrigger 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

 public  void updateWithNewCalendar(Calendar calendar,
    long misfireThreshold) 
 protected boolean validateMisfireInstruction(int misfireInstruction) 
 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).

 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)