public class SimpleTriggerBean extends SimpleTrigger implements JobDetailAwareTrigger, BeanNameAware, InitializingBean
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 against Quartz 2.0.
Use Quartz 2.0's native JobDetailImpl
class or the new Quartz 2.0
builder API instead. Alternatively, switch to Spring's SimpleTriggerFactoryBean
which largely is a drop-in replacement for this class and its properties and
consistently works against Quartz 1.x as well as Quartz 2.x.
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)
,
SchedulerAccessor.setTriggers(org.quartz.Trigger...)
,
SchedulerAccessor.setJobDetails(org.quartz.JobDetail...)
,
CronTriggerBean
,
Serialized FormMISFIRE_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
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
JOB_DETAIL_KEY
Constructor and Description |
---|
SimpleTriggerBean() |
Modifier and Type | Method and Description |
---|---|
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<String,?> 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 start delay in milliseconds.
|
void |
setTriggerListenerNames(String... names)
Deprecated.
as of Spring 4.0, since it only works on Quartz 1.x
|
computeFirstFireTime, computeNumTimesFiredBetween, executionComplete, getEndTime, getFinalFireTime, getFireTimeAfter, getFireTimeBefore, getNextFireTime, getPreviousFireTime, getRepeatCount, getRepeatInterval, getStartTime, getTimesTriggered, hasAdditionalProperties, mayFireAgain, setEndTime, setNextFireTime, setPreviousFireTime, setRepeatCount, setRepeatInterval, setStartTime, setTimesTriggered, triggered, updateAfterMisfire, updateWithNewCalendar, validate, validateMisfireInstruction
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
public void setJobDataAsMap(Map<String,?> jobDataAsMap)
These objects will be available to this Trigger only, in contrast to objects in the JobDetail's data map.
jobDataAsMap
- Map with String keys and any objects as values
(for example Spring-managed beans)JobDetailBean.setJobDataAsMap(java.util.Map<java.lang.String, ?>)
public void setMisfireInstructionName(String constantName)
SimpleTrigger
class.
Default is MISFIRE_INSTRUCTION_SMART_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
,
Trigger.MISFIRE_INSTRUCTION_SMART_POLICY
@Deprecated public void setTriggerListenerNames(String... names)
A TriggerListener name always refers to the name returned by the TriggerListener implementation.
public void setStartDelay(long startDelay)
The start delay is added to the current system time (when the bean starts)
to control the start time
of the trigger.
If the start delay is non-zero, it will always take precedence over start time.
startDelay
- the start delay, in millisecondspublic void setJobDetail(JobDetail jobDetail)
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.
public JobDetail getJobDetail()
JobDetailAwareTrigger
getJobDetail
in interface JobDetailAwareTrigger
null
if nonepublic void setBeanName(String beanName)
BeanNameAware
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName
in interface BeanNameAware
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.public void afterPropertiesSet()
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean