| java.lang.Object hu.netmind.persistence.LockTracker
LockTracker | public class LockTracker (Code) | | 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
an instances of this class, or any subclass.
author: Brautigam Robert version: Revision: $Revision$ |
Method Summary | |
public SessionInfoProvider | getProvider() | public void | lock(Object obj) Lock a single object. | public void | lock(Object obj, int wait) Lock a single object with wait period given. | public void | lock(Object obj, SessionInfo info) Lock a single object with the session information given. | public void | lock(Object[] objs) Lock multiple objects. | public void | lock(Object[] objs, int wait) Lock multiple objects. | public synchronized void | lock(Object[] objs, SessionInfo info, int wait, boolean ensureCurrent) Lock multiple objects with all possible parameters specified.
Use this method, if you want to lock multiple objects at the same time.
If classes are asked to be ensured to be current, the following date is
taken into account:
- If the lock is called from inside a transaction, the
transaction's first operation's date is taken.
- If there are regular objects with this lock call, then
the oldest object's read date is taken.
Whichever was earlier, the classes are checked against that date.
Parameters: objs - The object to lock simultaniously. Parameters: info - The session info to memorize for this lock. | public void | lockEnsureCurrent(Object obj) Lock a single object, and ensure that the object given is the
most recent version of the object. | public void | lockEnsureCurrent(Object obj, int wait) Lock a single object, and guarantee it's current. | public void | lockEnsureCurrent(Object obj, SessionInfo info) Lock a single object with the session information given,
and check is the given object is the current version. | public void | lockEnsureCurrent(Object[] objs) Lock multiple objects, and check whether given objects
are current. | public void | lockEnsureCurrent(Object[] objs, int wait) Lock multiple objects, and check whether given objects
are current. | public void | setProvider(SessionInfoProvider provider) | public void | unlock(Object obj) Unlock a single object. | public synchronized void | unlock(Object[] objs) Unlock multiple objects. |
lock | public void lock(Object obj)(Code) | | Lock a single object. The session information is gathered
from the session info provider.
throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lock | public void lock(Object obj, int wait)(Code) | | Lock a single object with wait period given. The session information is gathered
from the session info provider.
Parameters: obj - The object to lock. Parameters: wait - Wait the given amount of milliseconds for the lock tofree up. Method only throws ConcurrentModificationException ifthe lock is not available in the given time. throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lock | public void lock(Object[] objs)(Code) | | Lock multiple objects. The session information is gathered
from the session info provider. Use this method, if you want
to lock multiple objects at the same time.
throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lock | public void lock(Object[] objs, int wait)(Code) | | Lock multiple objects. The session information is gathered
from the session info provider. Use this method, if you want
to lock multiple objects at the same time.
Parameters: wait - Wait the given amount of milliseconds for the lock tofree up. Method only throws ConcurrentModificationException ifthe lock is not available in the given time. throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lock | public synchronized void lock(Object[] objs, SessionInfo info, int wait, boolean ensureCurrent)(Code) | | Lock multiple objects with all possible parameters specified.
Use this method, if you want to lock multiple objects at the same time.
If classes are asked to be ensured to be current, the following date is
taken into account:
- If the lock is called from inside a transaction, the
transaction's first operation's date is taken.
- If there are regular objects with this lock call, then
the oldest object's read date is taken.
Whichever was earlier, the classes are checked against that date.
Parameters: objs - The object to lock simultaniously. Parameters: info - The session info to memorize for this lock. This object willbe included in the ConcurrentModificationException. Parameters: wait - Wait the given amount of milliseconds for the lock tofree up. Method only throws ConcurrentModificationException ifthe lock is not available in the given time. Parameters: ensureCurrent - Do the objects need to be guaranteed to be current.If this flag is set, the lock operation will fail, if any suppliedobject has a newer version. throws: ConcurrentModificationException - If the object is alreadylocked by another process. |
lockEnsureCurrent | public void lockEnsureCurrent(Object obj)(Code) | | Lock a single object, and ensure that the object given is the
most recent version of the object. The session information is gathered
from the session info provider.
throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lockEnsureCurrent | public void lockEnsureCurrent(Object obj, int wait)(Code) | | Lock a single object, and guarantee it's current.
The session information is gathered from the session info provider.
Parameters: obj - The object to lock. Parameters: wait - Wait the given amount of milliseconds for the lock tofree up. Method only throws ConcurrentModificationException ifthe lock is not available in the given time. throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lockEnsureCurrent | public void lockEnsureCurrent(Object obj, SessionInfo info)(Code) | | Lock a single object with the session information given,
and check is the given object is the current version.
throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lockEnsureCurrent | public void lockEnsureCurrent(Object[] objs)(Code) | | Lock multiple objects, and check whether given objects
are current. The session information is gathered
from the session info provider. Use this method, if you want
to lock multiple objects at the same time.
throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
lockEnsureCurrent | public void lockEnsureCurrent(Object[] objs, int wait)(Code) | | Lock multiple objects, and check whether given objects
are current. The session information is gathered
from the session info provider. Use this method, if you want
to lock multiple objects at the same time.
Parameters: wait - Wait the given amount of milliseconds for the lock tofree up. Method only throws ConcurrentModificationException ifthe lock is not available in the given time. throws: ConcurrentModificationException - If the object is alreadylocked by another thread. |
unlock | public void unlock(Object obj)(Code) | | Unlock a single object. If the object is not locked, nothing is done.
|
unlock | public synchronized void unlock(Object[] objs)(Code) | | Unlock multiple objects.
|
|
|