Package org.springframework.scheduling.quartz

# Class SimpleTriggerFactoryBean

java.lang.Object
org.springframework.scheduling.quartz.SimpleTriggerFactoryBean

All Implemented Interfaces:
  `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanNameAware`, `org.springframework.beans.factory.FactoryBean<SimpleTrigger>`, `org.springframework.beans.factory.InitializingBean`

public class SimpleTriggerFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<SimpleTrigger>, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
A Spring `FactoryBean` for creating a Quartz `SimpleTrigger` instance, supporting bean-style usage for trigger configuration.

`SimpleTrigger(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.

Since:
  3.1
Author:
  Juergen Hoeller, Sam Brannen
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...)`

## Field Summary

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

## Constructor Summary

Constructors
Constructor
Description
`SimpleTriggerFactoryBean()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
`JobDataMap`
`getJobDataMap()`
Return the trigger's JobDataMap.
`SimpleTrigger`
`getObject()`
`Class<?>`
`getObjectType()`
`boolean`
`isSingleton()`
`void`
`setBeanName(String beanName)`
`void`
`setDescription(String description)`
Associate a textual description with this trigger.
`void`
`setGroup(String group)`
Specify the trigger's group.
`void`
`setJobDataAsMap(Map<String,?> jobDataAsMap)`
Register objects in the JobDataMap via a given Map.
`void`
`setJobDataMap(JobDataMap jobDataMap)`
Set the trigger's JobDataMap.
`void`
`setJobDetail(JobDetail jobDetail)`
Set the JobDetail that this trigger should be associated with.
`void`
`setMisfireInstruction(int misfireInstruction)`
Specify the misfire instruction for this trigger.
`void`
`setMisfireInstructionName(String constantName)`
Set the misfire instruction for this trigger via the name of the corresponding constant in the `Trigger` and `SimpleTrigger` classes.
`void`
`setName(String name)`
Specify the trigger's name.
`void`
`setPriority(int priority)`
Specify the priority of this trigger.
`void`
`setRepeatCount(int repeatCount)`
Specify the number of times this trigger is supposed to fire.
`void`
`setRepeatInterval(long repeatInterval)`
Specify the interval between execution times of this trigger.
`void`
`setStartDelay(long startDelay)`
Set the start delay in milliseconds.
`void`
`setStartTime(Date startTime)`
Set a specific start time for the trigger.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SimpleTriggerFactoryBean

public SimpleTriggerFactoryBean()

## Method Details

### setName

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

### setGroup

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

### setJobDetail

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

### setJobDataMap

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

See Also:
  - `setJobDataAsMap(java.util.Map<java.lang.String, ?>)`

### getJobDataMap

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

### setJobDataAsMap

public void setJobDataAsMap(Map<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` - a Map with String keys and any objects as values (for example Spring-managed beans)

### setStartTime

public void setStartTime(Date startTime)
Set a specific start time for the trigger.

Note that a dynamically computed `setStartDelay(long)` specification overrides a static timestamp set here.

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

See Also:
  - `setStartTime(java.util.Date)`

### setRepeatInterval

public void setRepeatInterval(long repeatInterval)
Specify the interval between execution times of this trigger.

### setRepeatCount

public void setRepeatCount(int repeatCount)
Specify the number of times this trigger is supposed to fire.

Default is to repeat indefinitely.

### setPriority

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

### setMisfireInstruction

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

### setMisfireInstructionName

public void setMisfireInstructionName(String constantName)
Set the misfire instruction for this trigger via the name of the corresponding constant in the `Trigger` and `SimpleTrigger` classes.

Default is `MISFIRE_INSTRUCTION_SMART_POLICY`.

See Also:
  - `Trigger.MISFIRE_INSTRUCTION_SMART_POLICY`
  - `Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY`
  - `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`

### setDescription

public void setDescription(String description)
Associate a textual description with this trigger.

### setBeanName

public void setBeanName(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

@Nullable public SimpleTrigger getObject()

Specified by:
  `getObject` in interface `org.springframework.beans.factory.FactoryBean<SimpleTrigger>`

### getObjectType

public Class<?> getObjectType()

Specified by:
  `getObjectType` in interface `org.springframework.beans.factory.FactoryBean<SimpleTrigger>`

### isSingleton

public boolean isSingleton()

Specified by:
  `isSingleton` in interface `org.springframework.beans.factory.FactoryBean<SimpleTrigger>`