KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > txn > LockConflict


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: LockConflict.java,v 1.5 2006/10/30 21:14:27 bostic Exp $
7  */

8
9 package com.sleepycat.je.txn;
10
11 /**
12  * LockConflict is a type safe enumeration of lock conflict types. Methods on
13  * LockConflict objects are used to determine whether a conflict exists and, if
14  * so, how it should be handled.
15  */

16 class LockConflict {
17
18     static final LockConflict ALLOW = new LockConflict(true, false);
19     static final LockConflict BLOCK = new LockConflict(false, false);
20     static final LockConflict RESTART = new LockConflict(false, true);
21
22     private boolean allowed;
23     private boolean restart;
24
25     /**
26      * No conflict types can be defined outside this class.
27      */

28     private LockConflict(boolean allowed, boolean restart) {
29         this.allowed = allowed;
30         this.restart= restart;
31     }
32
33     /**
34      * This method is called first to determine whether the locks is allowed.
35      * If true, there is no conflict. If false, there is a conflict and the
36      * requester must wait for or be denied the lock, or (if getRestart returns
37      * true) an exception should be thrown to cause the requester's operation
38      * to be restarted.
39      */

40     boolean getAllowed() {
41         return allowed;
42     }
43
44     /**
45      * This method is called when getAllowed returns false to determine whether
46      * an exception should be thrown to cause the requester's operation to be
47      * restarted. If getAllowed returns false and this method returns false,
48      * the requester should wait for or be denied the lock, depending on the
49      * request mode. If getAllowed returns true, this method will always
50      * return false.
51      */

52     boolean getRestart() {
53         return restart;
54     }
55 }
56
Popular Tags