01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: LockConflict.java,v 1.5.2.2 2008/01/07 15:14:17 cwl Exp $
07: */
08:
09: 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: }
|