Package com.aspectran.utils
Class FileLocker
java.lang.Object
com.aspectran.utils.FileLocker
Used to obtain a lock that can be used to prevent other Aspectran services
that use the same persistent store.
- Since:
- 5.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionFileLocker
(File lockFile) Instantiates a new FileLocker.FileLocker
(String basePath) FileLocker
(String basePath, String filename) -
Method Summary
-
Constructor Details
-
FileLocker
Instantiates a new FileLocker.- Parameters:
lockFile
- the file to lock
-
FileLocker
-
FileLocker
-
-
Method Details
-
lock
Try to lock the file and return true if the locking succeeds.- Returns:
- true if the locking succeeds; false if the lock is already held
- Throws:
Exception
- if the lock could not be obtained for any reason
-
release
Releases the lock.- Throws:
Exception
- if the lock could not be released for any reason
-