@ThreadSafe public abstract class AbstractLockingService<T extends Lock> extends Object implements LockingService
LockingService implementations.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLockingService() |
protected |
AbstractLockingService(long lockTimeoutMillis) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
createLock(String name) |
protected boolean |
doLock(T lock,
String name,
long time,
TimeUnit timeUnit) |
protected void |
doShutdown() |
protected abstract boolean |
releaseLock(T lock) |
boolean |
shutdown()
Shuts down this locking service.
|
boolean |
tryLock(long time,
TimeUnit unit,
String... names)
Attempts to acquire a series of locks, waiting a maximum amount of time to obtain each lock.
|
boolean |
tryLock(String... names)
Attempts to acquire a series of locks using the default lock timeout.
|
boolean |
unlock(String... names)
Unlocks a number of locks.
|
protected boolean |
unlock(String name) |
protected abstract void |
validateLock(T lock) |
protected final Logger logger
protected AbstractLockingService()
protected AbstractLockingService(long lockTimeoutMillis)
public boolean tryLock(String... names) throws InterruptedException
LockingServiceNOTE: Implementors must make sure that either all the locks are obtained, or none. Otherwise possible deadlocks can occur.
tryLock in interface LockingServicenames - the names of the locks to acquiretrue if *all* the locks were successfully acquired, false otherwiseInterruptedException - if this thread is interrupted while waiting to obtain the lockspublic boolean tryLock(long time,
TimeUnit unit,
String... names)
throws InterruptedException
LockingServiceNOTE: Implementors must make sure that either all the locks are obtained, or none. Otherwise possible deadlocks can occur.
tryLock in interface LockingServicetime - an amount of timeunit - a TimeUnit; may not be nullnames - the names of the locks to acquiretrue if *all* the locks were successfully acquired, false otherwiseInterruptedException - if this thread is interrupted while waiting to obtain the lockspublic boolean unlock(String... names)
LockingServiceunlock in interface LockingServicenames - the names of the locks to unlocktrue if all the locks were successfully unlocked and false if at least one lock could not be
released.protected boolean unlock(String name)
public boolean shutdown()
LockingServiceshutdown in interface LockingServicetrue if the service was shutdown successfully or false if the service was already shutdown prior
to this call.protected void doShutdown()
protected boolean doLock(T lock, String name, long time, TimeUnit timeUnit) throws InterruptedException
InterruptedExceptionprotected abstract void validateLock(T lock)
protected abstract boolean releaseLock(T lock)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.