Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.quartz
Class SimpleTrigger

    java.lang.Object
      org.quartz.Trigger
          org.quartz.SimpleTrigger

All Implemented Interfaces:
  Cloneable, Comparable, Serializable

public class SimpleTrigger
extends Trigger

A concrete ``Trigger`` that is used to fire a ``JobDetail`` at a given moment in time, and optionally repeated at a specified interval.

Author:
  James House, contributions by Lieven Govaerts of Ebitec Nv, Belgium.
See Also:
  `Trigger`, `CronTrigger`, `TriggerUtils`, Serialized Form

Field Summary
`static int` | `MISFIRE_INSTRUCTION_FIRE_NOW` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be fired now by `Scheduler`.
`static int` | `MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to the next scheduled time after 'now' - taking into account any associated ``Calendar``, and with the repeat count left unchanged.
`static int` | `MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to the next scheduled time after 'now' - taking into account any associated ``Calendar``, and with the repeat count set to what it would be, if it had not missed any firings.
`static int` | `MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to 'now' (even if the associated ``Calendar`` excludes 'now') with the repeat count left as-is.
`static int` | `MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to 'now' (even if the associated ``Calendar`` excludes 'now') with the repeat count set to what it would be, if it had not missed any firings.
`static int` | `REPEAT_INDEFINITELY` Used to indicate the 'repeat count' of the trigger is indefinite.

Fields inherited from class org.quartz.Trigger
`INSTRUCTION_DELETE_TRIGGER, INSTRUCTION_NOOP, INSTRUCTION_RE_EXECUTE_JOB, INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE, INSTRUCTION_SET_ALL_JOB_TRIGGERS_ERROR, INSTRUCTION_SET_TRIGGER_COMPLETE, INSTRUCTION_SET_TRIGGER_ERROR, MISFIRE_INSTRUCTION_SMART_POLICY, STATE_BLOCKED, STATE_COMPLETE, STATE_ERROR, STATE_NONE, STATE_NORMAL, STATE_PAUSED`

Constructor Summary
`SimpleTrigger()` Create a `SimpleTrigger` with no settings.
`SimpleTrigger(String name, String group)` Create a `SimpleTrigger` that will occur immediately, and not repeat.
`SimpleTrigger(String name, String group, Date startTime)` Create a `SimpleTrigger` that will occur at the given time, and not repeat.
`SimpleTrigger(String name, String group, Date startTime, Date endTime, int repeatCount, long repeatInterval)` Create a `SimpleTrigger` that will occur at the given time, and repeat at the the given interval the given number of times, or until the given end time.
`SimpleTrigger(String name, String group, int repeatCount, long repeatInterval)` Create a `SimpleTrigger` that will occur immediately, and repeat at the the given interval the given number of times.
`SimpleTrigger(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, int repeatCount, long repeatInterval)` Create a `SimpleTrigger` that will occur at the given time, fire the identified `Job` and repeat at the the given interval the given number of times, or until the given end time.

Method Summary
`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` | `computeNumTimesFiredBetween(Date start, Date end)`
`int` | `executionComplete(JobExecutionContext context, JobExecutionException result)` Called after the ``Scheduler`` has executed the ``JobDetail`` associated with the `Trigger` in order to get the final instruction code from the trigger.
`Date` | `getEndTime()` Get the time at which the `SimpleTrigger` should quit repeating - even if repeastCount isn't yet satisfied.
`Date` | `getFinalFireTime()` Returns the final time at which the `SimpleTrigger` will fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.
`Date` | `getFireTimeAfter(Date afterTime)` Returns the next time at which the `SimpleTrigger` will fire, after the given time.
`Date` | `getFireTimeBefore(Date end)` Returns the last time at which the `SimpleTrigger` will fire, before the given time.
`Date` | `getNextFireTime()` Returns the next time at which the `SimpleTrigger` will fire.
`Date` | `getPreviousFireTime()` Returns the previous time at which the `SimpleTrigger` will fire.
`int` | `getRepeatCount()` Get the the number of times the `SimpleTrigger` should repeat, after which it will be automatically deleted.
`long` | `getRepeatInterval()` Get the the time interval (in milliseconds) at which the `SimpleTrigger` should repeat.
`Date` | `getStartTime()` Get the time at which the `SimpleTrigger` should occur.
`int` | `getTimesTriggered()` Get the number of times the `SimpleTrigger` has already fired.
`static void` | `main(String[] args)`
`boolean` | `mayFireAgain()` Determines whether or not the `SimpleTrigger` will occur again.
`void` | `setEndTime(Date endTime)` Set the time at which the `SimpleTrigger` should quit repeating (and be automatically deleted).
`void` | `setNextFireTime(Date nextFireTime)` Set the next time at which the `SimpleTrigger` should fire.
`void` | `setPreviousFireTime(Date previousFireTime)` Set the previous time at which the `SimpleTrigger` fired.
`void` | `setRepeatCount(int repeatCount)` Set the the number of time the `SimpleTrigger` should repeat, after which it will be automatically deleted.
`void` | `setRepeatInterval(long repeatInterval)` Set the the time interval (in milliseconds) at which the `SimpleTrigger` should repeat.
`void` | `setStartTime(Date startTime)` Set the time at which the `SimpleTrigger` should occur.
`void` | `setTimesTriggered(int timesTriggered)` Set the number of times the `SimpleTrigger` has already fired.
`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(Calendar cal)` Updates the `SimpleTrigger`'s state based on the MISFIRE_INSTRUCTION_XXX that was selected when the `SimpleTrigger` was created.
`void` | `updateWithNewCalendar(Calendar calendar, 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 boolean` | `validateMisfireInstruction(int misfireInstruction)`

Methods inherited from class org.quartz.Trigger
`addTriggerListener, clone, compareTo, equals, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobName, getMisfireInstruction, getName, getTriggerListenerNames, hashCode, isVolatile, removeTriggerListener, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobName, setMisfireInstruction, setName, setVolatility, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### MISFIRE_INSTRUCTION_FIRE_NOW

    public static final int MISFIRE_INSTRUCTION_FIRE_NOW

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

  NOTE: This instruction should typically only be used for 'one-shot' (non-repeating) Triggers. If it is used on a trigger with a repeat count > 0 then it is equivalent to the instruction ``MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT`` .

  See Also:
    Constant Field Values

### MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT

    public static final int MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to 'now' (even if the associated ``Calendar`` excludes 'now') with the repeat count left as-is.

  NOTE: Use of this instruction causes the trigger to 'forget' the start-time and repeat-count that it was originally setup with (this is only an issue if you for some reason wanted to be able to tell what the original values were at some later time).

  NOTE: This instruction could cause the `Trigger` to go to the 'COMPLETE' state after firing 'now', if all the repeat-fire-times where missed.

  See Also:
    Constant Field Values

### MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT

    public static final int MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to 'now' (even if the associated ``Calendar`` excludes 'now') with the repeat count set to what it would be, if it had not missed any firings.

  NOTE: Use of this instruction causes the trigger to 'forget' the start-time and repeat-count that it was originally setup with (this is only an issue if you for some reason wanted to be able to tell what the original values were at some later time).

  NOTE: This instruction could cause the `Trigger` to go to the 'COMPLETE' state after firing 'now', if all the repeat-fire-times where missed.

  See Also:
    Constant Field Values

### MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT

    public static final int MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to the next scheduled time after 'now' - taking into account any associated ``Calendar``, and with the repeat count set to what it would be, if it had not missed any firings.

  NOTE/WARNING: This instruction could cause the `Trigger` to go directly to the 'COMPLETE' state if all fire-times where missed.

  See Also:
    Constant Field Values

### MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT

    public static final int MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``SimpleTrigger`` wants to be re-scheduled to the next scheduled time after 'now' - taking into account any associated ``Calendar``, and with the repeat count left unchanged.

  NOTE: Use of this instruction causes the trigger to 'forget' the repeat-count that it was originally setup with (this is only an issue if you for some reason wanted to be able to tell what the original values were at some later time).

  NOTE/WARNING: This instruction could cause the `Trigger` to go directly to the 'COMPLETE' state if all fire-times where missed.

  See Also:
    Constant Field Values

### REPEAT_INDEFINITELY

    public static int REPEAT_INDEFINITELY

  Used to indicate the 'repeat count' of the trigger is indefinite. Or in other words, the trigger should repeat continually until the trigger's ending timestamp.

Constructor Detail

### SimpleTrigger

    public SimpleTrigger()

  Create a `SimpleTrigger` with no settings.

### SimpleTrigger

    public SimpleTrigger(String name,
                         String group)

  Create a `SimpleTrigger` that will occur immediately, and not repeat.

### SimpleTrigger

    public SimpleTrigger(String name,
                         String group,
                         int repeatCount,
                         long repeatInterval)

  Create a `SimpleTrigger` that will occur immediately, and repeat at the the given interval the given number of times.

### SimpleTrigger

    public SimpleTrigger(String name,
                         String group,
                         Date startTime)

  Create a `SimpleTrigger` that will occur at the given time, and not repeat.

### SimpleTrigger

    public SimpleTrigger(String name,
                         String group,
                         Date startTime,
                         Date endTime,
                         int repeatCount,
                         long repeatInterval)

  Create a `SimpleTrigger` that will occur at the given time, and repeat at the the given interval the given number of times, or until the given end time.

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.
  `repeatCount` - The number of times for the `Trigger` to repeat firing, use `REPEAT_INDEFINITELY`for unlimitted times.
  `repeatInterval` - The number of milliseconds to pause between the repeat firing.

### SimpleTrigger

    public SimpleTrigger(String name,
                         String group,
                         String jobName,
                         String jobGroup,
                         Date startTime,
                         Date endTime,
                         int repeatCount,
                         long repeatInterval)

  Create a `SimpleTrigger` that will occur at the given time, fire the identified `Job` and repeat at the the given interval the given number of times, or until the given end time.

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.
  `repeatCount` - The number of times for the `Trigger` to repeat firing, use `REPEAT_INDEFINITELY`for unlimitted times.
  `repeatInterval` - The number of milliseconds to pause between the repeat firing.

Method Detail

### getStartTime

    public Date getStartTime()

  Get the time at which the `SimpleTrigger` should occur.

  Specified by:
    `getStartTime` in class `Trigger`

### setStartTime

    public void setStartTime(Date startTime)

  Set the time at which the `SimpleTrigger` should occur.

  Specified by:
    `setStartTime` in class `Trigger`
  Throws:
    `IllegalArgumentException` - if startTime is `null`.

### getEndTime

    public Date getEndTime()

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

  Specified by:
    `getEndTime` in class `Trigger`
  See Also:
    `getFinalFireTime()`

### setEndTime

    public void setEndTime(Date endTime)

  Set the time at which the `SimpleTrigger` should quit repeating (and be automatically deleted).

  Specified by:
    `setEndTime` in class `Trigger`
  Throws:
    `IllegalArgumentException` - if endTime is before start time.

### getRepeatCount

    public int getRepeatCount()

  Get the the number of times the `SimpleTrigger` should repeat, after which it will be automatically deleted.

  See Also:
    `REPEAT_INDEFINITELY`

### setRepeatCount

    public void setRepeatCount(int repeatCount)

  Set the the number of time the `SimpleTrigger` should repeat, after which it will be automatically deleted.

  Throws:
    `IllegalArgumentException` - if repeatCount is < 0
  See Also:
    `REPEAT_INDEFINITELY`

### getRepeatInterval

    public long getRepeatInterval()

  Get the the time interval (in milliseconds) at which the `SimpleTrigger` should repeat.

### setRepeatInterval

    public void setRepeatInterval(long repeatInterval)

  Set the the time interval (in milliseconds) at which the `SimpleTrigger` should repeat.

  Throws:
    `IllegalArgumentException` - if repeatInterval is <= 0

### getTimesTriggered

    public int getTimesTriggered()

  Get the number of times the `SimpleTrigger` has already fired.

### setTimesTriggered

    public void setTimesTriggered(int timesTriggered)

  Set the number of times the `SimpleTrigger` has already fired.

### validateMisfireInstruction

    protected boolean validateMisfireInstruction(int misfireInstruction)

  Specified by:
    `validateMisfireInstruction` in class `Trigger`

### updateAfterMisfire

    public void updateAfterMisfire(Calendar cal)

  Updates the `SimpleTrigger`'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:

  - If the Repeat Count is `0`, then the instruction will be interpreted as `MISFIRE_INSTRUCTION_FIRE_NOW`.
  - If the Repeat Count is `REPEAT_INDEFINITELY`, then the instruction will be interpreted as `MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT`. WARNING: using MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT with a trigger that has a non-null end-time may cause the trigger to never fire again if the end-time arrived during the misfire time span.
  - If the Repeat Count is `> 0`, then the instruction will be interpreted as `MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT`.

  Specified by:
    `updateAfterMisfire` in class `Trigger`

### triggered

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

  Specified by:
    `triggered` in class `Trigger`
  See Also:
    `executionComplete(JobExecutionContext, JobExecutionException)`

### 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 associated `Calendar` (the state should be updated so that it's next fire time is appropriate given the Calendar's new settings).

  Specified by:
    `updateWithNewCalendar` in class `Trigger`
  Parameters:
    `calendar` -
  See Also:
    `Trigger.updateWithNewCalendar(org.quartz.Calendar, long)`

### computeFirstFireTime

    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.

  Specified by:
    `computeFirstFireTime` in class `Trigger`
  Returns:
    the first time at which the `Trigger` will be fired by the scheduler, which is also the same value `getNextFireTime()` will return (until after the first firing of the `Trigger`).

### executionComplete

    public int executionComplete(JobExecutionContext context,
                                 JobExecutionException result)

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

  Specified by:
    `executionComplete` in class `Trigger`
  Parameters:
    `context` - is the `JobExecutionContext` that was used by the `Job`'s`execute(xx)` method.
    `result` - is the `JobExecutionException` thrown by the `Job`, if any (may be null).
  Returns:
    one of the Trigger.INSTRUCTION_XXX constants.
  See Also:
    `Trigger.INSTRUCTION_NOOP`, `Trigger.INSTRUCTION_RE_EXECUTE_JOB`, `Trigger.INSTRUCTION_DELETE_TRIGGER`, `Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE`, `triggered(Calendar)`

### getNextFireTime

    public Date getNextFireTime()

  Returns the next time at which the `SimpleTrigger` 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.

  Specified by:
    `getNextFireTime` in class `Trigger`

### getPreviousFireTime

    public Date getPreviousFireTime()

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

  Specified by:
    `getPreviousFireTime` in class `Trigger`

### setNextFireTime

    public void setNextFireTime(Date nextFireTime)

  Set the next time at which the `SimpleTrigger` should fire.

  This method should not be invoked by client code.

### setPreviousFireTime

    public void setPreviousFireTime(Date previousFireTime)

  Set the previous time at which the `SimpleTrigger` fired.

  This method should not be invoked by client code.

### getFireTimeAfter

    public Date getFireTimeAfter(Date afterTime)

  Returns the next time at which the `SimpleTrigger` will fire, after the given time. If the trigger will not fire after the given time, `null` will be returned.

  Specified by:
    `getFireTimeAfter` in class `Trigger`

### getFireTimeBefore

    public Date getFireTimeBefore(Date end)

  Returns the last time at which the `SimpleTrigger` will fire, before the given time. If the trigger will not fire before the given time, `null` will be returned.

### computeNumTimesFiredBetween

    public int computeNumTimesFiredBetween(Date start,
                                           Date end)

### getFinalFireTime

    public Date getFinalFireTime()

  Returns the final time at which the `SimpleTrigger` will fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.

  Note that the return time may be in the past.

  Specified by:
    `getFinalFireTime` in class `Trigger`

### mayFireAgain

    public boolean mayFireAgain()

  Determines whether or not the `SimpleTrigger` will occur again.

  Specified by:
    `mayFireAgain` in class `Trigger`

### validate

    public void validate()
                  throws SchedulerException

  Validates whether the properties of the `JobDetail` are valid for submission into a `Scheduler`.

  Overrides:
    `validate` in class `Trigger`
  Throws:
    `IllegalStateException` - if a required property (such as Name, Group, Class) is not set.
    `SchedulerException`

### main

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

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Quartz Enterprise Job Scheduler Project Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD