public class LockServiceTemplate extends Object implements LockService
| Constructor and Description |
|---|
LockServiceTemplate(LockPersistenceRepository repository,
Long expiryInterval) |
| Modifier and Type | Method and Description |
|---|---|
Lock |
create(String name)
Acquire a lock by name.
|
Iterable<Lock> |
findAll()
Iterate the existing locks.
|
Lock |
refresh(String name,
String value)
The holder of a lock can refresh it, extending its expiry.
|
void |
release(String name,
String value)
Release a lock before it expires.
|
public LockServiceTemplate(LockPersistenceRepository repository, Long expiryInterval)
public Iterable<Lock> findAll()
LockServicefindAll in interface LockServicepublic Lock create(String name) throws LockExistsException
LockServicecreate in interface LockServicename - the name identifying the lockLockExistsExceptionpublic void release(String name, String value) throws LockNotHeldException
LockServicerelease in interface LockServicename - the name of the lockvalue - the value of the lock (which has to match the value when it was
acquired)LockNotHeldExceptionpublic Lock refresh(String name, String value) throws LockNotHeldException
LockServicerefresh in interface LockServicename - the name of the lockvalue - the value of the lock (which has to match the value when it was
acquired)LockNotHeldException - if the value does not match the current value or if
the lock doesn't exist (e.g. if it expired)Copyright © 2018. All rights reserved.