Class DefaultDirectoryScanner
java.lang.Object
org.springframework.integration.file.DefaultDirectoryScanner
- All Implemented Interfaces:
DirectoryScanner
- Direct Known Subclasses:
HeadDirectoryScanner,RecursiveDirectoryScanner
public class DefaultDirectoryScanner extends Object implements DirectoryScanner
Default directory scanner and base class for other directory scanners.
Manages the default interrelations between filtering, scanning and locking.
- Since:
- 2.0
- Author:
- Iwein Fuld, Gunnar Hillert, Artem Bilan
-
Constructor Summary
Constructors Constructor Description DefaultDirectoryScanner()Initializefilterwith a default list ofFileListFilters using aCompositeFileListFilter:IgnoreHiddenFileListFilterAcceptOnceFileListFilter. -
Method Summary
Modifier and Type Method Description protected FileListFilter<File>getFilter()protected FileLockergetLocker()protected File[]listEligibleFiles(File directory)Subclasses may refine the listing strategy by overriding this method.List<File>listFiles(File directory)Scans the directory according to the strategy particular to this implementation and returns the selected files as a File array.voidsetFilter(FileListFilter<File> filter)Sets a custom filter to be used by this scanner.voidsetLocker(FileLocker locker)Sets a custom locker to be used by this scanner.booleantryClaim(File file)This class takes the minimal implementation and merely delegates to the locker if set.
-
Constructor Details
-
DefaultDirectoryScanner
public DefaultDirectoryScanner()
-
-
Method Details
-
setFilter
Description copied from interface:DirectoryScannerSets a custom filter to be used by this scanner. The filter will get a chance to reject files before the scanner presents them through its listFiles method. A scanner may use additional filtering that is out of the control of the provided filter.- Specified by:
setFilterin interfaceDirectoryScanner- Parameters:
filter- the custom filter to be used
-
getFilter
-
setLocker
Description copied from interface:DirectoryScannerSets a custom locker to be used by this scanner. The locker will get a chance to lock files and reject claims on files that are already locked.- Specified by:
setLockerin interfaceDirectoryScanner- Parameters:
locker- the custom locker to be used
-
getLocker
-
tryClaim
This class takes the minimal implementation and merely delegates to the locker if set.- Specified by:
tryClaimin interfaceDirectoryScanner- Parameters:
file- the file to try to claim.- Returns:
- true if the claim was granted false otherwise
-
listFiles
Description copied from interface:DirectoryScannerScans the directory according to the strategy particular to this implementation and returns the selected files as a File array. This method may never return files that are rejected by the filter.- Specified by:
listFilesin interfaceDirectoryScanner- Parameters:
directory- the directory to scan for files- Returns:
- a list of files representing the content of the directory
- Throws:
IllegalArgumentException- if the input is incorrect
-
listEligibleFiles
Subclasses may refine the listing strategy by overriding this method. The files returned here are passed onto the filter.- Parameters:
directory- root directory to use for listing- Returns:
- the files this scanner should consider
-