com.groiss.store
Class Lock
java.lang.Object
com.groiss.store.PersistentObject
com.groiss.store.Lock
- All Implemented Interfaces:
- KeyValuePair<java.lang.Object,java.lang.Object>, Persistent, java.io.Serializable, java.lang.Cloneable
public class Lock
- extends PersistentObject
Make a database lock.
- See Also:
- Serialized Form
Constructor Summary |
|
Lock()
|
protected |
Lock(long obj,
java.lang.String lockname)
|
Method Summary |
java.util.Date |
getLockdate()
|
java.lang.String |
getLockname()
|
java.lang.String |
getNodeid()
|
long |
getObj()
|
java.lang.String |
getTableName()
This method must return the table name of the database table in which
this persistent object is stored. |
static boolean |
isLocked(long obj,
java.lang.String lockname)
Returns true if the specified lock exists for the passed object, false otherwise. |
static void |
lock(long obj,
java.lang.String lockname)
Try to make a database lock. |
static void |
unlock(long obj,
java.lang.String lockname)
Remove the lock. |
Methods inherited from class com.groiss.store.PersistentObject |
clone, dbFields, equals, getKey, getOid, getStore, getValue, hashCode, isFilled, onDelete, onInsert, onRead, onUpdate, setFilled, setOid, setStore |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
MAILBOX_LOCKNAME
public static final java.lang.String MAILBOX_LOCKNAME
- See Also:
- Constant Field Values
Lock
public Lock()
Lock
protected Lock(long obj,
java.lang.String lockname)
getLockdate
public java.util.Date getLockdate()
getLockname
public java.lang.String getLockname()
getNodeid
public java.lang.String getNodeid()
getObj
public long getObj()
getTableName
public java.lang.String getTableName()
- Description copied from interface:
Persistent
- This method must return the table name of the database table in which
this persistent object is stored.
- Returns:
- The table name of the database table in which this persistent
object is stored.
lock
public static void lock(long obj,
java.lang.String lockname)
- Try to make a database lock.
- Parameters:
obj
- the oid of an object to locklockname
-
unlock
public static void unlock(long obj,
java.lang.String lockname)
- Remove the lock.
- Parameters:
obj
- the locked objectlockname
- the name of the lock
isLocked
public static boolean isLocked(long obj,
java.lang.String lockname)
throws java.lang.Exception
- Returns true if the specified lock exists for the passed object, false otherwise.
Note: there is some uncertainty in the answer because if another thread did call
lock(long, String)
before you call this method but did not commit already, this method
will return false allthough a subsequent call of lock(long, String)
would cause an Exception.
If you want to lock an object, do not call this method before calling lock(long, String)
but call lock(long, String)
directly which is guaranteed to be not successfull if a lock
already exists.
- Parameters:
obj
- the locked objectlockname
- the name of the lock
- Returns:
true
if the specified lock exists for the given object; else
instead
- Throws:
java.lang.Exception
@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.