org.olat.commons.coordinate.singlevm
Class SingleVMLocker

java.lang.Object
  extended by org.olat.commons.coordinate.singlevm.SingleVMLocker
All Implemented Interfaces:
Locker, GenericEventListener

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

Description:
implementation of the olat system bus within one vm

Initial Date: 19.09.2007

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

Method Summary
 LockResult acquireLock(OLATResourceable ores, Identity identity, 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]
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

init

public void init()
[used by spring]


setEventBus

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

Parameters:
eventBus -

acquireLock

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

releaseLock

public void releaseLock(LockResult lockResult)
releases the lock. can also be called if the lock was not sucessfully acquired

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

isLocked

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

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)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

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
See Also:
PersistentLockManager.releasePersistentLock(org.olat.core.util.coordinate.LockResult)

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.