uk.ac.ebi.intenz.webapp.utilities
Class EntryLockSingleton

java.lang.Object
  extended by uk.ac.ebi.intenz.webapp.utilities.EntryLockSingleton

public class EntryLockSingleton
extends Object

This class is responsible for locking entries in process.

This will be guaranteed by a synchronized Hashtable which stores the enzyme id of the entry and the users name. If a user locks an entry but quits the application without finishing its modifications, the ModificationBindingListener will take care of releasing the lock.

Version:
$Revision: 1.2 $ $Date: 2008/01/28 12:33:09 $
Author:
Michael Darsow

Constructor Summary
protected EntryLockSingleton()
          Initialises the Hashtable for storing enzyme ids of currently modified entries.
 
Method Summary
static EntryLockSingleton getInstance()
          Returns the EntryLockSingleton instance.
 void invalidateLocks(String user)
          Removes all locks of entries modified by one and the same user.
 void releaseLock(String enzymeId)
          Removes a lock from an entry.
 boolean setLock(String enzymeId, String user)
          Sets a lock for an entry in process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntryLockSingleton

protected EntryLockSingleton()
Initialises the Hashtable for storing enzyme ids of currently modified entries.

Method Detail

getInstance

public static EntryLockSingleton getInstance()
Returns the EntryLockSingleton instance.

Returns:
the one and only EntryLockSingleton instance.

setLock

public boolean setLock(String enzymeId,
                       String user)
Sets a lock for an entry in process.

This method is synchronized to ensure, that only one user at the time can set a lock, hence only one user is able to modify one and the same entry.

Parameters:
enzymeId - The enzyme id of the entry to be modified.
user - The user who is modifying the entry.
Returns:
true, if no-one else is modifying the entry.

releaseLock

public void releaseLock(String enzymeId)
Removes a lock from an entry.

Parameters:
enzymeId - The enzyme id of the entry to be released.

invalidateLocks

public void invalidateLocks(String user)
Removes all locks of entries modified by one and the same user.

This (and the EntryLockListener) ensures that even if the user does not finish a modification and closes the browser, that all locked entries will be released.

Parameters:
user - The user name.


Copyright © 2013 EMBL-EBI. All Rights Reserved.