public class NioFileLocker extends AbstractFileLockerFilter
FileReadingMessageSource
s sharing a Locker will not pick up the same files.
This implementation will acquire or create a FileLock
for the given file. Caching locks might be expensive,
so this locking strategy is not recommended for scenarios where many files are accessed in parallel.
Constructor and Description |
---|
NioFileLocker() |
Modifier and Type | Method and Description |
---|---|
boolean |
isLockable(File file)
Checks whether the file passed in can be locked by this locker.
|
boolean |
lock(File fileToLock)
Tries to lock the given file and returns
true if it was
successful, false otherwise. |
void |
unlock(File fileToUnlock)
Unlocks the given file.
|
accept
filterFiles
public boolean lock(File fileToLock)
true
if it was
successful, false
otherwise.fileToLock
- the file that should be locked according to this lockerpublic boolean isLockable(File file)
FileLocker
file
- The file.public void unlock(File fileToUnlock)
FileLocker
fileToUnlock
- the file that should be unlocked according to this locker