KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > l1 > api > TestClientStateManager


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.objectserver.l1.api;
5
6 import com.tc.exception.ImplementMe;
7 import com.tc.net.protocol.tcm.ChannelID;
8 import com.tc.object.ObjectID;
9 import com.tc.objectserver.managedobject.BackReferences;
10 import com.tc.text.PrettyPrinter;
11
12 import java.util.ArrayList JavaDoc;
13 import java.util.Collection JavaDoc;
14 import java.util.Collections JavaDoc;
15 import java.util.HashSet JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18 import java.util.Set JavaDoc;
19
20 public class TestClientStateManager implements ClientStateManager {
21
22   public boolean shutdownClientCalled = false;
23   public Collection JavaDoc allClientIDs = new HashSet JavaDoc();
24   public List JavaDoc addReferenceCalls = new ArrayList JavaDoc();
25
26   public void shutdownClient(ChannelID deadClient) {
27     this.shutdownClientCalled = true;
28   }
29
30   public void addReference(ChannelID clientID, ObjectID objectID) {
31     addReferenceCalls.add(new AddReferenceContext(clientID, objectID));
32   }
33
34   public static class AddReferenceContext {
35     public final ChannelID clientID;
36     public final ObjectID objectID;
37
38     private AddReferenceContext(ChannelID clientID, ObjectID objectID) {
39       this.clientID = clientID;
40       this.objectID = objectID;
41     }
42   }
43
44   public void removeReferences(ChannelID clientID, Set JavaDoc removed) {
45     //
46
}
47
48   public List JavaDoc createPrunedChangesAndAddObjectIDTo(Collection JavaDoc changes, BackReferences includeIDs, ChannelID clientID,
49                                                   Set JavaDoc objectIDs) {
50     return Collections.EMPTY_LIST;
51   }
52
53
54   public boolean hasReference(ChannelID clientID, ObjectID objectID) {
55     // to be consistent with createPrunedChangesAndAddObjectIDTo, return false
56
return false;
57   }
58
59   public void addAllReferencedIdsTo(Set JavaDoc rescueIds) {
60     throw new ImplementMe();
61
62   }
63
64   public PrettyPrinter prettyPrint(PrettyPrinter out) {
65     return out.print(getClass().getName());
66   }
67
68   public Collection JavaDoc getAllClientIDs() {
69     return allClientIDs;
70   }
71
72   public void stop() {
73     // TODO Auto-generated method stub
74

75   }
76
77   public void removeReferencedFrom(ChannelID channelID, Set JavaDoc secondPass) {
78     throw new ImplementMe();
79
80   }
81
82   public Set JavaDoc addReferences(ChannelID channelID, Set JavaDoc oids) {
83     for (Iterator JavaDoc i = oids.iterator(); i.hasNext();) {
84       ObjectID oid = (ObjectID) i.next();
85       addReferenceCalls.add(new AddReferenceContext(channelID, oid));
86     }
87     return oids;
88   }
89
90 }
Popular Tags