Package com.aspectran.core.util
Class FileLocker
- java.lang.Object
-
- com.aspectran.core.util.FileLocker
-
public class FileLocker extends java.lang.ObjectUsed 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
Constructors Constructor Description FileLocker(java.io.File lockFile)Instantiates a new FileLocker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanlock()Try to lock the file and return true if the locking succeeds.voidrelease()Releases the lock.
-
-
-
Method Detail
-
lock
public boolean lock() throws java.lang.ExceptionTry 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:
java.lang.Exception- if the lock could not be obtained for any reason
-
release
public void release() throws java.lang.ExceptionReleases the lock.- Throws:
java.lang.Exception- if the lock could not be released for any reason
-
-