1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.fulcrum.yaafi.framework.locking;
21
22 /**
23 *
24 * A multi level lock. Depending on the implementation more than one owner may own a certain lock level on the same lock.
25 *
26 * @version $Revision: 1.2 $
27 */
28 public interface MultiLevelLock {
29
30 /**
31 * Tries to acquire a certain lock level on this lock.
32 *
33 * @param ownerId a unique id identifying the entity that wants to acquire a certain lock level on this lock
34 * @param targetLockLevel the lock level to acquire
35 * @param wait <code>true</code> if this method shall block when the desired lock level can not be acquired
36 * @param reentrant <code>true</code> if lock levels of the same entity acquired earlier
37 * should not restrict compatibility with the lock level desired now
38 * @param timeoutMSecs if blocking is enabled by the <code>wait</code> parameter this specifies the maximum wait time in milliseconds
39 * @return <code>true</code> if the lock actually was acquired
40 * @throws InterruptedException when the thread waiting on this method is interrupted
41 */
42 public boolean acquire(Object ownerId, int targetLockLevel, boolean wait, boolean reentrant, long timeoutMSecs)
43 throws InterruptedException;
44
45 /**
46 * Releases any lock levels the specified owner may hold on this lock.
47 *
48 * @param ownerId a unique id identifying the entity that wants to release all lock levels
49 * @return <code>true</code> if the lock actually was released, <code>false</code> in case
50 * there was no lock held by the owner
51 */
52 public boolean release(Object ownerId);
53
54 /**
55 * Retuns the highest lock level the specified owner holds on this lock or <code>0</code> if it holds no locks at all.
56 *
57 * @param ownerId a unique id identifying the entity that wants to know its highest lock level
58 * @return the highest lock level
59 */
60 public int getLockLevel(Object ownerId);
61 }