org.quartz.plugins.xml
Class XMLSchedulingDataProcessorPlugin

java.lang.Object
  extended by org.quartz.plugins.SchedulerPluginWithUserTransactionSupport
      extended by org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
All Implemented Interfaces:
FileScanListener, org.quartz.spi.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
protected  org.quartz.spi.ClassLoadHelper classLoadHelper
           
 
Constructor Summary
XMLSchedulingDataProcessorPlugin()
           
 
Method Summary
 void fileUpdated(String fileName)
           
 String getFileNames()
          Comma separated list of file names (with paths) to the XML files that should be read.
 long getScanInterval()
          The interval (in seconds) at which to scan for changes to the file.
 void initialize(String name, Scheduler scheduler)
           Called during creation of the Scheduler in order to give the SchedulerPlugin a chance to initialize.
 boolean isFailOnFileNotFound()
          Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found.
 void processFile(String filePath)
           
 void setFailOnFileNotFound(boolean failOnFileNotFound)
          Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found.
 void setFileNames(String fileNames)
          The file name (and path) to the XML file that should be read.
 void setScanInterval(long scanInterval)
          The interval (in seconds) at which to scan for changes to the file.
 void shutdown()
          Overriden to ignore wrapInUserTransaction because shutdown() does not interact with the Scheduler.
 void start(UserTransaction userTransaction)
           Called when the associated Scheduler is 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, setWrapInUserTransaction, shutdown, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLoadHelper

protected org.quartz.spi.ClassLoadHelper classLoadHelper
Constructor Detail

XMLSchedulingDataProcessorPlugin

public XMLSchedulingDataProcessorPlugin()
Method Detail

getFileNames

public String getFileNames()
Comma separated list of file names (with paths) to the XML files that should be read.


setFileNames

public void setFileNames(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 is true.


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


initialize

public void initialize(String name,
                       Scheduler scheduler)
                throws SchedulerException

Called during creation of the Scheduler in order to give the SchedulerPlugin a chance to initialize.

Specified by:
initialize in interface org.quartz.spi.SchedulerPlugin
Overrides:
initialize in class SchedulerPluginWithUserTransactionSupport
Throws:
SchedulerConfigException - if there is an error initializing.
SchedulerException

start

public void start(UserTransaction userTransaction)
Description copied from class: SchedulerPluginWithUserTransactionSupport

Called when the associated Scheduler is 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:
start in class SchedulerPluginWithUserTransactionSupport
Parameters:
userTransaction - The UserTranaction 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()
Overriden to ignore wrapInUserTransaction because shutdown() does not interact with the Scheduler.

Specified by:
shutdown in interface org.quartz.spi.SchedulerPlugin
Overrides:
shutdown in class SchedulerPluginWithUserTransactionSupport

processFile

public void processFile(String filePath)

fileUpdated

public void fileUpdated(String fileName)
Specified by:
fileUpdated in interface FileScanListener
See Also:
FileScanListener.fileUpdated(java.lang.String)


Copyright 2001-2013, Terracotta, Inc.