org.apache.jackrabbit.jcr2spi.lock
Class LockManagerImpl

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl
All Implemented Interfaces:
LockManager, SessionListener

public class LockManagerImpl
extends Object
implements LockManager, LockManager, SessionListener

LockManagerImpl... TODO: TOBEFIXED. Lock objects obtained through this mgr are not informed if another session is or becomes lock-holder and removes the lock again.


Constructor Summary
LockManagerImpl(WorkspaceManager wspManager, ItemManager itemManager, CacheBehaviour cacheBehaviour, PathResolver pathResolver)
           
 
Method Summary
 void addLockToken(String lt)
          Delegates this call to WorkspaceManager.addLockToken(String).
 Lock getLock(NodeState nodeState)
          If the session created a lock on the node with the given state, we already know the lock.
 Lock getLock(String absPath)
           
 String[] getLockTokens()
          Returns the lock tokens present on the SessionInfo this manager has been created with.
 boolean holdsLock(String absPath)
           
 void checkLock(NodeState nodeState)
          Check whether the given node state is locked by somebody else than the current session.
 boolean isLocked(NodeState nodeState)
          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.
 boolean isLocked(String absPath)
           
 Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped)
          Lock a node.
 Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint)
          Lock a node.
 Lock lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
           
 void loggedOut(Session session)
          Called when a Session has been 'closed' by calling Session.logout()
 void loggingOut(Session session)
          Called when a Session is about to be 'closed' by calling Session.logout()
 void removeLockToken(String lt)
          If the lock addressed by the token is session-scoped, this method will throw a LockException, such as defined by JSR170 v.1.0.1 for Session.removeLockToken(String).
 void unlock(NodeState nodeState)
          Removes the lock on a node.
 void unlock(String absPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockManagerImpl

public LockManagerImpl(WorkspaceManager wspManager,
                       ItemManager itemManager,
                       CacheBehaviour cacheBehaviour,
                       PathResolver pathResolver)
Method Detail

getLock

public Lock getLock(String absPath)
             throws LockException,
                    RepositoryException
Specified by:
getLock in interface LockManager
Throws:
LockException
RepositoryException
See Also:
LockManager.getLock(String)

isLocked

public boolean isLocked(String absPath)
                 throws RepositoryException
Specified by:
isLocked in interface LockManager
Throws:
RepositoryException
See Also:
LockManager.isLocked(String)

holdsLock

public boolean holdsLock(String absPath)
                  throws RepositoryException
Specified by:
holdsLock in interface LockManager
Throws:
RepositoryException
See Also:
LockManager.holdsLock(String)

lock

public Lock lock(String absPath,
                 boolean isDeep,
                 boolean isSessionScoped,
                 long timeoutHint,
                 String ownerInfo)
          throws RepositoryException
Specified by:
lock in interface LockManager
Throws:
RepositoryException
See Also:
LockManager.lock(String, boolean, boolean, long, String)

unlock

public void unlock(String absPath)
            throws LockException,
                   RepositoryException
Specified by:
unlock in interface LockManager
Throws:
LockException
RepositoryException
See Also:
LockManager.unlock(String)

lock

public Lock lock(NodeState nodeState,
                 boolean isDeep,
                 boolean isSessionScoped)
          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.

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:
LockManager.lock(NodeState,boolean,boolean)

lock

public Lock lock(NodeState nodeState,
                 boolean isDeep,
                 boolean isSessionScoped,
                 long timeoutHint,
                 String ownerHint)
          throws 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.

isDeep - whether the lock applies to this node only
isSessionScoped - whether the lock is session scoped
timeoutHint - optional timeout hint.
ownerHint - optional String defining the lock owner info to be displayed.
Returns:
lock object
Throws:
LockException - if this node already is locked, or some descendant node is locked and isDeep is true
RepositoryException
See Also:
LockManager.lock(NodeState,boolean,boolean,long,String)

unlock

public void unlock(NodeState nodeState)
            throws LockException,
                   RepositoryException
Description copied from interface: LockManager
Removes the lock on a node.

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

getLock

public Lock getLock(NodeState nodeState)
             throws LockException,
                    RepositoryException
If the session created a lock on the node with the given state, we already know the lock. Otherwise, the node state and its ancestores are searched for properties indicating a lock.
Note, that the flag indicating session-scoped lock cannot be retrieved unless the current session is the lock holder.

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

isLocked

public boolean isLocked(NodeState nodeState)
                 throws RepositoryException
Description copied from interface: LockManager
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:
nodeState -
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 error occurs.
See Also:
LockManager.isLocked(NodeState)

checkLock

public void checkLock(NodeState nodeState)
               throws LockException,
                      RepositoryException
Description copied from interface: LockManager
Check whether the given node state 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. If the node is not locked at all this method returns silently.

Parameters:
nodeState -
Throws:
LockException - if write access to the specified node is not allowed
RepositoryException - if some other error occurs
See Also:
LockManager.checkLock(NodeState)

getLockTokens

public String[] getLockTokens()
Returns the lock tokens present on the SessionInfo this manager has been created with.

Specified by:
getLockTokens in interface LockManager
Returns:
The lock tokens associated with the Session this lock manager has been created for.
See Also:
LockManager.getLockTokens()

addLockToken

public void addLockToken(String lt)
                  throws LockException,
                         RepositoryException
Delegates this call to WorkspaceManager.addLockToken(String). If this succeeds this method will inform all locks stored in the local map in order to give them the chance to update their lock information.

Specified by:
addLockToken in interface LockManager
Parameters:
lt - added lock token
Throws:
LockException
RepositoryException
See Also:
LockManager.addLockToken(String)

removeLockToken

public void removeLockToken(String lt)
                     throws LockException,
                            RepositoryException
If the lock addressed by the token is session-scoped, this method will throw a LockException, such as defined by JSR170 v.1.0.1 for Session.removeLockToken(String).
Otherwise the call is delegated to WorkspaceManager.removeLockToken(String). All locks stored in the local lock map are notified by the removed token in order have them updated their lock information.

Specified by:
removeLockToken in interface LockManager
Parameters:
lt - removed lock token
Throws:
LockException
RepositoryException
See Also:
LockManager.removeLockToken(String)

loggingOut

public void loggingOut(Session session)
Description copied from interface: SessionListener
Called when a Session is about to be 'closed' by calling Session.logout()
Specified by:
loggingOut in interface SessionListener
Parameters:
session -
See Also:
SessionListener.loggingOut(Session)

loggedOut

public void loggedOut(Session session)
Description copied from interface: SessionListener
Called when a Session has been 'closed' by calling Session.logout()
Specified by:
loggedOut in interface SessionListener
Parameters:
session -
See Also:
SessionListener.loggedOut(Session)


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