Package com.aspectran.core.util
Class FileLocker
- java.lang.Object
-
- com.aspectran.core.util.FileLocker
-
public class FileLocker extends java.lang.Object
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
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 boolean
lock()
Try to lock the file and return true if the locking succeeds.void
release()
Releases the lock.
-
-
-
Method Detail
-
lock
public boolean lock() throws java.lang.Exception
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:
java.lang.Exception
- if the lock could not be obtained for any reason
-
release
public void release() throws java.lang.Exception
Releases the lock.- Throws:
java.lang.Exception
- if the lock could not be released for any reason
-
-