Interface FileLocker
- All Known Implementing Classes:
AbstractFileLockerFilter,NioFileLocker
public interface FileLocker
A FileLocker is a strategy that can ensure that files are only processed a
single time. Implementations are free to implement any relation between
locking and unlocking. This means that there are no safety guarantees in the
contract, defining these guarantees is up to the implementation.
If a filter that respects locks is required extend
AbstractFileLockerFilter instead.- Since:
- 2.0
- Author:
- Iwein Fuld
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisLockable(File file) Checks whether the file passed in can be locked by this locker.booleanTries to lock the given file and returnstrueif it was successful,falseotherwise.voidUnlocks the given file.
-
Method Details
-
lock
Tries to lock the given file and returnstrueif it was successful,falseotherwise.- Parameters:
fileToLock- the file that should be locked according to this locker- Returns:
- true if successful.
-
isLockable
Checks whether the file passed in can be locked by this locker. This method never changes the locked state.- Parameters:
file- The file.- Returns:
- true if the file was locked by another locker than this locker
-
unlock
Unlocks the given file.- Parameters:
fileToUnlock- the file that should be unlocked according to this locker
-