Home » quartz-1.6.0 » org » quartz » [javadoc | source]
org.quartz
public class: UICronTrigger [javadoc | source]
java.lang.Object
   org.quartz.Trigger
      org.quartz.UICronTrigger

All Implemented Interfaces:
    Cloneable, Serializable, Comparable

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

What you should know about this particular trigger is that it is based on org.quartz.CronTrigger, but the the functionality to build the sets from a string are unused. Whereas CronTrigger would essentially deserialize by rebuilding the TreeSets from the cronExpression, this class does not have a cronExpression, and de/serializes the TreeSets in their entirety. This is because the TreeSets map directly to the Struts user interface for set selection, and no effort is made to write an interpreter to map them back and forth between legacy UN*X cron expressions that CronTrigger uses.

The method I use with this trigger is to instantiate it, then put it in the ActionForm of a Struts bean, then let Struts manipulate it directly through BeanUtils. You are by no means required to do that, but to fully understand the concepts here, at least until there is better documentation, you should understand how it works within that context first so you can write the appropriate code that Struts does for you for free. I'll try to explain that here.

Struts JSP tags allow the user to use Apache BeanUtils to reference components of beans by path. This is to say that a bean Foo that has an accessor method Bar getBar() and given Bar has a primitive type String as a field named splat, one can set the field to "new string value" as follows:

// create a new Foo with contained reference to a new Bar Foo fooBean = new Foo(); fooBean.setBar(new Bar()); // set the splat string in the Bar bean from Foo BeanUtils.setProperty(fooBean, "bar.splat", "new string value");

In turn, Struts JSP tags use the bean addressing provided by BeanUtils to address accessor methods within the bean graph that is rooted with the ActionForm that is put into the Action context.

Finally, having all this allows you to put direct selection lists on the screen of the UI, then map them directly into the UICronTrigger bean. Given a ActionForm bean that was set up to contain a UICronTrigger in a field called trigger, the following HTML code will completely create your UI in Struts:

Date Time

So if you don't want to use Struts, what you have to do is take the information that was submitted on the form in the HTML select ranges, iterate each of them, and add the values to the appropriate sets in the fields of this class. Make sense?

Note that this is not as versatile as the standard CronTrigger. There are tricks with "last day of month" and repeating sets that need to be manually selected, and sets that can happen for date ranges much longer than we can reasonably map with direct selection in a UI.
Field Summary
public static final  int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW   

Instructs the Scheduler that upon a mis-fire situation, the org.quartz.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 org.quartz.CronTrigger wants to have it's next-fire-time updated to the next time in the schedule after the current time, but it does not 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 UICronTrigger() 
 public UICronTrigger(String name,
    String group) 

    Create a CronTrigger with the given name and group.

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

    Create a CronTrigger with the given name and group, and associated with the identified Job .

Method from org.quartz.UICronTrigger Summary:
computeFirstFireTime,   executionComplete,   getDaysOfMonth,   getDaysOfMonthLabels,   getDaysOfMonthValues,   getDaysOfWeek,   getDaysOfWeekLabels,   getDaysOfWeekValues,   getEndTime,   getExpressionSummary,   getFinalFireTime,   getFireTimeAfter,   getHours,   getHoursLabels,   getHoursValues,   getLastDayOfMonth,   getMinutes,   getMinutesLabels,   getMinutesValues,   getMonths,   getMonthsLabels,   getMonthsValues,   getNextFireTime,   getPreviousFireTime,   getSeconds,   getSecondsLabels,   getSecondsValues,   getStartTime,   getTimeZone,   getYears,   getYearsLabels,   getYearsValues,   isLeapYear,   main,   mayFireAgain,   reset,   setDaysOfMonth,   setDaysOfWeek,   setEndTime,   setHours,   setMinutes,   setMonths,   setNextFireTime,   setPreviousFireTime,   setSeconds,   setStartTime,   setTimeZone,   setYears,   triggered,   updateAfterMisfire,   updateAfterMisfire,   updateWithNewCalendar,   validateMisfireInstruction,   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.UICronTrigger Detail:
 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 Job associated with the Trigger in order to get the final instruction code from the trigger.

 public Integer[] getDaysOfMonth() 
 public Integer[] getDaysOfMonthLabels() 
 public Integer[] getDaysOfMonthValues() 
 public Integer[] getDaysOfWeek() 
 public String[] getDaysOfWeekLabels() 
 public Integer[] getDaysOfWeekValues() 
 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() 

    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 Integer[] getHours() 
 public String[] getHoursLabels() 
 public Integer[] getHoursValues() 
 public int getLastDayOfMonth(int monthNum) 
 public Integer[] getMinutes() 
 public Integer[] getMinutesLabels() 
 public Integer[] getMinutesValues() 
 public Integer[] getMonths() 
 public String[] getMonthsLabels() 
 public Integer[] getMonthsValues() 
 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() 
 public Integer[] getSeconds() 
 public Integer[] getSecondsLabels() 
 public Integer[] getSecondsValues() 
 public Date getStartTime() 

    Get the time at which the CronTrigger should occur.

 public TimeZone getTimeZone() 

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

 public Integer[] getYears() 
 public Integer[] getYearsLabels() 
 public Integer[] getYearsValues() 
 public boolean isLeapYear() 
 public static  void main(String[] argv) 
 public boolean mayFireAgain() 

    Determines whether or not the CronTrigger will occur again.

 public  void reset() 
 public  void setDaysOfMonth(Integer[] val) 
 public  void setDaysOfWeek(Integer[] val) 
 public  void setEndTime(Date endTime) 
 public  void setHours(Integer[] val) 
 public  void setMinutes(Integer[] val) 
 public  void setMonths(Integer[] val) 
 public  void setNextFireTime(Date nextFireTime) 

    Sets the next time at which the CronTrigger will fire. If the trigger will not fire again, null will be returned.

 public  void setPreviousFireTime(Date previousFireTime) 

    Set the previous time at which the SimpleTrigger fired.

    This method should not be invoked by client code.

 public  void setSeconds(Integer[] val) 
 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 setYears(Integer[] val) 
 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() 

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

 public  void updateAfterMisfire(Calendar cal) 
 public  void updateWithNewCalendar(Calendar calendar,
    long misfireThreshold) 
 protected boolean validateMisfireInstruction(int misfireInstruction) 
 public boolean willFireOn(Calendar test) 

    Determines whether the date & time of the given java.util.Calendar instance falls on a scheduled fire-time of this trigger.

    Note that the date returned is NOT validated against the related org.quartz.Calendar (if any)