org.quartz.plugins.xml
Class JobInitializationPlugin

java.lang.Object
  extended byorg.quartz.plugins.xml.JobInitializationPlugin
All Implemented Interfaces:
FileScanListener, SchedulerPlugin

public class JobInitializationPlugin
extends java.lang.Object
implements SchedulerPlugin, FileScanListener

This plugin loads an XML file to add jobs and schedule them with triggers as the scheduler is initialized, and can optionally periodically scan the file for changes.

Author:
James House, Pierre Awaragi

Constructor Summary
JobInitializationPlugin()
           
 
Method Summary
 void fileUpdated(java.lang.String fileName)
           
 java.lang.String getFileName()
          The file name (and path) to the XML file that should be read.
protected static org.apache.commons.logging.Log getLog()
           
 long getScanInterval()
          The interval (in seconds) at which to scan for changes to the file.
 void initialize(java.lang.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.
 boolean isOverWriteExistingJobs()
          Whether or not jobs defined in the XML file should be overwrite existing jobs with the same name.
 boolean isUseContextClassLoader()
          Whether or not the context class loader should be used.
 boolean isValidating()
          Whether or not the XML should be validated.
 boolean isValidatingSchema()
          Whether or not the XML schema should be validated.
 void processFile()
           
 void setFailOnFileNotFound(boolean failOnFileNotFound)
          Whether or not initialization of the plugin should fail (throw an exception) if the file cannot be found.
 void setFileName(java.lang.String fileName)
          The file name (and path) to the XML file that should be read.
 void setOverWriteExistingJobs(boolean overWriteExistingJobs)
          Whether or not jobs defined in the XML file should be overwrite existing jobs with the same name.
 void setScanInterval(long scanInterval)
          The interval (in seconds) at which to scan for changes to the file.
 void setUseContextClassLoader(boolean useContextClassLoader)
          Whether or not context class loader should be used.
 void setValidating(boolean validating)
          Whether or not the XML should be validated.
 void setValidatingSchema(boolean validatingSchema)
          Whether or not the XML schema should be validated.
 void shutdown()
           Called in order to inform the SchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.
 void start()
           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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobInitializationPlugin

public JobInitializationPlugin()
Method Detail

getFileName

public java.lang.String getFileName()
The file name (and path) to the XML file that should be read.

Returns:

setFileName

public void setFileName(java.lang.String fileName)
The file name (and path) to the XML file that should be read.

Parameters:
fileName -

isOverWriteExistingJobs

public boolean isOverWriteExistingJobs()
Whether or not jobs defined in the XML file should be overwrite existing jobs with the same name.

Returns:

setOverWriteExistingJobs

public void setOverWriteExistingJobs(boolean overWriteExistingJobs)
Whether or not jobs defined in the XML file should be overwrite existing jobs with the same name.

Parameters:
overWriteExistingJobs -

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.

Returns:

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.


isUseContextClassLoader

public boolean isUseContextClassLoader()
Whether or not the context class loader should be used. Default is true.

Returns:

setUseContextClassLoader

public void setUseContextClassLoader(boolean useContextClassLoader)
Whether or not context class loader should be used. Default is true.

Parameters:
useContextClassLoader -

isValidating

public boolean isValidating()
Whether or not the XML should be validated. Default is true.

Returns:

setValidating

public void setValidating(boolean validating)
Whether or not the XML should be validated. Default is true.

Parameters:
validating -

isValidatingSchema

public boolean isValidatingSchema()
Whether or not the XML schema should be validated. Default is true.

Returns:

setValidatingSchema

public void setValidatingSchema(boolean validatingSchema)
Whether or not the XML schema should be validated. Default is true.

Parameters:
validatingSchema -

getLog

protected static org.apache.commons.logging.Log getLog()

initialize

public void initialize(java.lang.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 SchedulerPlugin
Parameters:
name - The name by which the plugin is identified.
scheduler - The scheduler to which the plugin is registered.
Throws:
SchedulerConfigException - if there is an error initializing.
SchedulerException

start

public void start()
Description copied from interface: SchedulerPlugin

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.

Specified by:
start in interface SchedulerPlugin

shutdown

public void shutdown()

Called in order to inform the SchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.

Specified by:
shutdown in interface SchedulerPlugin

processFile

public void processFile()

fileUpdated

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

Quartz Project Page