Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql
Class LockManager

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.LockManager

public class LockManager
extends Object

Manager of locks that serializes access to them.

The public methods called by the session are setLock(java.io.Serializable, org.nuxeo.ecm.core.api.Lock), removeLock(java.io.Serializable, java.lang.String) and getLock(java.io.Serializable). Method shutdown() must be called when done with the lock manager.

In cluster mode, changes are executed in a begin/commit so that tests/updates can be atomic.

Transaction management can be done by hand because we're dealing with a low-level Mapper and not something wrapped by a JCA pool.


Constructor Summary
LockManager(Mapper mapper, boolean clusteringEnabled)
          Creates a lock manager using the given mapper.
 
Method Summary
static boolean canLockBeRemoved(Lock lock, String owner)
          Checks if a given lock can be removed by the given owner.
 void clearCaches()
           
 Lock getLock(Serializable id)
          Gets the lock on a document.
 Lock removeLock(Serializable id, String owner)
          Unlocks a document.
 Lock setLock(Serializable id, Lock lock)
          Locks a document.
 void shutdown()
          Shuts down the lock manager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockManager

public LockManager(Mapper mapper,
                   boolean clusteringEnabled)
Creates a lock manager using the given mapper.

The mapper will from then on be only used and closed by the lock manager.

shutdown() must be called when done with the lock manager.

Method Detail

shutdown

public void shutdown()
              throws StorageException
Shuts down the lock manager.

Throws:
StorageException

getLock

public Lock getLock(Serializable id)
             throws StorageException
Gets the lock on a document.

Throws:
StorageException

setLock

public Lock setLock(Serializable id,
                    Lock lock)
             throws StorageException
Locks a document.

Throws:
StorageException

removeLock

public Lock removeLock(Serializable id,
                       String owner)
                throws StorageException
Unlocks a document.

Throws:
StorageException

clearCaches

public void clearCaches()

canLockBeRemoved

public static boolean canLockBeRemoved(Lock lock,
                                       String owner)
Checks if a given lock can be removed by the given owner.

Parameters:
lock - the lock
owner - the owner (may be null)
Returns:
true if the lock can be removed

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.