org.olat.commons.coordinate.cluster.lock
Class ClusterLocker

java.lang.Object
  extended by org.olat.commons.coordinate.cluster.lock.ClusterLocker
All Implemented Interfaces:
Locker, GenericEventListener

public class ClusterLocker
extends java.lang.Object
implements Locker, GenericEventListener

Description:
the cluster implementation for the Locker. It uses a database table oc_lock to perform the locking.

Initial Date: 21.09.2007

Author:
Felix Jost, http://www.goodsolutions.ch

Constructor Summary
ClusterLocker()
          [used by spring]
 
Method Summary
 LockResult acquireLock(OLATResourceable ores, Identity requestor, java.lang.String locksubkey)
           
 java.util.List<LockEntry> adminOnlyGetLockEntries()
          for admin purposes only.
 LockResult aquirePersistentLock(OLATResourceable ores, Identity ident, java.lang.String locksubkey)
          acquires a persistent lock.
 void event(Event event)
          receives all sign on / sign off events so it can release locks of users which have or are logged off
 void init()
          [used by spring]
 boolean isLocked(OLATResourceable ores, java.lang.String locksubkey)
           
 void releaseLock(LockResult lockResult)
          releases the lock.
 void releasePersistentLock(LockResult lockResult)
          releases a persistent lock.
 void setEventBus(EventBus eventBus)
          [used by spring]
 void setSyncer(Syncer syncer)
          [used by spring]
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterLocker

public ClusterLocker()
[used by spring]

Method Detail

init

public void init()
[used by spring]


acquireLock

public LockResult acquireLock(OLATResourceable ores,
                              Identity requestor,
                              java.lang.String locksubkey)
Specified by:
acquireLock in interface Locker
Parameters:
ores - the OLATResourceable to lock upon, e.g a repositoryentry or such
requestor - the identity who tries to acquire the lock, not null
locksubkey - null or any string to lock finer upon the resource (e.g. "authors", or "write", ...)
Returns:
lock result

event

public void event(Event event)
receives all sign on / sign off events so it can release locks of users which have or are logged off

Specified by:
event in interface GenericEventListener
See Also:
GenericEventListener.event(org.olat.core.gui.control.Event)

isLocked

public boolean isLocked(OLATResourceable ores,
                        java.lang.String locksubkey)
Specified by:
isLocked in interface Locker
Returns:
if the olatresourceable with the subkey is already locked by someone (returns true even if locked by "myself")

releaseLock

public void releaseLock(LockResult lockResult)
Description copied from interface: Locker
releases the lock. can also be called if the lock was not sucessfully acquired

Specified by:
releaseLock in interface Locker
Parameters:
lockResult - the LockResult received when locking

adminOnlyGetLockEntries

public java.util.List<LockEntry> adminOnlyGetLockEntries()
Description copied from interface: Locker
for admin purposes only.

Specified by:
adminOnlyGetLockEntries in interface Locker
Returns:
a list of lockentries.

aquirePersistentLock

public LockResult aquirePersistentLock(OLATResourceable ores,
                                       Identity ident,
                                       java.lang.String locksubkey)
Description copied from interface: Locker
acquires a persistent lock.

Specified by:
aquirePersistentLock in interface Locker
locksubkey - may not be longer than 30 chars
Returns:
the LockResult of this lock trial.

releasePersistentLock

public void releasePersistentLock(LockResult lockResult)
Description copied from interface: Locker
releases a persistent lock.

Specified by:
releasePersistentLock in interface Locker
Parameters:
lockResult - the LockResult which stems from the lock acquired previously

setSyncer

public void setSyncer(Syncer syncer)
[used by spring]

Parameters:
syncer -

setEventBus

public void setEventBus(EventBus eventBus)
[used by spring]