Class UUIDLock
- java.lang.Object
-
- de.aristaflow.adept2.util.locking.ReentrantLock<UUID>
-
- de.aristaflow.adept2.util.locking.UUIDLock
-
public class UUIDLock extends ReentrantLock<UUID>
This class provides a reentrant read/write-lock based on UUIDs.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
ReentrantLock.Lock, ReentrantLock.ReadLock, ReentrantLock.WriteLock
-
-
Field Summary
-
Fields inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
logger, notification, readLock, writeLock
-
-
Constructor Summary
Constructors Constructor Description UUIDLock(boolean exclusive, Logger logger)
Creates a newUUIDLock
based on UUID, it usesObject.equals(Object)
and supports (non-exclusive) readers and (exclusive) writers.UUIDLock(Class<? extends LockCountManager<UUID>> lockCountManager, boolean exclusive, LockNotification<UUID> notification, Logger logger)
Creates a newUUIDLock
using the designated lock count manager and the designated exclusive mode.UUIDLock(Class<? extends LockCountManager<UUID>> lockCountManager, boolean exclusive, Logger logger)
Creates a newUUIDLock
using the designated lock count manager and the designated exclusive mode.UUIDLock(Logger logger)
Creates a newUUIDLock
based on UUID, it usesObject.equals(Object)
and it is exclusive.
-
Method Summary
-
Methods inherited from class de.aristaflow.adept2.util.locking.ReentrantLock
invalidate, isReadLocked, isWriteLocked, readLock, writeLock
-
-
-
-
Constructor Detail
-
UUIDLock
public UUIDLock(Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
Creates a newUUIDLock
based on UUID, it usesObject.equals(Object)
and it is exclusive.- Parameters:
logger
- The logger for log messages.- Throws:
NoSuchMethodException
- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodException
will be thrown.InstantiationException
- Should never happen. If the object equality lock count manager cannot be instantiated or does not have a parameterless constructor, anInstantiationException
will be thrown.IllegalAccessException
- Should never happen. If the object equality lock count manager class or its constructor is not accessible, anIllegalAccessException
will be thrown.InvocationTargetException
- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException
.
-
UUIDLock
public UUIDLock(boolean exclusive, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
Creates a newUUIDLock
based on UUID, it usesObject.equals(Object)
and supports (non-exclusive) readers and (exclusive) writers.- Parameters:
exclusive
- Whether to create an exclusive lock or a read/write-lock.logger
- The logger for log messages.- Throws:
NoSuchMethodException
- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodException
will be thrown.InstantiationException
- Should never happen. If the object equality lock count manager cannot be instantiated or does not have a parameterless constructor, anInstantiationException
will be thrown.IllegalAccessException
- Should never happen. If the object equality lock count manager class or its constructor is not accessible, anIllegalAccessException
will be thrown.InvocationTargetException
- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException
.
-
UUIDLock
public UUIDLock(Class<? extends LockCountManager<UUID>> lockCountManager, boolean exclusive, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
Creates a newUUIDLock
using the designated lock count manager and the designated exclusive mode. This constructor is for usage byObjectLockManager
.- Parameters:
lockCountManager
- The manager counting locks for UUIDs. The provided class needs an accessible (public) constructor without parameters.exclusive
- Whether to create an exclusive lock or a read/write-lock.logger
- The logger for log messages.- Throws:
NoSuchMethodException
- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodException
will be thrown.InstantiationException
- If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, anInstantiationException
will be thrown.IllegalAccessException
- If the designated lock count manager class or its constructor is not accessible, anIllegalAccessException
will be thrown.InvocationTargetException
- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException
.
-
UUIDLock
public UUIDLock(Class<? extends LockCountManager<UUID>> lockCountManager, boolean exclusive, LockNotification<UUID> notification, Logger logger) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
Creates a newUUIDLock
using the designated lock count manager and the designated exclusive mode. The designated notification will be used for notifying a successful lock or unlock while locking and unlocking, that is, the notification will be atomically with respect to locking/unlocking. This constructor is for usage byObjectLockManager
.- Parameters:
lockCountManager
- The manager counting locks for UUIDs. The provided class needs an accessible (public) constructor without parameters.exclusive
- Whether to create an exclusive lock or a read/write-lock.notification
- The notification to call directly but atomically after locking and unlocking. If this isnull
, no notification will be sent.logger
- The logger for log messages.- Throws:
NoSuchMethodException
- Should never happen. If the object equality lock count manager has no constructor without parameters, aNouSuchMethodException
will be thrown.InstantiationException
- If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, anInstantiationException
will be thrown.IllegalAccessException
- If the designated lock count manager class or its constructor is not accessible, anIllegalAccessException
will be thrown.InvocationTargetException
- If the constructor of the object equality lock count manager throws an exception, this will be wrapped by anInvocationTargetException
.
-
-