KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > core > impl > TestManagedObject


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.core.impl;
5
6 import com.tc.exception.ImplementMe;
7 import com.tc.io.TCByteBufferOutputStream;
8 import com.tc.object.ObjectID;
9 import com.tc.object.dna.api.DNA;
10 import com.tc.object.dna.impl.ObjectStringSerializer;
11 import com.tc.object.tx.TransactionID;
12 import com.tc.objectserver.api.ObjectInstanceMonitor;
13 import com.tc.objectserver.core.api.ManagedObject;
14 import com.tc.objectserver.core.api.ManagedObjectState;
15 import com.tc.objectserver.impl.ManagedObjectReference;
16 import com.tc.objectserver.managedobject.BackReferences;
17 import com.tc.objectserver.managedobject.ManagedObjectStateFactory;
18 import com.tc.objectserver.managedobject.ManagedObjectTraverser;
19 import com.tc.objectserver.mgmt.ManagedObjectFacade;
20 import com.tc.objectserver.persistence.api.ManagedObjectStore;
21 import com.tc.util.concurrent.NoExceptionLinkedQueue;
22
23 import gnu.trove.TLinkable;
24
25 import java.io.Serializable JavaDoc;
26 import java.util.Arrays JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.Set JavaDoc;
29
30 /**
31  * @author steve
32  */

33 public class TestManagedObject implements ManagedObject, ManagedObjectReference, Serializable JavaDoc {
34   public final NoExceptionLinkedQueue setTransientStateCalls = new NoExceptionLinkedQueue();
35   private ObjectID id;
36   private ObjectID[] references;
37   private boolean isDirty;
38
39   public TestManagedObject(ObjectID id, ObjectID[] references) {
40     this.id = id;
41     this.references = references;
42   }
43
44   public TestManagedObject(ObjectID id) {
45     this(id, new ObjectID[0]);
46   }
47
48   public void setReference(int index, ObjectID id) {
49     this.references[index] = id;
50   }
51
52   public ObjectID getID() {
53     return id;
54   }
55
56   public Set JavaDoc getObjectReferences() {
57     return new HashSet JavaDoc(Arrays.asList(references));
58   }
59
60   public void apply(DNA dna, TransactionID txID, BackReferences includeIDs, ObjectInstanceMonitor imo) {
61     // do nothing
62
}
63
64   public void commit() {
65     return;
66   }
67
68   public void toDNA(TCByteBufferOutputStream out, ObjectStringSerializer serializer) {
69     throw new ImplementMe();
70   }
71
72   public void setObjectStore(ManagedObjectStore store) {
73     return;
74   }
75
76   public ManagedObjectFacade createFacade(int limit) {
77     throw new ImplementMe();
78   }
79
80   public boolean isDirty() {
81     return this.isDirty;
82   }
83
84   public void setIsDirty(boolean isDirty) {
85     this.isDirty = isDirty;
86   }
87
88   public void setReferences(ObjectID[] references) {
89     this.references = references;
90   }
91
92   public boolean isNew;
93   public boolean isNew() {
94     return this.isNew;
95   }
96
97   public void setTransientState(ManagedObjectStateFactory stateFactory) {
98     setTransientStateCalls.put(stateFactory);
99   }
100
101   public ManagedObjectReference getReference() {
102     return this;
103   }
104   
105   boolean processPendingOnRelease;
106   public boolean getProcessPendingOnRelease() {
107     return processPendingOnRelease;
108   }
109
110   public void setProcessPendingOnRelease(boolean b) {
111     this.processPendingOnRelease = b;
112   }
113
114   boolean removeOnRelease;
115   public void setRemoveOnRelease(boolean removeOnRelease) {
116     this.removeOnRelease = removeOnRelease;
117   }
118
119   public boolean isRemoveOnRelease() {
120     return removeOnRelease;
121   }
122
123   boolean referenced;
124   public void markReference() {
125     referenced = true;
126   }
127
128   public void unmarkReference() {
129     referenced = false;
130   }
131
132   public boolean isReferenced() {
133     return referenced;
134   }
135   
136   public ManagedObject getObject() {
137     return this;
138   }
139
140   public ObjectID getObjectID() {
141     return getID();
142   }
143
144   public void markAccessed() {
145     throw new ImplementMe();
146   }
147
148   public void clearAccessed() {
149     throw new ImplementMe();
150   }
151
152   public boolean recentlyAccessed() {
153     throw new ImplementMe();
154   }
155
156   public int accessCount(int accessed) {
157     throw new ImplementMe();
158   }
159
160   TLinkable next;
161   TLinkable previous;
162   
163   public TLinkable getNext() {
164     return this.next;
165   }
166
167   public TLinkable getPrevious() {
168     return this.previous;
169   }
170
171   public void setNext(TLinkable linkable) {
172     this.next = linkable;
173   }
174
175   public void setPrevious(TLinkable linkable) {
176     this.previous = linkable;
177   }
178
179   public ManagedObjectState getManagedObjectState() {
180     throw new ImplementMe();
181   }
182   
183   public String JavaDoc toString() {
184     return "TestManagedObject["+id+"]";
185   }
186
187   public boolean canEvict() {
188     return true;
189   }
190
191   public void addObjectReferencesTo(ManagedObjectTraverser traverser) {
192     return;
193   }
194 }
195
Popular Tags