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(java.io.File file)
Checks whether the file passed in can be locked by this locker.
|
boolean |
lock(java.io.File fileToLock)
Tries to lock the given file and returns
true if it was
successful, false otherwise. |
void |
unlock(java.io.File fileToUnlock)
Unlocks the given file.
|
accept
filterFiles
public boolean lock(java.io.File fileToLock)
true
if it was
successful, false
otherwise.fileToLock
- the file that should be locked according to this lockerpublic boolean isLockable(java.io.File file)
FileLocker
public void unlock(java.io.File fileToUnlock)
FileLocker
fileToUnlock
- the file that should be unlocked according to this locker