The Spring Framework

org.springframework.scheduling.quartz
Class SimpleTriggerBean

java.lang.Object
  extended by org.quartz.Trigger
      extended by org.quartz.SimpleTrigger
          extended by org.springframework.scheduling.quartz.SimpleTriggerBean
All Implemented Interfaces:
Serializable, Cloneable, Comparable, BeanNameAware, InitializingBean, JobDetailAwareTrigger

public class SimpleTriggerBean
extends SimpleTrigger
implements JobDetailAwareTrigger, BeanNameAware, InitializingBean

Convenience subclass of Quartz's SimpleTrigger class, making bean-style usage easier.

SimpleTrigger itself is already a JavaBean but lacks sensible defaults. This class uses the Spring bean name as job name, the Quartz default group ("DEFAULT") as job group, the current time as start time, and indefinite repetition, if not specified.

This class will also register the trigger with the job name and group of a given JobDetail. This allows SchedulerFactoryBean to automatically register a trigger for the corresponding JobDetail, instead of registering the JobDetail separately.

NOTE: This convenience subclass does not work with trigger persistence in Quartz 1.6, due to a change in Quartz's trigger handling. Use Quartz 1.5 if you rely on trigger persistence based on this class, or the standard Quartz SimpleTrigger class instead.

Since:
18.02.2004
Author:
Juergen Hoeller
See Also:
Trigger.setName(java.lang.String), Trigger.setGroup(java.lang.String), SimpleTrigger.setStartTime(java.util.Date), Trigger.setJobName(java.lang.String), Trigger.setJobGroup(java.lang.String), setJobDetail(org.quartz.JobDetail), SchedulerFactoryBean.setTriggers(org.quartz.Trigger[]), SchedulerFactoryBean.setJobDetails(org.quartz.JobDetail[]), CronTriggerBean, Serialized Form

Field Summary
 
Fields inherited from class org.quartz.SimpleTrigger
MISFIRE_INSTRUCTION_FIRE_NOW, MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT, REPEAT_INDEFINITELY
 
Fields inherited from class org.quartz.Trigger
DEFAULT_PRIORITY, 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
SimpleTriggerBean()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 JobDetail getJobDetail()
          Return the JobDetail that this Trigger is associated with.
 void setBeanName(String beanName)
          Set the name of the bean in the bean factory that created this bean.
 void setJobDataAsMap(Map jobDataAsMap)
          Register objects in the JobDataMap via a given Map.
 void setJobDetail(JobDetail jobDetail)
          Set the JobDetail that this trigger should be associated with.
 void setMisfireInstructionName(String constantName)
          Set the misfire instruction via the name of the corresponding constant in the SimpleTrigger class.
 void setStartDelay(long startDelay)
          Set the delay before starting the job for the first time.
 void setTriggerListenerNames(String[] names)
          Set a list of TriggerListener names for this job, referring to non-global TriggerListeners registered with the Scheduler.
 
Methods inherited from class org.quartz.SimpleTrigger
computeFirstFireTime, computeNumTimesFiredBetween, executionComplete, getEndTime, getFinalFireTime, getFireTimeAfter, getFireTimeBefore, getNextFireTime, getPreviousFireTime, getRepeatCount, getRepeatInterval, getStartTime, getTimesTriggered, hasAdditionalProperties, main, mayFireAgain, setEndTime, setNextFireTime, setPreviousFireTime, setRepeatCount, setRepeatInterval, setStartTime, setTimesTriggered, triggered, updateAfterMisfire, updateWithNewCalendar, validate, validateMisfireInstruction
 
Methods inherited from class org.quartz.Trigger
addTriggerListener, clearAllTriggerListeners, clone, compareTo, equals, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerListenerNames, hashCode, isVolatile, removeTriggerListener, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobName, setMisfireInstruction, setName, setPriority, setVolatility, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTriggerBean

public SimpleTriggerBean()
Method Detail

setJobDataAsMap

public void setJobDataAsMap(Map jobDataAsMap)
Register objects in the JobDataMap via a given Map.

These objects will be available to this Trigger only, in contrast to objects in the JobDetail's data map.

Parameters:
jobDataAsMap - Map with String keys and any objects as values (for example Spring-managed beans)
See Also:
JobDetailBean.setJobDataAsMap(java.util.Map)

setMisfireInstructionName

public void setMisfireInstructionName(String constantName)
Set the misfire instruction via the name of the corresponding constant in the SimpleTrigger class. Default is MISFIRE_INSTRUCTION_SMART_POLICY.

See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT, Trigger.MISFIRE_INSTRUCTION_SMART_POLICY

setTriggerListenerNames

public void setTriggerListenerNames(String[] names)
Set a list of TriggerListener names for this job, referring to non-global TriggerListeners registered with the Scheduler.

A TriggerListener name always refers to the name returned by the TriggerListener implementation.

See Also:
SchedulerFactoryBean.setTriggerListeners(org.quartz.TriggerListener[]), TriggerListener.getName()

setStartDelay

public void setStartDelay(long startDelay)
Set the delay before starting the job for the first time. The given number of milliseconds will be added to the current time to calculate the start time. Default is 0.

This delay will just be applied if no custom start time was specified. However, in typical usage within a Spring context, the start time will be the container startup time anyway. Specifying a relative delay is appropriate in that case.

See Also:
SimpleTrigger.setStartTime(java.util.Date)

setJobDetail

public void setJobDetail(JobDetail jobDetail)
Set the JobDetail that this trigger should be associated with.

This is typically used with a bean reference if the JobDetail is a Spring-managed bean. Alternatively, the trigger can also be associated with a job by name and group.

See Also:
Trigger.setJobName(java.lang.String), Trigger.setJobGroup(java.lang.String)

getJobDetail

public JobDetail getJobDetail()
Description copied from interface: JobDetailAwareTrigger
Return the JobDetail that this Trigger is associated with.

Specified by:
getJobDetail in interface JobDetailAwareTrigger
Returns:
the associated JobDetail, or null if none

setBeanName

public void setBeanName(String beanName)
Description copied from interface: BeanNameAware
Set the name of the bean in the bean factory that created this bean.

Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet() or a custom init-method.

Specified by:
setBeanName in interface BeanNameAware
Parameters:
beanName - the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String) method to extract the original bean name (without suffix), if desired.

afterPropertiesSet

public void afterPropertiesSet()
                        throws ParseException
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
ParseException

The Spring Framework

Copyright © 2002-2008 The Spring Framework.