org.apache.jackrabbit.jcr2spi.lock
Class LockManagerImpl

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

public class LockManagerImpl
extends Object
implements LockStateManager, 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)
           
 
Method Summary
 void addLockToken(String lt)
          Delegates this call to WorkspaceManager.addLockToken(String).
 void checkLock(NodeState nodeState)
          Check whether the given node state is locked by somebody else than the current session.
 Lock getLock(NodeState nodeState)
          If the session created a lock on the node with the given state, we already know the lock.
 String[] getLockTokens()
          Returns the lock tokens present on the SessionInfo this manager has been created with.
 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.
 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.
 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.
 
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)
Method Detail

lock

public Lock lock(NodeState nodeState,
                 boolean isDeep,
                 boolean isSessionScoped)
          throws LockException,
                 RepositoryException
Description copied from interface: LockStateManager
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.

Specified by:
lock in interface LockStateManager
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:
LockStateManager.lock(NodeState,boolean,boolean)

lock

public Lock lock(NodeState nodeState,
                 boolean isDeep,
                 boolean isSessionScoped,
                 long timeoutHint,
                 String ownerHint)
          throws RepositoryException
Description copied from interface: LockStateManager
Lock a node. Checks whether the node is not locked and then returns a lock object for this node.

Specified by:
lock in interface LockStateManager
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:
LockStateManager.lock(NodeState,boolean,boolean,long,String)

unlock

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

Specified by:
unlock in interface LockStateManager
Throws:
LockException - if this node is not locked or the session does not have the correct lock token
RepositoryException
See Also:
LockStateManager.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.

Specified by:
getLock in interface LockStateManager
Parameters:
nodeState -
Returns:
lock object
Throws:
LockException - if this node is not locked
RepositoryException
See Also:
LockStateManager.getLock(NodeState)

isLocked

public boolean isLocked(NodeState nodeState)
                 throws RepositoryException
Description copied from interface: LockStateManager
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 LockStateManager
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:
LockStateManager.isLocked(NodeState)

checkLock

public void checkLock(NodeState nodeState)
               throws LockException,
                      RepositoryException
Description copied from interface: LockStateManager
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.

Specified by:
checkLock in interface LockStateManager
Throws:
LockException - if write access to the specified node is not allowed
RepositoryException - if some other error occurs
See Also:
LockStateManager.checkLock(NodeState)

getLockTokens

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

Specified by:
getLockTokens in interface LockStateManager
Returns:
The lock tokens associated with the Session this lock manager has been created for.
Throws:
UnsupportedRepositoryOperationException
RepositoryException
See Also:
LockStateManager.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 LockStateManager
Parameters:
lt - added lock token
Throws:
LockException
RepositoryException
See Also:
LockStateManager.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 LockStateManager
Parameters:
lt - removed lock token
Throws:
LockException
RepositoryException
See Also:
LockStateManager.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 - the Session that is about to be 'closed'
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 - the Session that has been 'closed'
See Also:
SessionListener.loggedOut(Session)


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