Package org.quartz.jobs
Class DirectoryScanJob
- java.lang.Object
-
- org.quartz.jobs.DirectoryScanJob
-
- All Implemented Interfaces:
org.quartz.Job
@DisallowConcurrentExecution @PersistJobDataAfterExecution public class DirectoryScanJob extends java.lang.Object implements org.quartz.JobInspects a directory and compares whether any files' "last modified dates" have changed since the last time it was inspected. If one or more files have been updated (or created), the job invokes a "call-back" method on an identifiedDirectoryScanListenerthat can be found in theSchedulerContext.- See Also:
DirectoryScanListener,SchedulerContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDIRECTORY_NAMEJobDataMapkey with which to specify the directory to be monitored - an absolute path is recommended.static java.lang.StringDIRECTORY_SCAN_LISTENER_NAMEJobDataMapkey with which to specify theDirectoryScanListenerto be notified when the directory contents change.static java.lang.StringMINIMUM_UPDATE_AGEJobDataMapkey with which to specify alongvalue 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 DirectoryScanJob()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(org.quartz.JobExecutionContext context)protected java.io.File[]getUpdatedOrNewFiles(java.lang.String dirName, long lastDate, long maxAgeDate)
-
-
-
Field Detail
-
DIRECTORY_NAME
public static final java.lang.String DIRECTORY_NAME
JobDataMapkey with which to specify the directory to be monitored - an absolute path is recommended.- See Also:
- Constant Field Values
-
DIRECTORY_SCAN_LISTENER_NAME
public static final java.lang.String DIRECTORY_SCAN_LISTENER_NAME
JobDataMapkey with which to specify theDirectoryScanListenerto be notified when the directory contents change.- See Also:
- Constant Field Values
-
MINIMUM_UPDATE_AGE
public static final java.lang.String MINIMUM_UPDATE_AGE
JobDataMapkey with which to specify alongvalue 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(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException- Specified by:
executein interfaceorg.quartz.Job- Throws:
org.quartz.JobExecutionException- See Also:
Job.execute(org.quartz.JobExecutionContext)
-
getUpdatedOrNewFiles
protected java.io.File[] getUpdatedOrNewFiles(java.lang.String dirName, long lastDate, long maxAgeDate)
-
-