KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > lockmanager > api > TestLockManager


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.lockmanager.api;
5
6 import com.tc.exception.ImplementMe;
7 import com.tc.object.lockmanager.impl.GlobalLockInfo;
8 import com.tc.object.session.SessionID;
9 import com.tc.object.tx.TransactionID;
10 import com.tc.object.tx.WaitInvocation;
11
12 import java.util.ArrayList JavaDoc;
13 import java.util.Collection JavaDoc;
14 import java.util.LinkedList JavaDoc;
15 import java.util.List JavaDoc;
16
17 /**
18  * @author steve
19  */

20 public class TestLockManager implements ClientLockManager {
21   public final List JavaDoc locks = new ArrayList JavaDoc();
22   public final List JavaDoc lockIDForCalls = new LinkedList JavaDoc();
23   public final List JavaDoc waitCalls = new LinkedList JavaDoc();
24   public final List JavaDoc notifyCalls = new LinkedList JavaDoc();
25   public final List JavaDoc unlockCalls = new LinkedList JavaDoc();
26
27   public void unlock(LockID id, ThreadID threadID) {
28     unlockCalls.add(new Object JavaDoc[] {id, threadID });
29   }
30
31   public LockID lockIDFor(String JavaDoc id) {
32     lockIDForCalls.add(id);
33     return new LockID(id);
34   }
35
36   public void awardLock(SessionID sessionID, LockID id, ThreadID threadID, int type) {
37     return;
38   }
39
40   public void lock(LockID id, ThreadID threadID, int type) {
41     locks.add(new Object JavaDoc[] { id, threadID, new Integer JavaDoc(type) });
42   }
43
44   public void wait(LockID lockID, ThreadID transactionID, WaitInvocation call, Object JavaDoc waitLock,
45                    WaitListener listener) {
46     waitCalls.add(new Object JavaDoc[] { lockID, transactionID, call, waitLock, listener });
47   }
48
49   public Notify notify(LockID lockID, ThreadID threadID, boolean all) {
50     notifyCalls.add(new Object JavaDoc[] { lockID, threadID, new Boolean JavaDoc(all) });
51     return Notify.NULL;
52   }
53
54   public Collection JavaDoc addAllPendingLockRequestsTo(Collection JavaDoc c) {
55     return c;
56   }
57
58   public void pause() {
59     return;
60   }
61
62   public void starting() {
63     return;
64   }
65   public void unpause() {
66     return;
67
68   }
69
70   public boolean isStarting() {
71     return false;
72   }
73
74   public Collection JavaDoc addAllWaitersTo(Collection JavaDoc c) {
75     return c;
76   }
77
78   public Collection JavaDoc addAllHeldLocksTo(Collection JavaDoc c) {
79     return c;
80   }
81
82   public void notified(LockID lockID, ThreadID threadID) {
83     return;
84   }
85
86   public void recall(LockID lockID, ThreadID id, int level) {
87     return;
88   }
89
90   public void waitTimedOut(LockID lockID, ThreadID threadID) {
91     return;
92   }
93
94   public void runGC() {
95     return;
96   }
97
98   public boolean isLocked(LockID lockID) {
99     return lockIDForCalls.contains(lockID.asString());
100   }
101
102   public int queueLength(LockID lockID, ThreadID threadID) {
103     throw new ImplementMe();
104   }
105
106   public int localHeldCount(LockID lockID, int lockLevel, ThreadID threadID) {
107     throw new ImplementMe();
108   }
109
110   public boolean isLocked(LockID lockID, ThreadID threadID) {
111     throw new ImplementMe();
112   }
113
114   public boolean haveLock(LockID lockID, TransactionID requesterID) {
115     throw new ImplementMe();
116   }
117
118   public void queryLockCommit(ThreadID threadID, GlobalLockInfo globalLockInfo) {
119     throw new ImplementMe();
120   }
121
122   public int waitLength(LockID lockID, ThreadID threadID) {
123     throw new ImplementMe();
124   }
125
126   public boolean tryLock(LockID id, ThreadID threadID, int type) {
127     throw new ImplementMe();
128   }
129
130   public void cannotAwardLock(SessionID sessionID, LockID id, ThreadID threadID, int type) {
131     throw new ImplementMe();
132
133   }
134 }
135
Popular Tags