public class LockService
extends java.lang.Object
Channel and interacts with a locking protocol (e.g. CENTRAL_LOCK) via events.
When no locking protocol is seen on the channel's stack, LockService will throw an exception at startup. An example
of using LockService is:
JChannel ch=new JChannel("/home/bela/locking.xml); // locking.xml needs to have a locking protocol towards the top
LockService lock_service=new LockService(ch);
ch.connect("lock-cluster");
Lock lock=lock_service.getLock("mylock");
lock.lock();
try {
// do something with the lock acquired
}
finally {
lock.unlock();
}
The exact semantics of this lock implemantation are defined in LockService.LockImpl.
Note that, contrary to the semantics of Lock, unlock() can be called multiple
times; after a lock has been released, future calls to unlock() have no effect.| Modifier and Type | Class and Description |
|---|---|
protected class |
LockService.LockImpl
Implementation of
Lock. |
| Modifier and Type | Field and Description |
|---|---|
protected Channel |
ch |
protected Locking |
lock_prot |
| Constructor and Description |
|---|
LockService() |
LockService(Channel ch) |
| Modifier and Type | Method and Description |
|---|---|
void |
addLockListener(LockNotification listener) |
java.util.concurrent.locks.Lock |
getLock(java.lang.String lock_name) |
java.lang.String |
printLocks() |
void |
removeLockListener(LockNotification listener) |
void |
setChannel(Channel ch) |
void |
unlockAll() |
public LockService()
public LockService(Channel ch)
public void setChannel(Channel ch)
public java.util.concurrent.locks.Lock getLock(java.lang.String lock_name)
public void unlockAll()
public void addLockListener(LockNotification listener)
public void removeLockListener(LockNotification listener)
public java.lang.String printLocks()
Copyright © 1998-2020 Red Hat. All Rights Reserved.