001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.objectserver.impl;
006:
007: import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
008:
009: import com.tc.exception.ImplementMe;
010: import com.tc.exception.TCRuntimeException;
011: import com.tc.net.groups.NodeID;
012: import com.tc.object.ObjectID;
013: import com.tc.objectserver.api.ObjectManager;
014: import com.tc.objectserver.api.ObjectManagerEventListener;
015: import com.tc.objectserver.api.ObjectManagerStatsListener;
016: import com.tc.objectserver.context.ObjectManagerResultsContext;
017: import com.tc.objectserver.core.api.GarbageCollector;
018: import com.tc.objectserver.core.api.ManagedObject;
019: import com.tc.objectserver.core.impl.TestManagedObject;
020: import com.tc.objectserver.mgmt.ManagedObjectFacade;
021: import com.tc.objectserver.persistence.api.PersistenceTransaction;
022: import com.tc.text.PrettyPrinter;
023: import com.tc.util.ObjectIDSet2;
024: import com.tc.util.concurrent.NoExceptionLinkedQueue;
025:
026: import java.util.Collection;
027: import java.util.HashMap;
028: import java.util.HashSet;
029: import java.util.Iterator;
030: import java.util.List;
031: import java.util.Map;
032: import java.util.Set;
033:
034: public class TestObjectManager implements ObjectManager {
035:
036: public boolean makePending = false;
037:
038: public TestObjectManager() {
039: super ();
040: }
041:
042: public void stop() {
043: throw new ImplementMe();
044: }
045:
046: public ManagedObjectFacade lookupFacade(ObjectID id) {
047: throw new ImplementMe();
048: }
049:
050: public boolean lookupObjectsAndSubObjectsFor(NodeID nodeID,
051: ObjectManagerResultsContext context, int maxCount) {
052: return basicLookup(nodeID, context, maxCount);
053: }
054:
055: public LinkedQueue lookupObjectForCreateIfNecessaryContexts = new LinkedQueue();
056:
057: public boolean lookupObjectsFor(NodeID nodeID,
058: ObjectManagerResultsContext context) {
059: Object[] args = new Object[] { nodeID, context };
060: try {
061: lookupObjectForCreateIfNecessaryContexts.put(args);
062: } catch (InterruptedException e) {
063: throw new TCRuntimeException(e);
064: }
065: return basicLookup(nodeID, context, -1);
066: }
067:
068: private boolean basicLookup(NodeID nodeID,
069: ObjectManagerResultsContext context, int i) {
070: if (!makePending) {
071: context.setResults(new ObjectManagerLookupResultsImpl(
072: createLookResults(context.getLookupIDs())));
073: }
074: return !makePending;
075: }
076:
077: public void processPending(Object[] args) {
078: basicLookup((NodeID) args[0],
079: (ObjectManagerResultsContext) args[1], -1);
080: }
081:
082: private Map createLookResults(Collection ids) {
083: Map results = new HashMap();
084: for (Iterator i = ids.iterator(); i.hasNext();) {
085: ObjectID id = (ObjectID) i.next();
086: TestManagedObject tmo = new TestManagedObject(id);
087: results.put(id, tmo);
088: }
089: return results;
090: }
091:
092: public Iterator getRoots() {
093: throw new ImplementMe();
094: }
095:
096: public void createObject(ManagedObject object) {
097: throw new ImplementMe();
098: }
099:
100: public void createRoot(String name, ObjectID id) {
101: //
102: }
103:
104: public ObjectID lookupRootID(String name) {
105: throw new ImplementMe();
106: }
107:
108: public void setGarbageCollector(GarbageCollector gc) {
109: throw new ImplementMe();
110: }
111:
112: public void addListener(ObjectManagerEventListener listener) {
113: throw new ImplementMe();
114: }
115:
116: public ManagedObject getObjectByID(ObjectID id) {
117: throw new ImplementMe();
118: }
119:
120: public final LinkedQueue releaseContextQueue = new LinkedQueue();
121:
122: public void release(PersistenceTransaction tx, ManagedObject object) {
123: try {
124: releaseContextQueue.put(object);
125: } catch (InterruptedException e) {
126: throw new TCRuntimeException(e);
127: }
128: }
129:
130: public void releaseReadOnly(ManagedObject object) {
131: try {
132: releaseContextQueue.put(object);
133: } catch (InterruptedException e) {
134: throw new TCRuntimeException(e);
135: }
136: }
137:
138: public final LinkedQueue releaseAllQueue = new LinkedQueue();
139:
140: public void releaseAll(PersistenceTransaction tx,
141: Collection collection) {
142: try {
143: releaseAllQueue.put(collection);
144: } catch (InterruptedException e) {
145: throw new TCRuntimeException(e);
146: }
147: }
148:
149: public PrettyPrinter prettyPrint(PrettyPrinter out) {
150: throw new ImplementMe();
151: }
152:
153: public final NoExceptionLinkedQueue startCalls = new NoExceptionLinkedQueue();
154:
155: public void start() {
156: startCalls.put(new Object());
157: }
158:
159: public void setStatsListener(ObjectManagerStatsListener listener) {
160: throw new ImplementMe();
161: }
162:
163: public void dump() {
164: throw new ImplementMe();
165: }
166:
167: public void releaseAll(Collection objects) {
168: releaseAll(null, objects);
169: }
170:
171: public int getCheckedOutCount() {
172: return 0;
173: }
174:
175: public Set getRootIDs() {
176: return new HashSet();
177: }
178:
179: public ObjectIDSet2 getAllObjectIDs() {
180: return new ObjectIDSet2();
181: }
182:
183: public Object getLock() {
184: return this ;
185: }
186:
187: public void addFaultedObject(ObjectID oid, ManagedObject mo,
188: boolean removeOnRelease) {
189: throw new ImplementMe();
190: }
191:
192: public void waitUntilReadyToGC() {
193: throw new ImplementMe();
194: }
195:
196: public void notifyGCComplete(Set toDelete) {
197: throw new ImplementMe();
198: }
199:
200: public void flushAndEvict(List objects2Flush) {
201: throw new ImplementMe();
202: }
203:
204: public Map getRootNamesToIDsMap() {
205: throw new ImplementMe();
206: }
207:
208: public GarbageCollector getGarbageCollector() {
209: throw new ImplementMe();
210: }
211:
212: }
|