org.apache.jackrabbit.core.lock
Interface LockManager

All Known Implementing Classes:
LockManagerImpl, XALockManager

public interface LockManager

Defines the functionality needed for locking and unlocking nodes.


Method Summary
 void addLockToken(SessionImpl session, String lt)
          Invoked by a session to inform that a lock token has been added.
 void checkLock(NodeImpl node)
          Check whether the node given is locked by somebody else than the current session.
 void checkLock(Path path, Session session)
          Check whether the path given is locked by somebody else than the session described.
 void checkUnlock(Session session, NodeImpl node)
          Returns true if the specified session is allowed to unlock the node; otherwise returns false.
 Lock getLock(NodeImpl node)
          Returns the Lock object that applies to a node.
 Lock[] getLocks(SessionImpl session)
          Returns all locks owned by the specified session.
 boolean holdsLock(NodeImpl node)
          Returns true if the node given holds a lock; otherwise returns false.
 boolean isLocked(NodeImpl 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
 Lock lock(NodeImpl node, boolean isDeep, boolean isSessionScoped)
          Lock a node.
 Lock lock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timoutHint, String ownerInfo)
          Lock a node.
 void removeLockToken(SessionImpl session, String lt)
          Invoked by a session to inform that a lock token has been removed.
 void unlock(NodeImpl node)
          Removes the lock on a node given by its path.
 

Method Detail

lock

Lock lock(NodeImpl node,
          boolean isDeep,
          boolean isSessionScoped)
          throws LockException,
                 RepositoryException
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.

Parameters:
node - node
isDeep - whether the lock applies to this node only
isSessionScoped - whether the lock is session scoped
Returns:
lock object
Throws:
LockException - if this node already is locked, or some descendant node is locked and isDeep is true
RepositoryException
See Also:
Node.lock(boolean, boolean)

lock

Lock lock(NodeImpl node,
          boolean isDeep,
          boolean isSessionScoped,
          long timoutHint,
          String ownerInfo)
          throws LockException,
                 RepositoryException
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.

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(String, boolean, boolean, long, String)

getLock

Lock getLock(NodeImpl node)
             throws LockException,
                    RepositoryException
Returns the Lock object that applies to a node. This may be either a lock on this node itself or a deep lock on a node above this node.

Parameters:
node - node
Returns:
lock object
Throws:
LockException - if this node is not locked
RepositoryException
See Also:
Node.getLock()

getLocks

Lock[] getLocks(SessionImpl session)
                throws RepositoryException
Returns all locks owned by the specified session.

Parameters:
session - session
Returns:
an array of lock objects
Throws:
RepositoryException - if an error occurs
See Also:
SessionImpl.getLocks()

unlock

void unlock(NodeImpl node)
            throws LockException,
                   RepositoryException
Removes the lock on a node given by its path.

Parameters:
node - node
Throws:
LockException - if this node is not locked or the session does not have the correct lock token
RepositoryException
See Also:
Node.unlock()

holdsLock

boolean holdsLock(NodeImpl node)
                  throws RepositoryException
Returns true if the node given holds a lock; otherwise returns false.

Parameters:
node - node
Returns:
true if the node given holds a lock; otherwise returns false
Throws:
RepositoryException - If an exception occurs.
See Also:
Node.holdsLock()

isLocked

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

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

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.

Parameters:
node - node to check
Throws:
LockException - if write access to the specified node is not allowed
RepositoryException - if some other error occurs

checkLock

void checkLock(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.

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

checkUnlock

void checkUnlock(Session session,
                 NodeImpl node)
                 throws LockException,
                        RepositoryException
Returns true if the specified session is allowed to unlock the node; otherwise returns false.

Parameters:
session - session
node - node
Throws:
LockException - if write access to the specified path is not allowed
RepositoryException - if some other error occurs

addLockToken

void addLockToken(SessionImpl session,
                  String lt)
                  throws LockException,
                         RepositoryException
Invoked by a session to inform that a lock token has been added.

Parameters:
session - session that has a added lock token
lt - added lock token
Throws:
LockException
RepositoryException

removeLockToken

void removeLockToken(SessionImpl session,
                     String lt)
                     throws LockException,
                            RepositoryException
Invoked by a session to inform that a lock token has been removed.

Parameters:
session - session that has a removed lock token
lt - removed lock token
Throws:
LockException
RepositoryException


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.