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.core.impl;
006:
007: import com.tc.exception.ImplementMe;
008: import com.tc.io.TCByteBufferOutputStream;
009: import com.tc.object.ObjectID;
010: import com.tc.object.dna.api.DNA;
011: import com.tc.object.dna.api.DNAException;
012: import com.tc.object.dna.impl.ObjectStringSerializer;
013: import com.tc.object.tx.TransactionID;
014: import com.tc.objectserver.api.ObjectInstanceMonitor;
015: import com.tc.objectserver.core.api.ManagedObject;
016: import com.tc.objectserver.core.api.ManagedObjectState;
017: import com.tc.objectserver.impl.ManagedObjectReference;
018: import com.tc.objectserver.managedobject.BackReferences;
019: import com.tc.objectserver.managedobject.ManagedObjectStateFactory;
020: import com.tc.objectserver.managedobject.ManagedObjectTraverser;
021: import com.tc.objectserver.mgmt.ManagedObjectFacade;
022: import com.tc.objectserver.persistence.api.ManagedObjectStore;
023: import com.tc.util.concurrent.NoExceptionLinkedQueue;
024:
025: import gnu.trove.TLinkable;
026:
027: import java.io.Serializable;
028: import java.util.Arrays;
029: import java.util.HashSet;
030: import java.util.Set;
031:
032: /**
033: * @author steve
034: */
035: public class TestManagedObject implements ManagedObject,
036: ManagedObjectReference, Serializable {
037: public final NoExceptionLinkedQueue setTransientStateCalls = new NoExceptionLinkedQueue();
038: private ObjectID id;
039: private ObjectID[] references;
040: public boolean isDirty;
041: public boolean isNew;
042:
043: public TestManagedObject(ObjectID id, ObjectID[] references) {
044: this .id = id;
045: this .references = references;
046: }
047:
048: public TestManagedObject(ObjectID id) {
049: this (id, new ObjectID[0]);
050: }
051:
052: public void setReference(int index, ObjectID id) {
053: this .references[index] = id;
054: }
055:
056: public ObjectID getID() {
057: return id;
058: }
059:
060: public Set getObjectReferences() {
061: return new HashSet(Arrays.asList(references));
062: }
063:
064: public void apply(DNA dna, TransactionID txID,
065: BackReferences includeIDs, ObjectInstanceMonitor imo) {
066: // do nothing
067: }
068:
069: public void commit() {
070: return;
071: }
072:
073: public void toDNA(TCByteBufferOutputStream out,
074: ObjectStringSerializer serializer) {
075: throw new ImplementMe();
076: }
077:
078: public void setObjectStore(ManagedObjectStore store) {
079: return;
080: }
081:
082: public ManagedObjectFacade createFacade(int limit) {
083: throw new ImplementMe();
084: }
085:
086: public boolean isDirty() {
087: return this .isDirty;
088: }
089:
090: public void setIsDirty(boolean isDirty) {
091: this .isDirty = isDirty;
092: }
093:
094: public void setReferences(ObjectID[] references) {
095: this .references = references;
096: }
097:
098: public boolean isNew() {
099: return this .isNew;
100: }
101:
102: public void setTransientState(ManagedObjectStateFactory stateFactory) {
103: setTransientStateCalls.put(stateFactory);
104: }
105:
106: public ManagedObjectReference getReference() {
107: return this ;
108: }
109:
110: boolean removeOnRelease;
111:
112: public void setRemoveOnRelease(boolean removeOnRelease) {
113: this .removeOnRelease = removeOnRelease;
114: }
115:
116: public boolean isRemoveOnRelease() {
117: return removeOnRelease;
118: }
119:
120: boolean referenced;
121:
122: public void markReference() {
123: referenced = true;
124: }
125:
126: public void unmarkReference() {
127: referenced = false;
128: }
129:
130: public boolean isReferenced() {
131: return referenced;
132: }
133:
134: public ManagedObject getObject() {
135: return this ;
136: }
137:
138: public ObjectID getObjectID() {
139: return getID();
140: }
141:
142: public void markAccessed() {
143: throw new ImplementMe();
144: }
145:
146: public void clearAccessed() {
147: throw new ImplementMe();
148: }
149:
150: public boolean recentlyAccessed() {
151: throw new ImplementMe();
152: }
153:
154: public int accessCount(int accessed) {
155: throw new ImplementMe();
156: }
157:
158: TLinkable next;
159: TLinkable previous;
160:
161: public TLinkable getNext() {
162: return this .next;
163: }
164:
165: public TLinkable getPrevious() {
166: return this .previous;
167: }
168:
169: public void setNext(TLinkable linkable) {
170: this .next = linkable;
171: }
172:
173: public void setPrevious(TLinkable linkable) {
174: this .previous = linkable;
175: }
176:
177: public ManagedObjectState getManagedObjectState() {
178: throw new ImplementMe();
179: }
180:
181: public String toString() {
182: return "TestManagedObject[" + id + "]";
183: }
184:
185: public boolean canEvict() {
186: return true;
187: }
188:
189: public void addObjectReferencesTo(ManagedObjectTraverser traverser) {
190: return;
191: }
192:
193: public void apply(DNA dna, TransactionID txnID,
194: BackReferences includeIDs,
195: ObjectInstanceMonitor instanceMonitor,
196: boolean ignoreIfOlderDNA) throws DNAException {
197: throw new ImplementMe();
198: }
199:
200: public long getVersion() {
201: throw new ImplementMe();
202: }
203: }
|