KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > blocks > LockManager


1 package org.jgroups.blocks;
2
3 import org.jgroups.ChannelException;
4
5 /**
6  * <code>LockManager</code> represents generic lock manager that allows
7  * obtaining and releasing locks on objects.
8  *
9  * @author Roman Rokytskyy (rrokytskyy@acm.org)
10  */

11 public interface LockManager {
12     
13     /**
14      * Obtain lock on <code>obj</code> for specified <code>owner</code>.
15      * Implementation should try to obtain lock few times within the
16      * specified timeout.
17      *
18      * @param obj obj to lock, usually not full object but object's ID.
19      * @param owner object identifying entity that will own the lock.
20      * @param timeout maximum time that we grant to obtain a lock.
21      *
22      * @throws LockNotGrantedException if lock is not granted within
23      * specified period.
24      *
25      * @throws ClassCastException if <code>obj</code> and/or
26      * <code>owner</code> is not of type that implementation expects to get
27      * (for example, when distributed lock manager obtains non-serializable
28      * <code>obj</code> or <code>owner</code>).
29      *
30      * @throws ChannelException if something bad happened to communication
31      * channel.
32      */

33     void lock(Object JavaDoc obj, Object JavaDoc owner, int timeout)
34     throws LockNotGrantedException, ClassCastException JavaDoc, ChannelException;
35
36     /**
37      * Release lock on <code>obj</code> owned by specified <code>owner</code>.
38      *
39      * @param obj obj to lock, usually not full object but object's ID.
40      * @param owner object identifying entity that will own the lock.
41      *
42      * @throws LockOwnerMismatchException if lock is owned by another object.
43      *
44      * @throws ClassCastException if <code>obj</code> and/or
45      * <code>owner</code> is not of type that implementation expects to get
46      * (for example, when distributed lock manager obtains non-serializable
47      * <code>obj</code> or <code>owner</code>).
48      *
49      * @throws ChannelException if something bad happened to communication
50      * channel.
51      */

52     void unlock(Object JavaDoc obj, Object JavaDoc owner)
53     throws LockNotReleasedException, ClassCastException JavaDoc, ChannelException;
54
55     
56 }
Popular Tags