spring-context-support

org.springframework.scheduling.quartz
Class CronTriggerFactoryBean

java.lang.Object
  extended by org.springframework.scheduling.quartz.CronTriggerFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.FactoryBean<org.quartz.CronTrigger>, org.springframework.beans.factory.InitializingBean

public class CronTriggerFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean<org.quartz.CronTrigger>, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

A Spring FactoryBean for creating a Quartz CronTrigger instance, supporting bean-style usage for trigger configuration.

CronTrigger(Impl) 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 FactoryBean works against both Quartz 1.x and Quartz 2.0/2.1, in contrast to the older CronTriggerBean class.

Since:
3.1
Author:
Juergen Hoeller
See Also:
setName(java.lang.String), setGroup(java.lang.String), setStartDelay(long), setJobDetail(org.quartz.JobDetail), SchedulerAccessor.setTriggers(org.quartz.Trigger[]), SchedulerAccessor.setJobDetails(org.quartz.JobDetail[]), SimpleTriggerBean

Constructor Summary
CronTriggerFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 org.quartz.JobDataMap getJobDataMap()
          Return the trigger's JobDataMap.
 org.quartz.CronTrigger getObject()
           
 java.lang.Class<?> getObjectType()
           
 boolean isSingleton()
           
 void setBeanName(java.lang.String beanName)
           
 void setCronExpression(java.lang.String cronExpression)
          Specify the cron expression for this trigger.
 void setGroup(java.lang.String group)
          Specify the trigger's group.
 void setJobDataAsMap(java.util.Map<java.lang.String,?> jobDataAsMap)
          Register objects in the JobDataMap via a given Map.
 void setJobDataMap(org.quartz.JobDataMap jobDataMap)
          Set the trigger's JobDataMap.
 void setJobDetail(org.quartz.JobDetail jobDetail)
          Set the JobDetail that this trigger should be associated with.
 void setMisfireInstruction(int misfireInstruction)
          Specify a misfire instruction for this trigger.
 void setMisfireInstructionName(java.lang.String constantName)
          Set the misfire instruction via the name of the corresponding constant in the CronTrigger class.
 void setName(java.lang.String name)
          Specify the trigger's name.
 void setPriority(int priority)
          Specify the priority of this trigger.
 void setStartDelay(long startDelay)
          Set the start delay in milliseconds.
 void setTimeZone(java.util.TimeZone timeZone)
          Specify the time zone for this trigger's cron expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CronTriggerFactoryBean

public CronTriggerFactoryBean()
Method Detail

setName

public void setName(java.lang.String name)
Specify the trigger's name.


setGroup

public void setGroup(java.lang.String group)
Specify the trigger's group.


setJobDetail

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


setJobDataMap

public void setJobDataMap(org.quartz.JobDataMap jobDataMap)
Set the trigger's JobDataMap.

See Also:
setJobDataAsMap(java.util.Map)

getJobDataMap

public org.quartz.JobDataMap getJobDataMap()
Return the trigger's JobDataMap.


setJobDataAsMap

public void setJobDataAsMap(java.util.Map<java.lang.String,?> 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)

setStartDelay

public void setStartDelay(long startDelay)
Set the start delay in milliseconds.

The start delay is added to the current system time (when the bean starts) to control the start time of the trigger.

Parameters:
startDelay - the start delay, in milliseconds

setCronExpression

public void setCronExpression(java.lang.String cronExpression)
Specify the cron expression for this trigger.


setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Specify the time zone for this trigger's cron expression.


setPriority

public void setPriority(int priority)
Specify the priority of this trigger.


setMisfireInstruction

public void setMisfireInstruction(int misfireInstruction)
Specify a misfire instruction for this trigger.


setMisfireInstructionName

public void setMisfireInstructionName(java.lang.String constantName)
Set the misfire instruction via the name of the corresponding constant in the CronTrigger 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

setBeanName

public void setBeanName(java.lang.String beanName)
Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

getObject

public org.quartz.CronTrigger getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<org.quartz.CronTrigger>

getObjectType

public java.lang.Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.quartz.CronTrigger>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<org.quartz.CronTrigger>

spring-context-support