|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.quartz.Trigger
org.quartz.UICronTrigger
A concrete
that is used to fire a Trigger
at given moments in time, defined with Unix 'cron-like' definitions.
Job
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.
CronTrigger
,
Trigger
,
SimpleTrigger
,
Serialized FormField Summary | |
static int |
MISFIRE_INSTRUCTION_DO_NOTHING
Instructs the that upon a mis-fire
situation, the 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 that upon a mis-fire
situation, the wants to be
fired now by Scheduler . |
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 . |
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 has executed the
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. |
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. |
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 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 |
public static final int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
Instructs the
that upon a mis-fire
situation, the Scheduler
wants to be
fired now by CronTrigger
Scheduler
.
public static final int MISFIRE_INSTRUCTION_DO_NOTHING
Instructs the
that upon a mis-fire
situation, the Scheduler
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.
CronTrigger
Constructor Detail |
public UICronTrigger()
Create a CronTrigger
with no settings.
public UICronTrigger(java.lang.String name, java.lang.String group)
Create a CronTrigger
with the given name and group.
public 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 Detail |
public void reset()
public java.util.Date getStartTime()
Get the time at which the CronTrigger
should occur.
getStartTime
in class Trigger
public void setStartTime(java.util.Date startTime)
setStartTime
in class Trigger
public java.util.Date getEndTime()
Get the time at which the CronTrigger
should quit
repeating - even if repeastCount isn't yet satisfied.
getEndTime
in class Trigger
getFinalFireTime()
public void setEndTime(java.util.Date endTime)
setEndTime
in class Trigger
public java.util.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.
getNextFireTime
in class Trigger
public void updateAfterMisfire(Calendar cal)
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 the Trigger
was created.
updateAfterMisfire
in class Trigger
public java.util.Date getPreviousFireTime()
Trigger
Returns the previous time at which the Trigger
will fire.
If the trigger has not yet fired, null
will be returned.
getPreviousFireTime
in class Trigger
public void setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the SimpleTrigger
fired.
This method should not be invoked by client code.
public void setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the CronTrigger
will fire. If
the trigger will not fire again, null
will be returned.
public java.util.TimeZone getTimeZone()
Returns the time zone for which the cronExpression
of
this CronTrigger
will be resolved.
public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the cronExpression
of this
CronTrigger
will be resolved.
public java.util.Date getFireTimeAfter(java.util.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)
getFireTimeAfter
in class Trigger
public java.util.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
getFinalFireTime
in class Trigger
public boolean mayFireAgain()
Determines whether or not the CronTrigger
will occur
again.
mayFireAgain
in class Trigger
protected boolean validateMisfireInstruction(int misfireInstruction)
validateMisfireInstruction
in class Trigger
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:
MISFIRE_INSTRUCTION_DO_NOTHING
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)
public int executionComplete(JobExecutionContext context, JobExecutionException result)
Called after the
has executed the
Scheduler
associated with the Job
Trigger
in
order to get the final instruction code from the trigger.
executionComplete
in class Trigger
context
- is the JobExecutionContext
that was used by the
Job
'sexecute(xx)
method.result
- is the JobExecutionException
thrown by the
Job
, if any (may be null).
Trigger.INSTRUCTION_NOOP
,
Trigger.INSTRUCTION_RE_EXECUTE_JOB
,
Trigger.INSTRUCTION_DELETE_TRIGGER
,
Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE
,
triggered(Calendar)
public void triggered(Calendar calendar)
Called when the
has decided to 'fire'
the trigger (execute the associated Scheduler
Job
), in order to
give the Trigger
a chance to update itself for its next
triggering (if any).
triggered
in class Trigger
executionComplete(JobExecutionContext, JobExecutionException)
public void updateWithNewCalendar(Calendar calendar, long misfireThreshold)
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 associated Calendar
(the state should be updated so that it's next fire time is appropriate
given the Calendar's new settings).
updateWithNewCalendar
in class Trigger
calendar
- Trigger.updateWithNewCalendar(org.quartz.Calendar, long)
public 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.
After this method has been called, getNextFireTime()
should return a valid answer.
computeFirstFireTime
in class Trigger
Trigger
will be fired
by the scheduler, which is also the same value getNextFireTime()
will return (until after the first firing of the Trigger
).
public java.lang.String getExpressionSummary()
public boolean isLeapYear()
public int getLastDayOfMonth(int monthNum)
public java.lang.Integer[] getSecondsValues()
public java.lang.Integer[] getSecondsLabels()
public java.lang.Integer[] getSeconds()
public void setSeconds(java.lang.Integer[] val)
public java.lang.Integer[] getMinutesValues()
public java.lang.Integer[] getMinutesLabels()
public java.lang.Integer[] getMinutes()
public void setMinutes(java.lang.Integer[] val)
public java.lang.Integer[] getHoursValues()
public java.lang.String[] getHoursLabels()
public java.lang.Integer[] getHours()
public void setHours(java.lang.Integer[] val)
public java.lang.Integer[] getDaysOfMonthValues()
public java.lang.Integer[] getDaysOfMonthLabels()
public java.lang.Integer[] getDaysOfMonth()
public void setDaysOfMonth(java.lang.Integer[] val)
public java.lang.Integer[] getMonthsValues()
public java.lang.String[] getMonthsLabels()
public java.lang.Integer[] getMonths()
public void setMonths(java.lang.Integer[] val)
public java.lang.String[] getDaysOfWeekLabels()
public java.lang.Integer[] getDaysOfWeekValues()
public java.lang.Integer[] getDaysOfWeek()
public void setDaysOfWeek(java.lang.Integer[] val)
public java.lang.Integer[] getYearsValues()
public java.lang.Integer[] getYearsLabels()
public java.lang.Integer[] getYears()
public void setYears(java.lang.Integer[] val)
public static void main(java.lang.String[] argv)
|
Quartz Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |