Package org.quartz.plugins.xml
Class FileScanJob
- java.lang.Object
-
- org.quartz.plugins.xml.FileScanJob
-
- All Implemented Interfaces:
Job
@DisallowConcurrentExecution @PersistJobDataAfterExecution public class FileScanJob extends java.lang.Object implements Job
Inspects a file and compares whether it's "last modified date" has changed since the last time it was inspected. If the file has been updated, the job invokes a "call-back" method on an identifiedFileScanListener
that can be found in theSchedulerContext
.- Author:
- jhouse, pl47ypus
- See Also:
FileScanListener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FILE_NAME
JobDataMap
key with which to specify the name of the file to monitor.static java.lang.String
FILE_SCAN_LISTENER_NAME
JobDataMap
key with which to specify theFileScanListener
to be notified when the file contents change.static java.lang.String
MINIMUM_UPDATE_AGE
JobDataMap
key with which to specify along
value that represents the minimum number of milliseconds that must have past since the file's last modified time in order to consider the file new/altered.
-
Constructor Summary
Constructors Constructor Description FileScanJob()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(JobExecutionContext context)
protected long
getLastModifiedDate(java.lang.String fileName)
-
-
-
Field Detail
-
FILE_NAME
public static final java.lang.String FILE_NAME
JobDataMap
key with which to specify the name of the file to monitor.- See Also:
- Constant Field Values
-
FILE_SCAN_LISTENER_NAME
public static final java.lang.String FILE_SCAN_LISTENER_NAME
JobDataMap
key with which to specify theFileScanListener
to be notified when the file contents change.- See Also:
- Constant Field Values
-
MINIMUM_UPDATE_AGE
public static final java.lang.String MINIMUM_UPDATE_AGE
JobDataMap
key with which to specify along
value that represents the minimum number of milliseconds that must have past since the file's last modified time in order to consider the file new/altered. This is necessary because another process may still be in the middle of writing to the file when the scan occurs, and the file may therefore not yet be ready for processing.If this parameter is not specified, a default value of
5000
(five seconds) will be used.- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public void execute(JobExecutionContext context) throws JobExecutionException
Description copied from interface:Job
Called by the
when aScheduler
fires that is associated with theTrigger
Job
.The implementation may wish to set a
result
object on theJobExecutionContext
before this method exits. The result itself is meaningless to Quartz, but may be informative to
orJobListener
s
that are watching the job's execution.TriggerListener
s- Specified by:
execute
in interfaceJob
- Throws:
JobExecutionException
- if there is an exception while executing the job.- See Also:
Job.execute(JobExecutionContext)
-
getLastModifiedDate
protected long getLastModifiedDate(java.lang.String fileName)
-
-