Class XMLSchedulingDataProcessorPlugin
- java.lang.Object
-
- org.quartz.plugins.SchedulerPluginWithUserTransactionSupport
-
- org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
-
- All Implemented Interfaces:
FileScanListener,SchedulerPlugin
public class XMLSchedulingDataProcessorPlugin extends SchedulerPluginWithUserTransactionSupport implements FileScanListener
This plugin loads XML file(s) to add jobs and schedule them with triggers as the scheduler is initialized, and can optionally periodically scan the file for changes.The XML schema definition can be found here: http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd
The periodically scanning of files for changes is not currently supported in a clustered environment.
If using this plugin with JobStoreCMT, be sure to set the plugin property wrapInUserTransaction to true. Also, if you have a positive scanInterval be sure to set org.quartz.scheduler.wrapJobExecutionInUserTransaction to true.
- Author:
- James House, Pierre Awaragi, pl47ypus
- See Also:
XMLSchedulingDataProcessor
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassLoadHelperclassLoadHelper
-
Constructor Summary
Constructors Constructor Description XMLSchedulingDataProcessorPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfileUpdated(java.lang.String fileName)java.lang.StringgetFileNames()Comma separated list of file names (with paths) to the XML files that should be read.longgetScanInterval()The interval (in seconds) at which to scan for changes to the file.voidinitialize(java.lang.String name, Scheduler scheduler, ClassLoadHelper schedulerFactoryClassLoadHelper)Called during creation of theSchedulerin order to give theSchedulerPlugina chance to initialize.booleanisFailOnFileNotFound()Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found.voidprocessFile(java.lang.String filePath)voidsetFailOnFileNotFound(boolean failOnFileNotFound)Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found.voidsetFileNames(java.lang.String fileNames)The file name (and path) to the XML file that should be read.voidsetScanInterval(long scanInterval)The interval (in seconds) at which to scan for changes to the file.voidshutdown()Overridden to ignore wrapInUserTransaction because shutdown() does not interact with theScheduler.voidstart(jakarta.transaction.UserTransaction userTransaction)Called when the associatedScheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.-
Methods inherited from class org.quartz.plugins.SchedulerPluginWithUserTransactionSupport
getLog, getName, getScheduler, getWrapInUserTransaction, initialize, setWrapInUserTransaction, shutdown, start
-
-
-
-
Field Detail
-
classLoadHelper
protected ClassLoadHelper classLoadHelper
-
-
Method Detail
-
getFileNames
public java.lang.String getFileNames()
Comma separated list of file names (with paths) to the XML files that should be read.
-
setFileNames
public void setFileNames(java.lang.String fileNames)
The file name (and path) to the XML file that should be read.
-
getScanInterval
public long getScanInterval()
The interval (in seconds) at which to scan for changes to the file. If the file has been changed, it is re-loaded and parsed. The default value for the interval is 0, which disables scanning.- Returns:
- Returns the scanInterval.
-
setScanInterval
public void setScanInterval(long scanInterval)
The interval (in seconds) at which to scan for changes to the file. If the file has been changed, it is re-loaded and parsed. The default value for the interval is 0, which disables scanning.- Parameters:
scanInterval- The scanInterval to set.
-
isFailOnFileNotFound
public boolean isFailOnFileNotFound()
Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found. Default istrue.
-
setFailOnFileNotFound
public void setFailOnFileNotFound(boolean failOnFileNotFound)
Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found. Default istrue.
-
initialize
public void initialize(java.lang.String name, Scheduler scheduler, ClassLoadHelper schedulerFactoryClassLoadHelper) throws SchedulerExceptionCalled during creation of the
Schedulerin order to give theSchedulerPlugina chance to initialize.- Specified by:
initializein interfaceSchedulerPlugin- Parameters:
name- The name by which the plugin is identified.scheduler- The scheduler to which the plugin is registered.schedulerFactoryClassLoadHelper- The classLoadHelper theSchedulerFactoryis actually using- Throws:
SchedulerConfigException- if there is an error initializing.SchedulerException
-
start
public void start(jakarta.transaction.UserTransaction userTransaction)
Description copied from class:SchedulerPluginWithUserTransactionSupportCalled when the associated
Scheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.If UserTransaction is not null, the plugin can call setRollbackOnly() on it to signal that the wrapped transaction should rollback.
- Overrides:
startin classSchedulerPluginWithUserTransactionSupport- Parameters:
userTransaction- The UserTransaction object used to provide a transaction around the start() operation. It will be null if wrapInUserTransaction is false or if the transaction failed to be started.
-
shutdown
public void shutdown()
Overridden to ignore wrapInUserTransaction because shutdown() does not interact with theScheduler.- Specified by:
shutdownin interfaceSchedulerPlugin- Overrides:
shutdownin classSchedulerPluginWithUserTransactionSupport
-
processFile
public void processFile(java.lang.String filePath)
-
fileUpdated
public void fileUpdated(java.lang.String fileName)
- Specified by:
fileUpdatedin interfaceFileScanListener- See Also:
FileScanListener.fileUpdated(java.lang.String)
-
-