public class LockManagerUtils extends Object
Constructor and Description |
---|
LockManagerUtils() |
Modifier and Type | Method and Description |
---|---|
static LockResource |
waitForLock(LockManager lockManager,
String key,
long waitInterval)
Utility method to create and if needed wait indefinitely (unless interrupted) for a
LockManager.lock(String) . |
static LockResource |
waitForLock(LockManager lockManager,
String key,
long waitInterval,
long maxWait)
Utility method to create and if needed wait for a maximum amount of time (unless interrupted) for a
LockManager.lock(String) * |
public static LockResource waitForLock(LockManager lockManager, String key, long waitInterval) throws LockException, InterruptedException
Utility method to create and if needed wait indefinitely (unless interrupted) for a LockManager.lock(String)
.
Make sure that after obtaining the cluster-wide lock, that in you are doing JCR node invocations, you first invoke
to make sure the latest global JCR cluster changes are retrieved locally.
session.refresh(true|false)
lockManager
- lockManagerkey
- the key for the Lock
where key
is now allowed to exceed 256 charswaitInterval
- time in milliseconds to wait before retrying creating the lockLockResource
such that this ##waitForLock(LockManager, String, long)
method can be used
in a try-with-resources statement where the LockResource.close()
results in the lock being freed.LockException
- if the lock could not be created (other then AlreadyLockedException
)InterruptedException
- when the thread is interrupted while waiting before retrying to create the lockpublic static LockResource waitForLock(LockManager lockManager, String key, long waitInterval, long maxWait) throws LockException, TimeoutException, InterruptedException
Utility method to create and if needed wait for a maximum amount of time (unless interrupted) for a LockManager.lock(String)
*
Make sure that after obtaining the cluster-wide lock, that in you are doing JCR node invocations, you first invoke
to make sure the latest global JCR cluster changes are retrieved locally.
session.refresh(true|false)
lockManager
- lockManagerkey
- the key for the Lock
where key
is now allowed to exceed 256 charswaitInterval
- time in milliseconds to wait before retrying creating the lockmaxWait
- maximum time in milliseconds for trying to create the lock, will throw TimeoutException when exceeded.LockResource
such that this ##waitForLock(LockManager, String, long)
method can be used
in a try-with-resources statement where the LockResource.close()
results in the lock being freed.LockException
- if the lock could not be created (other then AlreadyLockedException
)TimeoutException
- when the maxWait time has exceeded while trying to create the lockInterruptedException
- when the thread is interrupted while waiting before retrying to create the lockCopyright © 2012–2019 Hippo B.V. (http://www.onehippo.com). All rights reserved.