KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > impl > TestObjectManager


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

5 package com.tc.objectserver.impl;
6
7 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
8
9 import com.tc.exception.ImplementMe;
10 import com.tc.exception.TCRuntimeException;
11 import com.tc.net.protocol.tcm.ChannelID;
12 import com.tc.object.ObjectID;
13 import com.tc.objectserver.api.ObjectManager;
14 import com.tc.objectserver.api.ObjectManagerEventListener;
15 import com.tc.objectserver.api.ObjectManagerStatsListener;
16 import com.tc.objectserver.context.ObjectManagerResultsContext;
17 import com.tc.objectserver.core.api.GarbageCollector;
18 import com.tc.objectserver.core.api.ManagedObject;
19 import com.tc.objectserver.core.impl.TestManagedObject;
20 import com.tc.objectserver.mgmt.ManagedObjectFacade;
21 import com.tc.objectserver.persistence.api.PersistenceTransaction;
22 import com.tc.text.PrettyPrinter;
23 import com.tc.util.SyncObjectIdSet;
24 import com.tc.util.SyncObjectIdSetImpl;
25 import com.tc.util.concurrent.NoExceptionLinkedQueue;
26
27 import java.util.Collection JavaDoc;
28 import java.util.HashMap JavaDoc;
29 import java.util.HashSet JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.Set JavaDoc;
34
35 public class TestObjectManager implements ObjectManager {
36
37   public boolean makePending = false;
38
39   public TestObjectManager() {
40     super();
41   }
42
43   public void stop() {
44     throw new ImplementMe();
45   }
46
47   public ManagedObjectFacade lookupFacade(ObjectID id) {
48     throw new ImplementMe();
49   }
50
51   public boolean lookupObjectsAndSubObjectsFor(ChannelID channelID, ObjectManagerResultsContext context, int maxCount) {
52     return basicLookup(channelID, context, maxCount);
53   }
54
55   public LinkedQueue lookupObjectForCreateIfNecessaryContexts = new LinkedQueue();
56
57   public boolean lookupObjectsForCreateIfNecessary(ChannelID channelID, ObjectManagerResultsContext context) {
58     Object JavaDoc[] args = new Object JavaDoc[] { channelID, context };
59     try {
60       lookupObjectForCreateIfNecessaryContexts.put(args);
61     } catch (InterruptedException JavaDoc e) {
62       throw new TCRuntimeException(e);
63     }
64     return basicLookup(channelID, context, -1);
65   }
66
67   private boolean basicLookup(ChannelID channelID, ObjectManagerResultsContext context, int i) {
68     if (!makePending) {
69       context.setResults(new ObjectManagerLookupResultsImpl(createLookResults(context.getLookupIDs())));
70     }
71     return !makePending;
72   }
73
74   public void processPending(Object JavaDoc[] args) {
75     basicLookup((ChannelID) args[0], (ObjectManagerResultsContext) args[1], -1);
76   }
77
78   private Map JavaDoc createLookResults(Collection JavaDoc ids) {
79     Map JavaDoc results = new HashMap JavaDoc();
80     for (Iterator JavaDoc i = ids.iterator(); i.hasNext();) {
81       ObjectID id = (ObjectID) i.next();
82       TestManagedObject tmo = new TestManagedObject(id);
83       results.put(id, tmo);
84     }
85     return results;
86   }
87
88   public Iterator JavaDoc getRoots() {
89     throw new ImplementMe();
90   }
91
92   public void createObject(ManagedObject object) {
93     throw new ImplementMe();
94   }
95
96   public void createRoot(String JavaDoc name, ObjectID id) {
97     //
98
}
99
100   public ObjectID lookupRootID(String JavaDoc name) {
101     throw new ImplementMe();
102   }
103
104   public void setGarbageCollector(GarbageCollector gc) {
105     throw new ImplementMe();
106   }
107
108   public void addListener(ObjectManagerEventListener listener) {
109     throw new ImplementMe();
110   }
111
112   public ManagedObject getObjectByID(ObjectID id) {
113     throw new ImplementMe();
114   }
115
116   public final LinkedQueue releaseContextQueue = new LinkedQueue();
117
118   public void release(PersistenceTransaction tx, ManagedObject object) {
119     try {
120       releaseContextQueue.put(object);
121     } catch (InterruptedException JavaDoc e) {
122       throw new TCRuntimeException(e);
123     }
124   }
125
126   public void releaseReadOnly(ManagedObject object) {
127     try {
128       releaseContextQueue.put(object);
129     } catch (InterruptedException JavaDoc e) {
130       throw new TCRuntimeException(e);
131     }
132   }
133
134   public final LinkedQueue releaseAllQueue = new LinkedQueue();
135
136   public void releaseAll(PersistenceTransaction tx, Collection JavaDoc collection) {
137     try {
138       releaseAllQueue.put(collection);
139     } catch (InterruptedException JavaDoc e) {
140       throw new TCRuntimeException(e);
141     }
142   }
143
144   public PrettyPrinter prettyPrint(PrettyPrinter out) {
145     throw new ImplementMe();
146   }
147
148   public final NoExceptionLinkedQueue startCalls = new NoExceptionLinkedQueue();
149
150   public void start() {
151     startCalls.put(new Object JavaDoc());
152   }
153
154   public void setStatsListener(ObjectManagerStatsListener listener) {
155     throw new ImplementMe();
156   }
157
158   public void dump() {
159     throw new ImplementMe();
160   }
161
162   public void releaseAll(Collection JavaDoc objects) {
163     releaseAll(null, objects);
164   }
165
166   public int getCheckedOutCount() {
167     return 0;
168   }
169
170   public Set getRootIDs() {
171     return new HashSet JavaDoc();
172   }
173
174   public SyncObjectIdSet getAllObjectIDs() {
175     return new SyncObjectIdSetImpl();
176   }
177
178   public Object JavaDoc getLock() {
179     return this;
180   }
181
182   public void addFaultedObject(ObjectID oid, ManagedObject mo, boolean removeOnRelease) {
183     throw new ImplementMe();
184   }
185
186   public void waitUntilReadyToGC() {
187     throw new ImplementMe();
188   }
189
190   public void notifyGCComplete(Set toDelete) {
191     throw new ImplementMe();
192   }
193
194   public void flushAndEvict(List JavaDoc objects2Flush) {
195     throw new ImplementMe();
196   }
197
198   public Map JavaDoc getRootNamesToIDsMap() {
199     throw new ImplementMe();
200   }
201
202 }
203
Popular Tags