public class PropertySettingJobFactory extends SimpleJobFactory
class.newInstance()), and
then attempts to set all values from the SchedulerContext and
the JobExecutionContext's merged JobDataMap onto
bean properties of the Job.
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.
| Constructor and Description |
|---|
PropertySettingJobFactory() |
| Modifier and Type | Method and Description |
|---|---|
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
property setter on the Job class.
|
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.
|
IJob |
newJob(TriggerFiredBundle bundle,
IScheduler scheduler)
Called by the scheduler at the time of the trigger firing, in order to
produce a
Job instance on which to call execute. |
protected void |
setBeanProps(Object obj,
JobDataMap data) |
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.
|
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.
|
public IJob newJob(TriggerFiredBundle bundle, IScheduler scheduler) throws SchedulerException
IJobFactoryJob instance on which to call execute.
It should be extremely rare for this method to throw an exception -
basically only the the case where there is no way at all to instantiate and
prepare the Job for execution. When the exception is thrown, the Scheduler
will move all triggers associated with the Job into the
Trigger.STATE_ERROR state, which will require human
intervention (e.g. an application restart after fixing whatever
configuration problem led to the issue wih instantiating the Job.
newJob in interface IJobFactorynewJob in class SimpleJobFactorybundle - The TriggerFiredBundle from which the JobDetail and
other info relating to the trigger firing can be obtained.scheduler - a handle to the scheduler that is about to execute the job.SchedulerException - if there is a problem instantiating the Job.protected void setBeanProps(Object obj, JobDataMap data) throws SchedulerException
SchedulerExceptionpublic boolean isThrowIfPropertyNotFound()
public void setThrowIfPropertyNotFound(boolean throwIfNotFound)
throwIfNotFound - defaults to false.public boolean isWarnIfPropertyNotFound()
public void setWarnIfPropertyNotFound(boolean warnIfNotFound)
warnIfNotFound - defaults to true.Copyright © 2016–2021 Philip Helger. All rights reserved.