Class SimpleLockable

  • All Implemented Interfaces:
    DFLockable

    public final class SimpleLockable
    extends java.lang.Object
    implements DFLockable
    Lockable with minimal functionality to cover test-cases needs.
    • Constructor Detail

      • SimpleLockable

        public SimpleLockable()
    • Method Detail

      • obtainLock

        public DFLock obtainLock​(java.lang.String reason)
                          throws AlreadyLockedException
        Description copied from interface: DFLockable
        Obtains the lock; fails with AlreadyLockedException if the object is already locked.
        Specified by:
        obtainLock in interface DFLockable
        Parameters:
        reason - The localized string explaining the operation or reason for locking. May be null.
        Returns:
        The lock, if one can be obtained. Never returns null, throws exception instead.
        Throws:
        AlreadyLockedException - if lockable provided another instance of DFLock before and this lock is still active
      • isLocked

        public boolean isLocked()
        Description copied from interface: DFLockable
        Is a valid lock held by someone already?
        Specified by:
        isLocked in interface DFLockable
        Returns:
        true if locked
      • isLockedForever

        public boolean isLockedForever()
        Description copied from interface: DFLockable
        Is this lockable constantly locked? This can be used for lockables which are in readonly mode (e.g. when you log in as a user without appropriate access rights). If this method returns true, it means that DFLockable.isLocked() returns true during whole life time of this object and will never change. Lockable which is "forever locked" will never change this status to unlocked during one session. It also means that you don't need to listen to DFLockable.PROP_LOCKED property on this DFLockable, because it will be never fired.
        Specified by:
        isLockedForever in interface DFLockable
        Returns:
        true if "forever locked"
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener pcl)
        Description copied from interface: DFLockable
        Register to listen to DFLockable.PROP_LOCKED property change.
        Specified by:
        addPropertyChangeListener in interface DFLockable
        Parameters:
        pcl - The PropertyChangeListener to register
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener pcl)
        Description copied from interface: DFLockable
        Unregister to listen to DFLockable.PROP_LOCKED property change.
        Specified by:
        removePropertyChangeListener in interface DFLockable
        Parameters:
        pcl - Th PropertyChangeListener to unregister
      • checkLock

        public void checkLock​(DFLock testedLock)
        Description copied from interface: DFLockable
        Checks whether the lock belongs to this lockable.
        Specified by:
        checkLock in interface DFLockable
        Parameters:
        testedLock - The lock to check