Package org.quartz.simpl
Class PropertySettingJobFactory
- java.lang.Object
-
- org.quartz.simpl.SimpleJobFactory
-
- org.quartz.simpl.PropertySettingJobFactory
-
- All Implemented Interfaces:
org.quartz.spi.JobFactory
public class PropertySettingJobFactory extends org.quartz.simpl.SimpleJobFactoryA JobFactory that instantiates the Job instance (using the default no-arg constructor, or more specifically:class.newInstance()), and then attempts to set all values from theSchedulerContextand theJobExecutionContext's mergedJobDataMaponto bean properties of theJob.Set the warnIfPropertyNotFound property to true if you'd like noisy logging in the case of values in the JobDataMap not mapping to properties on your Job class. This may be useful for troubleshooting typos of property names, etc. but very noisy if you regularly (and purposely) have extra things in your JobDataMap.
Also of possible interest is the throwIfPropertyNotFound property which will throw exceptions on unmatched JobDataMap keys.
- Author:
- jhouse
- See Also:
JobFactory,SimpleJobFactory,SchedulerContext,JobExecutionContext.getMergedJobDataMap(),setWarnIfPropertyNotFound(boolean),setThrowIfPropertyNotFound(boolean)
-
-
Constructor Summary
Constructors Constructor Description PropertySettingJobFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisThrowIfPropertyNotFound()Whether the JobInstantiation should fail and throw and exception if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.booleanisWarnIfPropertyNotFound()Whether a warning should be logged if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.org.quartz.JobnewJob(org.quartz.spi.TriggerFiredBundle bundle, org.quartz.Scheduler scheduler)protected voidsetBeanProps(Object obj, org.quartz.JobDataMap data)voidsetThrowIfPropertyNotFound(boolean throwIfNotFound)Whether the JobInstantiation should fail and throw and exception if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.voidsetWarnIfPropertyNotFound(boolean warnIfNotFound)Whether a warning should be logged if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.
-
-
-
Method Detail
-
newJob
public org.quartz.Job newJob(org.quartz.spi.TriggerFiredBundle bundle, org.quartz.Scheduler scheduler) throws org.quartz.SchedulerException- Specified by:
newJobin interfaceorg.quartz.spi.JobFactory- Overrides:
newJobin classorg.quartz.simpl.SimpleJobFactory- Throws:
org.quartz.SchedulerException
-
setBeanProps
protected void setBeanProps(Object obj, org.quartz.JobDataMap data) throws org.quartz.SchedulerException
- Throws:
org.quartz.SchedulerException
-
isThrowIfPropertyNotFound
public boolean isThrowIfPropertyNotFound()
Whether the JobInstantiation should fail and throw and exception if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.- Returns:
- Returns the throwIfNotFound.
-
setThrowIfPropertyNotFound
public void setThrowIfPropertyNotFound(boolean throwIfNotFound)
Whether the JobInstantiation should fail and throw and exception if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.- Parameters:
throwIfNotFound- defaults tofalse.
-
isWarnIfPropertyNotFound
public boolean isWarnIfPropertyNotFound()
Whether a warning should be logged if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.- Returns:
- Returns the warnIfNotFound.
-
setWarnIfPropertyNotFound
public void setWarnIfPropertyNotFound(boolean warnIfNotFound)
Whether a warning should be logged if a key (name) and value (type) found in the JobDataMap does not correspond to a proptery setter on the Job class.- Parameters:
warnIfNotFound- defaults totrue.
-
-