Class XALockManager

  • All Implemented Interfaces:
    LockManager, org.apache.jackrabbit.data.core.InternalXAResource

    public class XALockManager
    extends Object
    implements LockManager, org.apache.jackrabbit.data.core.InternalXAResource
    Session-local lock manager that implements the semantical changes inside transactions. This manager validates lock/unlock operations inside its view of the locking space.
    • Constructor Detail

      • XALockManager

        public XALockManager​(LockManagerImpl lockMgr)
        Create a new instance of this class.
        Parameters:
        lockMgr - lockMgr global lock manager
    • Method Detail

      • lock

        public Lock lock​(NodeImpl node,
                         boolean isDeep,
                         boolean isSessionScoped,
                         long timoutHint,
                         String ownerInfo)
                  throws LockException,
                         RepositoryException
        Description copied from interface: LockManager
        Lock a node. Checks whether the node is not locked and then returns a lock object for this node.
        Specified by:
        lock in interface LockManager
        Parameters:
        node - Node to create the lock for.
        isDeep - whether the lock applies to this node only
        isSessionScoped - whether the lock is session scoped
        timoutHint - Desired lock timeout in seconds.
        ownerInfo - Optional string acting as information about the owner.
        Returns:
        the lock.
        Throws:
        LockException - if this node already is locked, or some descendant node is locked and isDeep is true
        RepositoryException
        See Also:
        LockManager.lock(NodeImpl, boolean, boolean, long, String)
      • isLocked

        public boolean isLocked​(NodeImpl node)
                         throws RepositoryException
        Returns true if this node is locked either as a result of a lock held by this node or by a deep lock on a node above this node; otherwise returns false
        Specified by:
        isLocked in interface LockManager
        Parameters:
        node - node
        Returns:
        true if this node is locked either as a result of a lock held by this node or by a deep lock on a node above this node; otherwise returns false
        Throws:
        RepositoryException - If an exception occurs.
        See Also:
        Node.isLocked()
      • checkLock

        public void checkLock​(NodeImpl node)
                       throws LockException,
                              RepositoryException
        Check whether the node given is locked by somebody else than the current session. Access is allowed if the node is not locked or if the session itself holds the lock to this node, i.e. the session contains the lock token for the lock.
        Specified by:
        checkLock in interface LockManager
        Parameters:
        node - node to check
        Throws:
        LockException - if write access to the specified node is not allowed
        RepositoryException - if some other error occurs
      • checkLock

        public void checkLock​(org.apache.jackrabbit.spi.Path path,
                              Session session)
                       throws LockException,
                              RepositoryException
        Check whether the path given is locked by somebody else than the session described. Access is allowed if the node is not locked or if the session itself holds the lock to this node, i.e. the session contains the lock token for the lock.
        Specified by:
        checkLock in interface LockManager
        Parameters:
        path - path to check
        session - session
        Throws:
        LockException - if write access to the specified path is not allowed
        RepositoryException - if some other error occurs
      • associate

        public void associate​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        associate in interface org.apache.jackrabbit.data.core.InternalXAResource
      • beforeOperation

        public void beforeOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        beforeOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • prepare

        public void prepare​(org.apache.jackrabbit.data.core.TransactionContext tx)
                     throws org.apache.jackrabbit.data.core.TransactionException
        Specified by:
        prepare in interface org.apache.jackrabbit.data.core.InternalXAResource
        Throws:
        org.apache.jackrabbit.data.core.TransactionException
      • commit

        public void commit​(org.apache.jackrabbit.data.core.TransactionContext tx)

        This will finish the update and unlock the shared lock manager.

        Specified by:
        commit in interface org.apache.jackrabbit.data.core.InternalXAResource
      • rollback

        public void rollback​(org.apache.jackrabbit.data.core.TransactionContext tx)

        This will undo all updates and unlock the shared lock manager.

        Specified by:
        rollback in interface org.apache.jackrabbit.data.core.InternalXAResource
      • afterOperation

        public void afterOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        afterOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • differentXAEnv

        public boolean differentXAEnv​(LockInfo info)
        Return a flag indicating whether a lock info belongs to a different XA environment.