Class UUIDLock


  • public class UUIDLock
    extends ReentrantLock<UUID>
    This class provides a reentrant read/write-lock based on UUIDs.
    • Constructor Detail

      • UUIDLock

        public UUIDLock​(boolean exclusive,
                        Logger logger)
                 throws NoSuchMethodException,
                        InstantiationException,
                        IllegalAccessException,
                        InvocationTargetException
        Creates a new UUIDLock based on UUID, it uses Object.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, a NouSuchMethodException will be thrown.
        InstantiationException - Should never happen. If the object equality lock count manager cannot be instantiated or does not have a parameterless constructor, an InstantiationException will be thrown.
        IllegalAccessException - Should never happen. If the object equality lock count manager class or its constructor is not accessible, an IllegalAccessException will be thrown.
        InvocationTargetException - If the constructor of the object equality lock count manager throws an exception, this will be wrapped by an InvocationTargetException.
      • UUIDLock

        public UUIDLock​(Class<? extends LockCountManager<UUID>> lockCountManager,
                        boolean exclusive,
                        Logger logger)
                 throws NoSuchMethodException,
                        InstantiationException,
                        IllegalAccessException,
                        InvocationTargetException
        Creates a new UUIDLock using the designated lock count manager and the designated exclusive mode. This constructor is for usage by ObjectLockManager.
        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, a NouSuchMethodException will be thrown.
        InstantiationException - If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, an InstantiationException will be thrown.
        IllegalAccessException - If the designated lock count manager class or its constructor is not accessible, an IllegalAccessException will be thrown.
        InvocationTargetException - If the constructor of the object equality lock count manager throws an exception, this will be wrapped by an InvocationTargetException.
      • UUIDLock

        public UUIDLock​(Class<? extends LockCountManager<UUID>> lockCountManager,
                        boolean exclusive,
                        LockNotification<UUID> notification,
                        Logger logger)
                 throws NoSuchMethodException,
                        InstantiationException,
                        IllegalAccessException,
                        InvocationTargetException
        Creates a new UUIDLock 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 by ObjectLockManager.
        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 is null, 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, a NouSuchMethodException will be thrown.
        InstantiationException - If the designated lock count manager class cannot be instantiated or does not have a parameterless constructor, an InstantiationException will be thrown.
        IllegalAccessException - If the designated lock count manager class or its constructor is not accessible, an IllegalAccessException will be thrown.
        InvocationTargetException - If the constructor of the object equality lock count manager throws an exception, this will be wrapped by an InvocationTargetException.