org.springframework.scheduling.quartz
Class CronTriggerBean

java.lang.Object
  extended byorg.quartz.Trigger
      extended byorg.quartz.CronTrigger
          extended byorg.springframework.scheduling.quartz.CronTriggerBean
All Implemented Interfaces:
BeanNameAware, Cloneable, Comparable, InitializingBean, JobDetailAwareTrigger, Serializable

public class CronTriggerBean
extends CronTrigger
implements JobDetailAwareTrigger, BeanNameAware, InitializingBean

Convenience subclass of Quartz' CronTrigger class that eases bean-style usage.

CronTrigger 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 the default timezone 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 respective JobDetail, instead of registering the JobDetail separately.

Since:
18.02.2004
Author:
Juergen Hoeller
See Also:
Trigger.setName(java.lang.String), Trigger.setGroup(java.lang.String), CronTrigger.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[]), Serialized Form

Field Summary
 
Fields inherited from class org.quartz.CronTrigger
ALL_SPEC, ALL_SPEC_INT, calendardayOfMonth, calendardayOfWeek, DAY_OF_MONTH, DAY_OF_WEEK, dayMap, daysOfMonth, daysOfWeek, expressionParsed, HOUR, hours, lastdayOfMonth, lastdayOfWeek, MINUTE, minutes, MISFIRE_INSTRUCTION_DO_NOTHING, MISFIRE_INSTRUCTION_FIRE_ONCE_NOW, MONTH, monthMap, months, nearestWeekday, NO_SPEC, NO_SPEC_INT, nthdayOfWeek, SECOND, seconds, YEAR, years
 
Fields inherited from class org.quartz.Trigger
INSTRUCTION_DELETE_TRIGGER, INSTRUCTION_NOOP, INSTRUCTION_RE_EXECUTE_JOB, INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE, INSTRUCTION_SET_TRIGGER_COMPLETE, MISFIRE_INSTRUCTION_SMART_POLICY, STATE_BLOCKED, STATE_COMPLETE, STATE_ERROR, STATE_NONE, STATE_NORMAL, STATE_PAUSED
 
Constructor Summary
CronTriggerBean()
           
 
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 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 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.CronTrigger
addToSet, buildExpression, checkNext, computeFirstFireTime, executionComplete, findNextWhiteSpace, getCronExpression, getDayOfWeekNumber, getEndTime, getExpressionSetSummary, getExpressionSetSummary, getExpressionSummary, getFinalFireTime, getFireTimeAfter, getLastDayOfMonth, getMonthNumber, getNextFireTime, getNumericValue, getPreviousFireTime, getSet, getStartTime, getTime, getTimeAfter, getTimeBefore, getTimeZone, getValue, isLeapYear, main, mayFireAgain, setCalendarHour, setCronExpression, setEndTime, setNextFireTime, setPreviousFireTime, setStartTime, setTimeZone, skipWhiteSpace, storeExpressionVals, triggered, updateAfterMisfire, updateWithNewCalendar, validateMisfireInstruction, willFireOn, willFireOn
 
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
 

Constructor Detail

CronTriggerBean

public CronTriggerBean()
Method Detail

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:
CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW, CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING, 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()

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 like InitializingBean's afterPropertiesSet or a custom init-method.

Specified by:
setBeanName in interface BeanNameAware
Parameters:
beanName - the name of the bean in the factory

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


Copyright (C) 2003-2004 The Spring Framework Project.