|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface LockTracker
This class tracks locks on objects. Any persistable object can be locked, just like
with the synchronized keyword in Java, and it does roughly the same thing
too. If an object is locked, no database operations can occur outside of the lock owner
transaction. All Store operations automatically try to lock the objects
they work with, so there can't be any concurrent modifications.
You can also lock classes or interfaces. These equal to locking database tables, only they are
hierarchical. That means, if you lock a class, all subclasses will also be locked
automatically. For example, if you lock Object.class successfully, then
only the owner of that lock will be able to modify anything. Of course, a class can't be
locked, if there is another thread which holds lock on any super-, or sub-classes, or
any instances of this class, or any subclass.
There are two flavors of locks: read-only locks and read-write locks. In short, read-only
locks prevent read-write locks to be established (and with it prevent
save() and remove() calls). While read-write locks prevent both
other read-write locks and read-only locks too. Note, that using the find()
methods is prevented with none of the locks, since the finders always work correctly,
representing a consistent state at the moment when the find() is executed.
| Method Summary | |
|---|---|
SessionInfoProvider |
getProvider()
Get the session provider of locks. |
void |
lock(java.lang.Object obj)
Lock a single object. |
void |
lock(java.lang.Object[] objs)
Lock multiple objects. |
void |
lock(java.lang.Object[] objs,
int wait)
Lock multiple objects. |
void |
lock(java.lang.Object[] objs,
SessionInfo info,
int wait,
boolean ensureCurrent,
boolean readOnly)
Lock multiple objects with all possible parameters specified. |
void |
lock(java.lang.Object obj,
int wait)
Lock a single object with wait period given. |
void |
lock(java.lang.Object obj,
SessionInfo info)
Lock a single object with the session information given. |
void |
lockEnsureCurrent(java.lang.Object obj)
Lock a single object, and ensure that the object given is the most recent version of the object. |
void |
lockEnsureCurrent(java.lang.Object[] objs)
Lock multiple objects, and check whether given objects are current. |
void |
lockEnsureCurrent(java.lang.Object[] objs,
int wait)
Lock multiple objects, and check whether given objects are current. |
void |
lockEnsureCurrent(java.lang.Object obj,
int wait)
Lock a single object, and guarantee it's current. |
void |
lockEnsureCurrent(java.lang.Object obj,
SessionInfo info)
Lock a single object with the session information given, and check is the given object is the current version. |
void |
lockReadOnly(java.lang.Object obj)
Lock a single object read-only. |
void |
lockReadOnly(java.lang.Object[] objs)
Lock multiple objects read-only. |
void |
lockReadOnly(java.lang.Object[] objs,
int wait)
Lock multiple objects read-only. |
void |
lockReadOnly(java.lang.Object obj,
int wait)
Lock a single object read-only with wait period given. |
void |
lockReadOnly(java.lang.Object obj,
SessionInfo info)
Lock a single object read-only with the session information given. |
void |
lockReadOnlyEnsureCurrent(java.lang.Object obj)
Lock a single object read-only, and ensure that the object given is the most recent version of the object. |
void |
lockReadOnlyEnsureCurrent(java.lang.Object[] objs)
Lock multiple objects read-only, and check whether given objects are current. |
void |
lockReadOnlyEnsureCurrent(java.lang.Object[] objs,
int wait)
Lock multiple objects read-only, and check whether given objects are current. |
void |
lockReadOnlyEnsureCurrent(java.lang.Object obj,
int wait)
Lock a single object read-only, and guarantee it's current. |
void |
lockReadOnlyEnsureCurrent(java.lang.Object obj,
SessionInfo info)
Lock a single object read-only with the session information given, and check is the given object is the current version. |
void |
setProvider(SessionInfoProvider provider)
Set the session info provider implementation. |
void |
unlock(java.lang.Object obj)
Unlock a single object. |
void |
unlock(java.lang.Object[] objs)
Unlock multiple objects. |
| Method Detail |
|---|
SessionInfoProvider getProvider()
void setProvider(SessionInfoProvider provider)
void lockEnsureCurrent(java.lang.Object obj)
ConcurrentModificationException - If the object is already
locked by another thread.void lock(java.lang.Object obj)
ConcurrentModificationException - If the object is already
locked by another thread.
void lockEnsureCurrent(java.lang.Object obj,
int wait)
obj - The object to lock.wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lock(java.lang.Object obj,
int wait)
obj - The object to lock.wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lockEnsureCurrent(java.lang.Object obj,
SessionInfo info)
ConcurrentModificationException - If the object is already
locked by another thread.
void lock(java.lang.Object obj,
SessionInfo info)
ConcurrentModificationException - If the object is already
locked by another thread.void lockEnsureCurrent(java.lang.Object[] objs)
ConcurrentModificationException - If the object is already
locked by another thread.void lock(java.lang.Object[] objs)
ConcurrentModificationException - If the object is already
locked by another thread.
void lockEnsureCurrent(java.lang.Object[] objs,
int wait)
wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lock(java.lang.Object[] objs,
int wait)
wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.void lockReadOnlyEnsureCurrent(java.lang.Object obj)
ConcurrentModificationException - If the object is already
locked by another thread.void lockReadOnly(java.lang.Object obj)
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnlyEnsureCurrent(java.lang.Object obj,
int wait)
obj - The object to lock.wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnly(java.lang.Object obj,
int wait)
obj - The object to lock.wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnlyEnsureCurrent(java.lang.Object obj,
SessionInfo info)
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnly(java.lang.Object obj,
SessionInfo info)
ConcurrentModificationException - If the object is already
locked by another thread.void lockReadOnlyEnsureCurrent(java.lang.Object[] objs)
ConcurrentModificationException - If the object is already
locked by another thread.void lockReadOnly(java.lang.Object[] objs)
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnlyEnsureCurrent(java.lang.Object[] objs,
int wait)
wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lockReadOnly(java.lang.Object[] objs,
int wait)
wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.
ConcurrentModificationException - If the object is already
locked by another thread.
void lock(java.lang.Object[] objs,
SessionInfo info,
int wait,
boolean ensureCurrent,
boolean readOnly)
objs - The objects to lock simultaniously.info - The session info to memorize for this lock. This object will
be included in the ConcurrentModificationException.wait - Wait the given amount of milliseconds for the lock to
free up. Method only throws ConcurrentModificationException if
the lock is not available in the given time.ensureCurrent - Do the objects need to be guaranteed to be current.
If this flag is set, the lock operation will fail, if any supplied
object has a newer version.readOnly - Whether the lock should be read-only. If a lock is read-only, then
other read-only locks can still be established on the specified objects, read-write
locks will however fail.
ConcurrentModificationException - If the object is already
locked by another process.void unlock(java.lang.Object obj)
void unlock(java.lang.Object[] objs)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||