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 TypeMethodDescriptionboolean
isLockable
(File file) Checks whether the file passed in can be locked by this locker.boolean
Tries to lock the given file and returnstrue
if it was successful,false
otherwise.void
Unlocks the given file.
-
Method Details
-
lock
Tries to lock the given file and returnstrue
if it was successful,false
otherwise.- 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
-