Class VersionLockManager

  • All Implemented Interfaces:
    LockLevels, LockManager, org.apache.openjpa.lib.util.Closeable

    public class VersionLockManager
    extends AbstractLockManager
    LockManager implementation that provides support for version checking and version updating when locks are acquired. This lock manager may be used standalone or extended for additional locking.
    Author:
    Marc Prud'hommeaux
    • Constructor Detail

      • VersionLockManager

        public VersionLockManager()
    • Method Detail

      • getLockLevel

        public int getLockLevel​(OpenJPAStateManager sm)
        Returns the given instance's lock level, assuming that the state's lock object is a number. If the given instance is embedded, traverses to its owner. Override if lock is not stored as a number.
      • setLockLevel

        protected void setLockLevel​(OpenJPAStateManager sm,
                                    int level)
        Sets the given instance's lock level to the given number. Override to store something else as the lock.
      • refreshLock

        public void refreshLock​(OpenJPAStateManager sm,
                                int level,
                                int timeout,
                                java.lang.Object sdata)
        Description copied from interface: LockManager
        Perform the same function as previous lock method and has the option to perform a version check after the lock function has completed.
      • optimisticLockInternal

        protected void optimisticLockInternal​(OpenJPAStateManager sm,
                                              int level,
                                              int timeout,
                                              java.lang.Object sdata,
                                              boolean postLockVersionCheck)
      • setVersionCheckOnReadLock

        public void setVersionCheckOnReadLock​(boolean versionCheckOnReadLock)
        Whether or not we should force a version check at commit time when a read lock is requested in order to verify read consistency. Defaults to true.
      • getVersionCheckOnReadLock

        public boolean getVersionCheckOnReadLock()
        Whether or not we should force a version check at commit time when a read lock is requested in order to verify read consistency. Defaults to true.
      • setVersionUpdateOnWriteLock

        public void setVersionUpdateOnWriteLock​(boolean versionUpdateOnWriteLock)
        Whether or not we should force an update to the version at commit time when a write lock is requested. Defaults to true.
      • getVersionUpdateOnWriteLock

        public boolean getVersionUpdateOnWriteLock()
        Whether or not we should force an update to the version at commit time when a write lock is requested. Defaults to true.