public class Lock extends PersistentObject
Modifier and Type | Field and Description |
---|---|
static String |
MAILBOX_LOCKNAME |
filled, oid
emptyKeys
Modifier | Constructor and Description |
---|---|
|
Lock() |
protected |
Lock(long obj,
String lockname) |
Modifier and Type | Method and Description |
---|---|
Date |
getLockdate() |
String |
getLockname() |
String |
getNodeid() |
long |
getObj() |
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,
String lockname)
Returns true if the specified lock exists for the passed combination of obj and lockname, false otherwise.
|
static void |
lock(long obj,
String lockname)
Try to make a database lock.
|
static void |
lockForCurrentTransaction(long obj,
String lockname)
Try to make a database lock with a duration of the current transaction.
|
static void |
unlock(long obj,
String lockname)
Remove the lock.
|
afterDelete, afterInsert, afterRead, afterUpdate, beforeDelete, beforeInsert, beforeUpdate, clone, dbFields, equals, getKey, getKeys, getLocalClassName, getLocalObjectName, getOid, getStore, getValue, hashCode, isFilled, isValid, onDelete, onInsert, onRead, onUpdate, setFilled, setOid, setOid, setStore, toListString
public static final String MAILBOX_LOCKNAME
public Lock()
protected Lock(long obj, String lockname)
public Date getLockdate()
public String getLockname()
public String getNodeid()
public long getObj()
public String getTableName()
Persistent
public static void lock(long obj, String lockname)
After successful completion of the method, there is a lock in the database. It is not (yet) externally observable, because the record is private to the current transaction.
Upon commit of the transaction, the lock will remain.
The lock must be removed by calling unlock(long, String)
at some time later.
If the transaction is rolled back, the lock also disappears.
If there is a persisted (committed) lock with the same combination of obj and lockname, the method will throw an ApplicationException(286).
If there is a lock that is still private (uncommitted), the method will block, either until the lock disappears (because of a rollback of the other lock requestor) and the method completes or until the lock is persisted (because of a commit of the lock requestor) and the ApplicationException is thrown.
obj
- the oid of an object to locklockname
- a (descriptive) name for the lockpublic static void lockForCurrentTransaction(long obj, String lockname)
After successful completion of the method, there is a lock which prevents other threads to gain such a lock. It is not (yet) externally observable, because the record is private to the current transaction.
Upon completion of the transaction (commit or rollback), the lock will disappear.
If there is a persisted (committed) lock with the same combination of obj and lockname, the method will throw an ApplicationException(286).
If there is a lock that is still private (uncommitted), the method will block, either until the lock disappears (because of a rollback of the other lock requestor) and the method completes or until the lock is persisted (because of a commit of the lock requestor) and the ApplicationException is thrown.
obj
- the oid of an object to locklockname
- a (descriptive) name for the lockpublic static void unlock(long obj, String lockname)
obj
- the locked objectlockname
- the name of the lockpublic static boolean isLocked(long obj, String lockname)
lock(long, String)
before you call this method but did not commit already, this method
will return false although a subsequent call of lock(long, String)
would cause an Exception.
This implies that isLocked will never return true for locks created via lockForCurrentTransaction(long, String)
.
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 successful if a lock
already exists.
obj
- the locked objectlockname
- the name of the locktrue
if the specified lock exists for the given object; else false
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.