public final class FileLockManager extends Object
FileLockManager is a single point of access to lock files
for reading, writing and removing.
Make sure all concurrent file access is done through locking otherwise the
prevention of concurrent access is bypassed.
Only works with a single JVM since this is a singleton.| Modifier and Type | Method and Description |
|---|---|
static FileLockManager |
getInstance() |
long |
lock(T object)
Lock's the object for any usage through this
LockManager
and returns the 'lock-cookie' to unlock it with. |
void |
unlock(T object,
long lockCookie)
Unlocks the object for usage through this
LockManager. |
public static FileLockManager getInstance()
public final long lock(T object)
LockManager
and returns the 'lock-cookie' to unlock it with.
CAUTION: Always unlock in the finally block to prevent starvation.object - The object to lock.public final void unlock(T object,
long lockCookie)
LockManager.object - The object to unlock.lockCookie - The cookie to unlock it with.SecurityException - on an invalid lock cookie.Copyright © 2016 SDL Group. All rights reserved.