01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.impl;
06:
07: import com.tc.exception.ImplementMe;
08: import com.tc.object.ObjectID;
09: import com.tc.objectserver.core.api.ManagedObject;
10: import com.tc.objectserver.persistence.api.ManagedObjectPersistor;
11: import com.tc.objectserver.persistence.api.PersistenceTransaction;
12: import com.tc.text.PrettyPrinter;
13: import com.tc.util.SyncObjectIdSet;
14: import com.tc.util.SyncObjectIdSetImpl;
15: import com.tc.util.concurrent.NoExceptionLinkedQueue;
16:
17: import java.util.Collection;
18: import java.util.Iterator;
19: import java.util.Map;
20: import java.util.Set;
21:
22: public class TestManagedObjectPersistor implements
23: ManagedObjectPersistor {
24:
25: public final NoExceptionLinkedQueue loadByObjectIDCalls = new NoExceptionLinkedQueue();
26: public final Map map;
27: public boolean closeCalled = false;
28: public SyncObjectIdSet allObjectIDs = new SyncObjectIdSetImpl();
29:
30: public TestManagedObjectPersistor(Map map) {
31: this .map = map;
32: }
33:
34: public ManagedObject loadObjectByID(ObjectID id) {
35: loadByObjectIDCalls.put(id);
36: return (ManagedObject) map.get(id);
37: }
38:
39: public ObjectID loadRootID(String name) {
40: return null;
41: }
42:
43: public void addRoot(PersistenceTransaction tx, String name,
44: ObjectID id) {
45: return;
46: }
47:
48: public void saveObject(PersistenceTransaction tx,
49: ManagedObject managedObject) {
50: map.put(managedObject.getID(), managedObject);
51: }
52:
53: public void saveAllObjects(PersistenceTransaction tx,
54: Collection managed) {
55: for (Iterator i = managed.iterator(); i.hasNext();) {
56: saveObject(tx, (ManagedObject) i.next());
57: }
58: }
59:
60: public void deleteObjectByID(PersistenceTransaction tx, ObjectID id) {
61: map.remove(id);
62: }
63:
64: public void prettyPrint(PrettyPrinter out) {
65: return;
66: }
67:
68: public Set loadRoots() {
69: return null;
70: }
71:
72: public Set loadRootNames() {
73: return null;
74: }
75:
76: public long nextObjectIDBatch(int batchSize) {
77: throw new ImplementMe();
78: }
79:
80: public void setNextAvailableObjectID(long startID) {
81: throw new ImplementMe();
82: }
83:
84: public SyncObjectIdSet getAllObjectIDs() {
85: return allObjectIDs;
86: }
87:
88: public void deleteAllObjectsByID(PersistenceTransaction tx,
89: Collection ids) {
90: for (Iterator i = ids.iterator(); i.hasNext();) {
91: deleteObjectByID(tx, (ObjectID) i.next());
92: }
93: }
94:
95: public Map loadRootNamesToIDs() {
96: return null;
97: }
98:
99: }
|