KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > lock > LockManager


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.cache.lock;
8
9 import org.jboss.cache.TreeCache;
10
11
12 /**
13  * Interface for acquising and releasing locks on nodes of the cache. An implementation
14  * knows the cache and how to acquire locks on nodes.
15  *
16  * @author <a HREF="mailto:bela@jboss.org">Bela Ban</a> Apr 9, 2003
17  * @version $Revision: 1.2.6.1 $
18  */

19 public interface LockManager
20 {
21
22    /**
23     * Can we read values changed in another (uncommitted) transaction ?
24     * If true we can have read-locks; otherwise only write-locks will be acquired
25     */

26    boolean getDirtyReadsAllowed();
27
28    void setDirtyReadsAllowed(boolean flag);
29
30    /**
31     * Acquires a read lock. If the lock cannot be acquired within the <tt>timeout</tt>,
32     * a TimeoutExeption will be thrown. If the current thread already owns the read-lock,
33     * or owns the write-lock, this will succeed.
34     *
35     * @param cache
36     * @param fqn
37     * @param timeout
38     * @throws TimeoutException
39     */

40    void getReadLock(TreeCache cache, String JavaDoc fqn, long timeout) throws TimeoutException;
41
42    /**
43     * Acquires a write-lock. If the lock cannot be acquired within the <tt>timeout</tt>,
44     * a TimeoutExeption will be thrown. If the current thread already owns the write-lock,
45     * this will succeed. If the current thread own the read-lock, it will try to upgrade
46     * the read-lock to write-lock status. If this fails, an UpgradeException will be thrown.
47     *
48     * @param cache
49     * @param fqn
50     * @param timeout
51     * @throws TimeoutException
52     */

53    void getWriteLock(TreeCache cache, String JavaDoc fqn, long timeout)
54          throws TimeoutException, UpgradeException;
55
56    void releaseLock(String JavaDoc fqn, boolean release_children);
57
58 }
59
Popular Tags