org.quartz.simpl
Class PropertySettingJobFactory

java.lang.Object
  extended by org.quartz.simpl.SimpleJobFactory
      extended by org.quartz.simpl.PropertySettingJobFactory
All Implemented Interfaces:
org.quartz.spi.JobFactory

public class PropertySettingJobFactory
extends SimpleJobFactory

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

Author:
jhouse
See Also:
JobFactory, SimpleJobFactory, SchedulerContext, JobExecutionContext.getMergedJobDataMap(), setWarnIfPropertyNotFound(boolean), setThrowIfPropertyNotFound(boolean)

Constructor Summary
PropertySettingJobFactory()
           
 
Method Summary
 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.
 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.
 Job newJob(org.quartz.spi.TriggerFiredBundle bundle, Scheduler scheduler)
           
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.
 
Methods inherited from class org.quartz.simpl.SimpleJobFactory
getLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertySettingJobFactory

public PropertySettingJobFactory()
Method Detail

newJob

public Job newJob(org.quartz.spi.TriggerFiredBundle bundle,
                  Scheduler scheduler)
           throws SchedulerException
Specified by:
newJob in interface org.quartz.spi.JobFactory
Overrides:
newJob in class SimpleJobFactory
Throws:
SchedulerException

setBeanProps

protected void setBeanProps(Object obj,
                            JobDataMap data)
                     throws SchedulerException
Throws:
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 to false.

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 to true.


Copyright 2001-2013, Terracotta, Inc.