public class Locker extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware
| Constructor and Description |
|---|
Locker() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
boolean |
canLease(String processName)
Returns true if process can be leased.
|
static LockStorage |
createDefaultLockStorage(DataSource ds,
org.springframework.transaction.PlatformTransactionManager transactionManager,
ResourceAccessor resourceAccessor,
org.springframework.core.io.ResourceLoader resourceLoader)
Creates lock persister on specific dataSource and transactionManager.
|
String |
leaseProcess(String processName,
LocalDateTime until)
Method stores lock on particular process.
|
String |
leaseProcess(String processName,
LocalDateTime until,
int waitForLockInMilliseconds)
Method stores lock on particular process.
|
String |
leaseProcess(String processName,
LocalDateTime until,
int waitForLockInMilliseconds,
LockRestorer lockerRestorer)
Method stores lock on particular process and start lock restorer.
|
String |
leaseProcess(String processName,
LocalDateTime until,
LockRestorer lockerRestorer)
Method stores lock on particular process and start lock restorer.
|
void |
releaseProcess(String processName,
String unlockKey)
Release lock you are owner of.
|
void |
renewLease(String processName,
String unlockKey,
LocalDateTime until)
Renews lease date for particular process, if you have correct unlock key (otherwise exeption is thrown)
|
public static LockStorage createDefaultLockStorage(DataSource ds, org.springframework.transaction.PlatformTransactionManager transactionManager, ResourceAccessor resourceAccessor, org.springframework.core.io.ResourceLoader resourceLoader)
ds - data sourcetransactionManager - transaction managerresourceAccessor - implementation for accessing SQL queriesresourceLoader - implementation for loading Spring ResourceLockStorage implementationpublic void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic boolean canLease(String processName)
processName - public String leaseProcess(String processName, LocalDateTime until, int waitForLockInMilliseconds) throws ProcessIsLockedException
processName - name of the process we want to lockuntil - date until lock should be kept providing no one has unlock it by thenProcessIsLockedExceptionpublic String leaseProcess(String processName, LocalDateTime until) throws ProcessIsLockedException
processName - name of the process we want to lockuntil - date until lock should be kept providing no one has unlock it by thenProcessIsLockedExceptionpublic String leaseProcess(String processName, LocalDateTime until, LockRestorer lockerRestorer) throws ProcessIsLockedException
processName - name of the process we want to lockuntil - date until lock should be kept providing no one has unlock it by thenProcessIsLockedException - when lock is already leasedpublic String leaseProcess(String processName, LocalDateTime until, int waitForLockInMilliseconds, LockRestorer lockerRestorer) throws ProcessIsLockedException
processName - name of the process we want to lockuntil - date until lock should be kept providing no one has unlock it by thenProcessIsLockedException - when lock is already leasedpublic void renewLease(String processName, String unlockKey, LocalDateTime until) throws ProcessIsLockedException
processName - name of the process we want to have the lock renewedunlockKey - key obtained during lock leasinguntil - date until lock should be kept providing no one has unlock it by thenProcessIsLockedException - when lock is already leasedpublic void releaseProcess(String processName, String unlockKey) throws ProcessIsLockedException
processName - name of the process we want to have the lock renewedunlockKey - key obtained during lock leasingProcessIsLockedException - when the lock key doesn't match the current lock for the processCopyright © 2020 FG Forrest, a.s.. All rights reserved.