|
|||||||||
| Home >> All >> org >> [ quartz overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.quartz
Class UICronTrigger

java.lang.Objectorg.quartz.Trigger
org.quartz.UICronTrigger
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Comparable, java.io.Serializable
- public class UICronTrigger
- extends Trigger
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 | |
private static java.lang.Integer |
ALL_SPEC
|
private static int |
ALL_SPEC_INT
|
private boolean |
calendardayOfMonth
|
private boolean |
calendardayOfWeek
|
private static java.util.Map |
dayMap
|
private java.util.TreeSet |
daysOfMonth
|
private java.util.TreeSet |
daysOfWeek
|
private java.util.Date |
endTime
|
private java.util.TreeSet |
hours
|
private boolean |
lastdayOfMonth
|
private boolean |
lastdayOfWeek
|
private java.util.TreeSet |
minutes
|
static 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, but it does not to be fired now. |
static int |
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
Instructs the Scheduler that upon a mis-fire
situation, the CronTrigger wants to be
fired now by Scheduler. |
private static java.util.Map |
monthMap
|
private java.util.TreeSet |
months
|
private java.util.Date |
nextFireTime
|
private static java.lang.Integer |
NO_SPEC
|
private static int |
NO_SPEC_INT
|
private int |
nthdayOfWeek
|
private java.util.Date |
previousFireTime
|
private java.util.TreeSet |
seconds
|
private java.util.Date |
startTime
|
private java.util.TimeZone |
timeZone
|
private java.util.TreeSet |
years
|
| Constructor Summary | |
UICronTrigger()
Create a CronTrigger with no settings. |
|
UICronTrigger(java.lang.String name,
java.lang.String group)
Create a CronTrigger with the given name and group. |
|
UICronTrigger(java.lang.String name,
java.lang.String group,
java.lang.String jobName,
java.lang.String jobGroup)
Create a CronTrigger with the given name and group, and
associated with the identified Job. |
|
| Method Summary | |
java.util.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. |
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. |
java.lang.Integer[] |
getDaysOfMonth()
|
java.lang.Integer[] |
getDaysOfMonthLabels()
|
java.lang.Integer[] |
getDaysOfMonthValues()
|
java.lang.Integer[] |
getDaysOfWeek()
|
java.lang.String[] |
getDaysOfWeekLabels()
|
java.lang.Integer[] |
getDaysOfWeekValues()
|
java.util.Date |
getEndTime()
Get the time at which the CronTrigger should quit
repeating - even if repeastCount isn't yet satisfied. |
private java.lang.String |
getExpressionSetSummary(java.util.Set set)
|
java.lang.String |
getExpressionSummary()
|
java.util.Date |
getFinalFireTime()
Returns the final time at which the CronTrigger will
fire. |
java.util.Date |
getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which the CronTrigger will fire,
after the given time. |
java.lang.Integer[] |
getHours()
|
java.lang.String[] |
getHoursLabels()
|
java.lang.Integer[] |
getHoursValues()
|
int |
getLastDayOfMonth(int monthNum)
|
java.lang.Integer[] |
getMinutes()
|
java.lang.Integer[] |
getMinutesLabels()
|
java.lang.Integer[] |
getMinutesValues()
|
java.lang.Integer[] |
getMonths()
|
java.lang.String[] |
getMonthsLabels()
|
java.lang.Integer[] |
getMonthsValues()
|
java.util.Date |
getNextFireTime()
Returns the next time at which the CronTrigger will fire. |
java.util.Date |
getPreviousFireTime()
Returns the previous time at which the Trigger will fire. |
java.lang.Integer[] |
getSeconds()
|
java.lang.Integer[] |
getSecondsLabels()
|
java.lang.Integer[] |
getSecondsValues()
|
java.util.Date |
getStartTime()
Get the time at which the CronTrigger should occur. |
private java.util.Date |
getTimeAfter(java.util.Date afterTime)
|
private java.util.Date |
getTimeBefore(java.util.Date endTime)
|
java.util.TimeZone |
getTimeZone()
Returns the time zone for which the cronExpression of
this CronTrigger will be resolved. |
java.lang.Integer[] |
getYears()
|
java.lang.Integer[] |
getYearsLabels()
|
java.lang.Integer[] |
getYearsValues()
|
boolean |
isLeapYear()
|
static void |
main(java.lang.String[] argv)
|
boolean |
mayFireAgain()
Determines whether or not the CronTrigger will occur
again. |
void |
reset()
|
void |
setDaysOfMonth(java.lang.Integer[] val)
|
void |
setDaysOfWeek(java.lang.Integer[] val)
|
void |
setEndTime(java.util.Date endTime)
|
void |
setHours(java.lang.Integer[] val)
|
void |
setMinutes(java.lang.Integer[] val)
|
void |
setMonths(java.lang.Integer[] val)
|
void |
setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the CronTrigger will fire. |
void |
setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the SimpleTrigger fired. |
void |
setSeconds(java.lang.Integer[] val)
|
void |
setStartTime(java.util.Date startTime)
|
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the cronExpression of this
CronTrigger will be resolved. |
void |
setYears(java.lang.Integer[] val)
|
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()
Updates the CronTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the SimpleTrigger
was created. |
void |
updateAfterMisfire(Calendar cal)
This method should not be used by the Quartz client. |
void |
updateWithNewCalendar(Calendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client. |
protected boolean |
validateMisfireInstruction(int misfireInstruction)
|
boolean |
willFireOn(java.util.Calendar test)
Determines whether the date & time of the given java.util.Calendar instance falls on a scheduled fire-time of this trigger. |
| Methods inherited from class org.quartz.Trigger |
addTriggerListener, clone, compareTo, equals, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobGroup, getJobName, getMisfireInstruction, getName, getTriggerListenerNames, hashCode, isVolatile, removeTriggerListener, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobGroup, setJobName, setMisfireInstruction, setName, setVolatility, toString, validate |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
public static final int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
Instructs the
Schedulerthat upon a mis-fire situation, theCronTriggerwants to be fired now byScheduler.- See Also:
- Constant Field Values
MISFIRE_INSTRUCTION_DO_NOTHING
public static final int MISFIRE_INSTRUCTION_DO_NOTHING
Instructs the
Schedulerthat upon a mis-fire situation, theCronTriggerwants 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.- See Also:
- Constant Field Values
ALL_SPEC_INT
private static final int ALL_SPEC_INT
- See Also:
- Constant Field Values
NO_SPEC_INT
private static final int NO_SPEC_INT
- See Also:
- Constant Field Values
ALL_SPEC
private static final java.lang.Integer ALL_SPEC
NO_SPEC
private static final java.lang.Integer NO_SPEC
monthMap
private static java.util.Map monthMap
dayMap
private static java.util.Map dayMap
startTime
private java.util.Date startTime
endTime
private java.util.Date endTime
nextFireTime
private java.util.Date nextFireTime
timeZone
private java.util.TimeZone timeZone
previousFireTime
private java.util.Date previousFireTime
seconds
private java.util.TreeSet seconds
minutes
private java.util.TreeSet minutes
hours
private java.util.TreeSet hours
daysOfMonth
private java.util.TreeSet daysOfMonth
months
private java.util.TreeSet months
daysOfWeek
private java.util.TreeSet daysOfWeek
years
private java.util.TreeSet years
lastdayOfWeek
private transient boolean lastdayOfWeek
nthdayOfWeek
private transient int nthdayOfWeek
lastdayOfMonth
private transient boolean lastdayOfMonth
calendardayOfWeek
private transient boolean calendardayOfWeek
calendardayOfMonth
private transient boolean calendardayOfMonth
| Constructor Detail |
UICronTrigger
public UICronTrigger()
Create a
CronTriggerwith no settings.
UICronTrigger
public UICronTrigger(java.lang.String name, java.lang.String group)
Create a
CronTriggerwith the given name and group.
UICronTrigger
public UICronTrigger(java.lang.String name, java.lang.String group, java.lang.String jobName, java.lang.String jobGroup)
Create a
CronTriggerwith the given name and group, and associated with the identifiedJob.
| Method Detail |
reset
public void reset()
getStartTime
public java.util.Date getStartTime()
Get the time at which the
CronTriggershould occur.- Specified by:
getStartTimein classTrigger
setStartTime
public void setStartTime(java.util.Date startTime)
- Specified by:
setStartTimein classTrigger
getEndTime
public java.util.Date getEndTime()
Get the time at which the
CronTriggershould quit repeating - even if repeastCount isn't yet satisfied.- Specified by:
getEndTimein classTrigger
setEndTime
public void setEndTime(java.util.Date endTime)
- Specified by:
setEndTimein classTrigger
getNextFireTime
public java.util.Date getNextFireTime()
Returns the next time at which the
CronTriggerwill fire. If the trigger will not fire again,nullwill be returned. The value returned is not guaranteed to be valid until after theTriggerhas been added to the scheduler.- Specified by:
getNextFireTimein classTrigger
updateAfterMisfire
public void updateAfterMisfire(Calendar cal)
- Description copied from class:
Trigger 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 theTriggerwas created.- Specified by:
updateAfterMisfirein classTrigger
getPreviousFireTime
public java.util.Date getPreviousFireTime()
- Description copied from class:
Trigger Returns the previous time at which the
Triggerwill fire. If the trigger has not yet fired,nullwill be returned.- Specified by:
getPreviousFireTimein classTrigger
setPreviousFireTime
public void setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the
SimpleTriggerfired.This method should not be invoked by client code.
setNextFireTime
public void setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the
CronTriggerwill fire. If the trigger will not fire again,nullwill be returned.
getTimeZone
public java.util.TimeZone getTimeZone()
Returns the time zone for which the
cronExpressionof thisCronTriggerwill be resolved.
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the
cronExpressionof thisCronTriggerwill be resolved.
getFireTimeAfter
public java.util.Date getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which the
CronTriggerwill fire, after the given time. If the trigger will not fire after the given time,nullwill be returned.Note that the date returned is NOT validated against the related org.quartz.Calendar (if any)
- Specified by:
getFireTimeAfterin classTrigger
getFinalFireTime
public java.util.Date getFinalFireTime()
Returns the final time at which the
CronTriggerwill fire.Note that the return time *may* be in the past. and the date returned is not validated against org.quartz.calendar
- Specified by:
getFinalFireTimein classTrigger
mayFireAgain
public boolean mayFireAgain()
Determines whether or not the
CronTriggerwill occur again.- Specified by:
mayFireAgainin classTrigger
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction)
- Specified by:
validateMisfireInstructionin classTrigger
updateAfterMisfire
public void updateAfterMisfire()
Updates the
CronTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theSimpleTriggerwas 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
- The instruction will be interpreted as
willFireOn
public boolean willFireOn(java.util.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)
executionComplete
public int executionComplete(JobExecutionContext context, JobExecutionException result)
Called after the
Schedulerhas executed theJobassociated with theTriggerin order to get the final instruction code from the trigger.- Specified by:
executionCompletein classTrigger
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).
updateWithNewCalendar
public void updateWithNewCalendar(Calendar calendar, long misfireThreshold)
- Description copied from class:
Trigger 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 classTrigger
computeFirstFireTime
public java.util.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 classTrigger
getExpressionSummary
public java.lang.String getExpressionSummary()
getExpressionSetSummary
private java.lang.String getExpressionSetSummary(java.util.Set set)
getTimeAfter
private java.util.Date getTimeAfter(java.util.Date afterTime)
getTimeBefore
private java.util.Date getTimeBefore(java.util.Date endTime)
isLeapYear
public boolean isLeapYear()
getLastDayOfMonth
public int getLastDayOfMonth(int monthNum)
getSecondsValues
public java.lang.Integer[] getSecondsValues()
getSecondsLabels
public java.lang.Integer[] getSecondsLabels()
getSeconds
public java.lang.Integer[] getSeconds()
setSeconds
public void setSeconds(java.lang.Integer[] val)
getMinutesValues
public java.lang.Integer[] getMinutesValues()
getMinutesLabels
public java.lang.Integer[] getMinutesLabels()
getMinutes
public java.lang.Integer[] getMinutes()
setMinutes
public void setMinutes(java.lang.Integer[] val)
getHoursValues
public java.lang.Integer[] getHoursValues()
getHoursLabels
public java.lang.String[] getHoursLabels()
getHours
public java.lang.Integer[] getHours()
setHours
public void setHours(java.lang.Integer[] val)
getDaysOfMonthValues
public java.lang.Integer[] getDaysOfMonthValues()
getDaysOfMonthLabels
public java.lang.Integer[] getDaysOfMonthLabels()
getDaysOfMonth
public java.lang.Integer[] getDaysOfMonth()
setDaysOfMonth
public void setDaysOfMonth(java.lang.Integer[] val)
getMonthsValues
public java.lang.Integer[] getMonthsValues()
getMonthsLabels
public java.lang.String[] getMonthsLabels()
getMonths
public java.lang.Integer[] getMonths()
setMonths
public void setMonths(java.lang.Integer[] val)
getDaysOfWeekLabels
public java.lang.String[] getDaysOfWeekLabels()
getDaysOfWeekValues
public java.lang.Integer[] getDaysOfWeekValues()
getDaysOfWeek
public java.lang.Integer[] getDaysOfWeek()
setDaysOfWeek
public void setDaysOfWeek(java.lang.Integer[] val)
getYearsValues
public java.lang.Integer[] getYearsValues()
getYearsLabels
public java.lang.Integer[] getYearsLabels()
getYears
public java.lang.Integer[] getYears()
setYears
public void setYears(java.lang.Integer[] val)
main
public static void main(java.lang.String[] argv)
|
|||||||||
| Home >> All >> org >> [ quartz overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC