org.springframework.integration.file
Interface DirectoryScanner

All Known Implementing Classes:
DefaultDirectoryScanner, HeadDirectoryScanner, RecursiveLeafOnlyDirectoryScanner

public interface DirectoryScanner

Strategy for scanning directories. Implementations may select all children and grandchildren of the scanned directory in any order. This interface is intended to enable the customization of selection, locking and ordering of files in a directory like RecursiveDirectoryScanner. If the only requirement is to ignore certain files a EntryListFilter implementation should suffice.


Method Summary
 java.util.List<java.io.File> listFiles(java.io.File directory)
          Scans the directory according to the strategy particular to this implementation and returns the selected files as a File array.
 void setFilter(FileListFilter<java.io.File> filter)
          Sets a custom filter to be used by this scanner.
 void setLocker(FileLocker locker)
          Sets a custom locker to be used by this scanner.
 boolean tryClaim(java.io.File file)
          Claim the file to process.
 

Method Detail

listFiles

java.util.List<java.io.File> listFiles(java.io.File directory)
                                       throws java.lang.IllegalArgumentException
Scans 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.

Parameters:
directory - the directory to scan for files
Returns:
a list of files representing the content of the directory
Throws:
java.lang.IllegalArgumentException - if the input is incorrect

setFilter

void setFilter(FileListFilter<java.io.File> filter)
Sets 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.

Parameters:
filter - the custom filter to be used

setLocker

void setLocker(FileLocker locker)
Sets 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.

Parameters:
locker - the custom locker to be used

tryClaim

boolean tryClaim(java.io.File file)
Claim the file to process. It is up to the implementation to decide what additional safe guards are required to attain a claim to the file. But if a locker is set implementations MUST invoke its lock method and MUST return false if the locker did not grant the lock.

Parameters:
file - file to be claimed
Returns:
true if the claim was granted false otherwise