org.quartz.locality
Class DelegatingLocalityTrigger

java.lang.Object
  extended by org.quartz.locality.DelegatingLocalityTrigger
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Trigger>, LocalityAware, LocalityTrigger, org.quartz.spi.MutableTrigger, org.quartz.spi.OperableTrigger, Trigger

public class DelegatingLocalityTrigger
extends Object
implements LocalityTrigger, org.quartz.spi.OperableTrigger, Serializable, Cloneable

Wrapping a Trigger instance while adding the LocalityAware contract All Trigger method calls will be delegated to the wrapped Trigger instance

Author:
Alex Snaps
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.quartz.Trigger
Trigger.CompletedExecutionInstruction, Trigger.TriggerState, Trigger.TriggerTimeComparator
 
Field Summary
 
Fields inherited from interface org.quartz.Trigger
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY, serialVersionUID
 
Constructor Summary
DelegatingLocalityTrigger(Trigger trigger, NodeSpec nodeSpec)
          Constructs a LocalityAware Trigger, wrapping an existing Trigger instance, with additional NodeSpec
 
Method Summary
 Object clone()
           
 int compareTo(Trigger other)
           Compare the next fire time of this Trigger to that of another by comparing their keys, or in other words, sorts them according to the natural (i.e.
 Date computeFirstFireTime(Calendar calendar)
          
 Trigger.CompletedExecutionInstruction executionComplete(JobExecutionContext context, JobExecutionException result)
          
 String getCalendarName()
          Get the name of the Calendar associated with this Trigger.
 String getDescription()
          Return the description given to the Trigger instance by its creator (if any).
 Date getEndTime()
          Get the time at which the Trigger should quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).
 Date getFinalFireTime()
          Returns the last time at which the Trigger will fire, if the Trigger will repeat indefinitely, null will be returned.
 String getFireInstanceId()
          
 Date getFireTimeAfter(Date afterTime)
          Returns the next time at which the Trigger will fire, after the given time.
 JobDataMap getJobDataMap()
          Get the JobDataMap that is associated with the Trigger.
 JobKey getJobKey()
          
 TriggerKey getKey()
          
 int getMisfireInstruction()
          Get the instruction the Scheduler should be given for handling misfire situations for this Trigger- the concrete Trigger type that you are using will have defined a set of additional MISFIRE_INSTRUCTION_XXX constants that may be set as this property's value.
 Date getNextFireTime()
          Returns the next time at which the Trigger is scheduled to fire.
 NodeSpec getNodeSpec()
          Accessor to the NodeSpec instance to evaluate constraints
 Date getPreviousFireTime()
          Returns the previous time at which the Trigger fired.
 int getPriority()
          The priority of a Trigger acts as a tiebreaker such that if two Triggers have the same scheduled fire time, then the one with the higher priority will get first access to a worker thread.
 ScheduleBuilder<Trigger> getScheduleBuilder()
          Get a ScheduleBuilder that is configured to produce a schedule identical to this trigger's schedule.
 Date getStartTime()
          Get the time at which the Trigger should occur.
 TriggerBuilder<Trigger> getTriggerBuilder()
          Get a TriggerBuilder that is configured to produce a Trigger identical to this one.
 boolean mayFireAgain()
          Used by the Scheduler to determine whether or not it is possible for this Trigger to fire again.
 void setCalendarName(String calendarName)
          
 void setDescription(String description)
          
 void setEndTime(Date endTime)
          
 void setFireInstanceId(String id)
          
 void setJobDataMap(JobDataMap jobDataMap)
          
 void setJobKey(JobKey key)
          
 void setKey(TriggerKey key)
          
 void setMisfireInstruction(int misfireInstruction)
          
 void setNextFireTime(Date nextFireTime)
          
 void setPreviousFireTime(Date previousFireTime)
          
 void setPriority(int priority)
          
 void setStartTime(Date startTime)
          
 void triggered(Calendar calendar)
          
 void updateAfterMisfire(Calendar cal)
          
 void updateWithNewCalendar(Calendar cal, long misfireThreshold)
          
 void validate()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.quartz.Trigger
equals
 

Constructor Detail

DelegatingLocalityTrigger

public DelegatingLocalityTrigger(Trigger trigger,
                                 NodeSpec nodeSpec)
Constructs a LocalityAware Trigger, wrapping an existing Trigger instance, with additional NodeSpec

Parameters:
trigger - The Trigger instance to wrap
nodeSpec - The NodeSpec instance
Method Detail

getNodeSpec

public NodeSpec getNodeSpec()
Accessor to the NodeSpec instance to evaluate constraints

Specified by:
getNodeSpec in interface LocalityAware
Returns:

getKey

public TriggerKey getKey()

Specified by:
getKey in interface Trigger

getJobKey

public JobKey getJobKey()

Specified by:
getJobKey in interface Trigger

getDescription

public String getDescription()
Return the description given to the Trigger instance by its creator (if any).

Specified by:
getDescription in interface Trigger
Returns:
null if no description was set.

getCalendarName

public String getCalendarName()
Get the name of the Calendar associated with this Trigger.

Specified by:
getCalendarName in interface Trigger
Returns:
null if there is no associated Calendar.

getJobDataMap

public JobDataMap getJobDataMap()
Get the JobDataMap that is associated with the Trigger.

Changes made to this map during job execution are not re-persisted, and in fact typically result in an IllegalStateException.

Specified by:
getJobDataMap in interface Trigger

getPriority

public int getPriority()
The priority of a Trigger acts as a tiebreaker such that if two Triggers have the same scheduled fire time, then the one with the higher priority will get first access to a worker thread.

If not explicitly set, the default value is 5.

Specified by:
getPriority in interface Trigger
See Also:
Trigger.DEFAULT_PRIORITY

mayFireAgain

public boolean mayFireAgain()
Used by the Scheduler to determine whether or not it is possible for this Trigger to fire again.

If the returned value is false then the Scheduler may remove the Trigger from the JobStore.

Specified by:
mayFireAgain in interface Trigger

getStartTime

public Date getStartTime()
Get the time at which the Trigger should occur.

Specified by:
getStartTime in interface Trigger

getEndTime

public Date getEndTime()
Get the time at which the Trigger should quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).

Specified by:
getEndTime in interface Trigger
See Also:
Trigger.getFinalFireTime()

getNextFireTime

public Date getNextFireTime()
Returns the next time at which the Trigger is scheduled to fire. If the trigger will not fire again, null will be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).

The value returned is not guaranteed to be valid until after the Trigger has been added to the scheduler.

Specified by:
getNextFireTime in interface Trigger
See Also:
TriggerUtils#computeFireTimesBetween(Trigger, Calendar, Date, Date)

getPreviousFireTime

public Date getPreviousFireTime()
Returns the previous time at which the Trigger fired. If the trigger has not yet fired, null will be returned.

Specified by:
getPreviousFireTime in interface Trigger

getFireTimeAfter

public Date getFireTimeAfter(Date afterTime)
Returns the next time at which the Trigger will fire, after the given time. If the trigger will not fire after the given time, null will be returned.

Specified by:
getFireTimeAfter in interface Trigger

getFinalFireTime

public Date getFinalFireTime()
Returns the last time at which the Trigger will fire, if the Trigger will repeat indefinitely, null will be returned.

Note that the return time *may* be in the past.

Specified by:
getFinalFireTime in interface Trigger

getMisfireInstruction

public int getMisfireInstruction()
Get the instruction the Scheduler should be given for handling misfire situations for this Trigger- the concrete Trigger type that you are using will have defined a set of additional MISFIRE_INSTRUCTION_XXX constants that may be set as this property's value.

If not explicitly set, the default value is MISFIRE_INSTRUCTION_SMART_POLICY.

Specified by:
getMisfireInstruction in interface Trigger
See Also:
Trigger.MISFIRE_INSTRUCTION_SMART_POLICY, #updateAfterMisfire(Calendar), SimpleTrigger, CronTrigger

compareTo

public int compareTo(Trigger other)

Compare the next fire time of this Trigger to that of another by comparing their keys, or in other words, sorts them according to the natural (i.e. alphabetical) order of their keys.

Specified by:
compareTo in interface Comparable<Trigger>
Specified by:
compareTo in interface Trigger

getTriggerBuilder

public TriggerBuilder<Trigger> getTriggerBuilder()
Get a TriggerBuilder that is configured to produce a Trigger identical to this one.

Specified by:
getTriggerBuilder in interface Trigger
See Also:
Trigger.getScheduleBuilder()

getScheduleBuilder

public ScheduleBuilder<Trigger> getScheduleBuilder()
Get a ScheduleBuilder that is configured to produce a schedule identical to this trigger's schedule.

Specified by:
getScheduleBuilder in interface Trigger
See Also:
Trigger.getTriggerBuilder()

setKey

public void setKey(TriggerKey key)

Specified by:
setKey in interface org.quartz.spi.MutableTrigger

setJobKey

public void setJobKey(JobKey key)

Specified by:
setJobKey in interface org.quartz.spi.MutableTrigger

setDescription

public void setDescription(String description)

Specified by:
setDescription in interface org.quartz.spi.MutableTrigger

setCalendarName

public void setCalendarName(String calendarName)

Specified by:
setCalendarName in interface org.quartz.spi.MutableTrigger

setJobDataMap

public void setJobDataMap(JobDataMap jobDataMap)

Specified by:
setJobDataMap in interface org.quartz.spi.MutableTrigger

setPriority

public void setPriority(int priority)

Specified by:
setPriority in interface org.quartz.spi.MutableTrigger

setStartTime

public void setStartTime(Date startTime)

Specified by:
setStartTime in interface org.quartz.spi.MutableTrigger

setEndTime

public void setEndTime(Date endTime)

Specified by:
setEndTime in interface org.quartz.spi.MutableTrigger

setMisfireInstruction

public void setMisfireInstruction(int misfireInstruction)

Specified by:
setMisfireInstruction in interface org.quartz.spi.MutableTrigger

triggered

public void triggered(Calendar calendar)

Specified by:
triggered in interface org.quartz.spi.OperableTrigger

computeFirstFireTime

public Date computeFirstFireTime(Calendar calendar)

Specified by:
computeFirstFireTime in interface org.quartz.spi.OperableTrigger

executionComplete

public Trigger.CompletedExecutionInstruction executionComplete(JobExecutionContext context,
                                                               JobExecutionException result)

Specified by:
executionComplete in interface org.quartz.spi.OperableTrigger

updateAfterMisfire

public void updateAfterMisfire(Calendar cal)

Specified by:
updateAfterMisfire in interface org.quartz.spi.OperableTrigger

updateWithNewCalendar

public void updateWithNewCalendar(Calendar cal,
                                  long misfireThreshold)

Specified by:
updateWithNewCalendar in interface org.quartz.spi.OperableTrigger

validate

public void validate()
              throws SchedulerException

Specified by:
validate in interface org.quartz.spi.OperableTrigger
Throws:
SchedulerException

setFireInstanceId

public void setFireInstanceId(String id)

Specified by:
setFireInstanceId in interface org.quartz.spi.OperableTrigger

getFireInstanceId

public String getFireInstanceId()

Specified by:
getFireInstanceId in interface org.quartz.spi.OperableTrigger

setNextFireTime

public void setNextFireTime(Date nextFireTime)

Specified by:
setNextFireTime in interface org.quartz.spi.OperableTrigger

setPreviousFireTime

public void setPreviousFireTime(Date previousFireTime)

Specified by:
setPreviousFireTime in interface org.quartz.spi.OperableTrigger

clone

public Object clone()
Specified by:
clone in interface org.quartz.spi.MutableTrigger
Overrides:
clone in class Object


Copyright 2001-2013, Terracotta, Inc.