01: /*
02:
03: Derby - Class org.apache.derbyTesting.unitTests.services.T_L1
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.unitTests.services;
23:
24: import org.apache.derby.iapi.services.locks.*;
25:
26: import org.apache.derby.iapi.services.sanity.SanityManager;
27: import java.util.Hashtable;
28:
29: /**
30: Unit test Lockable
31: <BR>
32: A simple Lockable that allows a single locker, but that locker
33: can lock the object multiple times, standard Lockable behaviour.
34: */
35:
36: class T_L1 implements Lockable {
37:
38: long value = 0;
39: int count = 0;
40:
41: Latch latch;
42:
43: T_L1() {
44: }
45:
46: /*
47: ** Lockable methods (Simple, qualifier assumed to be null).
48: */
49:
50: /**
51: Qualififier is assumed to be null.
52: @see Lockable#lockEvent
53: */
54: public void lockEvent(Latch lockInfo) {
55: if (SanityManager.DEBUG)
56: SanityManager.ASSERT(lockInfo.getQualifier() == null);
57:
58: latch = lockInfo;
59:
60: count++;
61: }
62:
63: public boolean requestCompatible(Object requestedQualifier,
64: Object grantedQualifier) {
65: return false;
66: }
67:
68: public boolean lockerAlwaysCompatible() {
69: return true;
70: }
71:
72: /**
73: Qualififier is assumed to be null.
74: @see Lockable#unlockEvent
75: */
76: public void unlockEvent(Latch lockInfo) {
77: if (SanityManager.DEBUG)
78: SanityManager.ASSERT(lockInfo.getQualifier() == null);
79:
80: count--;
81: if (SanityManager.DEBUG)
82: SanityManager.ASSERT(count >= 0);
83: latch = null;
84: }
85:
86: public boolean lockAttributes(int flag, Hashtable t) {
87: return false;
88: }
89: }
|