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.object.tx.optimistic;
006:
007: /**
008: * In the clone objects we create for rollback we put one of these in the Managed field in order to be able to correlate
009: * them with the original object they were created from.
010: */
011:
012: import com.tc.exception.ImplementMe;
013: import com.tc.object.ObjectID;
014: import com.tc.object.TCClass;
015: import com.tc.object.TCObject;
016: import com.tc.object.dna.api.DNA;
017: import com.tc.object.dna.api.DNAException;
018: import com.tc.object.dna.api.DNAWriter;
019:
020: import gnu.trove.TLinkable;
021:
022: public class TCObjectClone implements TCObject {
023: private final ObjectID objectID;
024: private final long version;
025: private final OptimisticTransactionManager txManager;
026: private final TCClass tcClass;
027: private final int arrayLength;
028:
029: public TCObjectClone(TCObject source,
030: OptimisticTransactionManager txManager) {
031: this (source, txManager, -1);
032: }
033:
034: public TCObjectClone(TCObject source,
035: OptimisticTransactionManager txManager, int arrayLength) {
036: this .version = source.getVersion();
037: this .objectID = source.getObjectID();
038: this .txManager = txManager;
039: this .tcClass = source.getTCClass();
040: this .arrayLength = arrayLength;
041: }
042:
043: public void setNext(TLinkable link) {
044: throw new ImplementMe();
045: }
046:
047: public void setPrevious(TLinkable link) {
048: throw new ImplementMe();
049: }
050:
051: public TLinkable getNext() {
052: throw new ImplementMe();
053: }
054:
055: public TLinkable getPrevious() {
056: throw new ImplementMe();
057: }
058:
059: public ObjectID getObjectID() {
060: return objectID;
061: }
062:
063: public Object getPeerObject() {
064: throw new ImplementMe();
065: }
066:
067: public TCClass getTCClass() {
068: return tcClass;
069: }
070:
071: public int clearReferences(int toClear) {
072: throw new ImplementMe();
073: }
074:
075: public Object getResolveLock() {
076: return this ;
077: }
078:
079: public void objectFieldChanged(String classname, String fieldname,
080: Object newValue, int index) {
081: txManager.objectFieldChanged(this , classname, fieldname,
082: newValue, index);
083: }
084:
085: public void booleanFieldChanged(String classname, String fieldname,
086: boolean newValue, int index) {
087: this .objectFieldChanged(classname, fieldname, new Boolean(
088: newValue), index);
089: }
090:
091: public void byteFieldChanged(String classname, String fieldname,
092: byte newValue, int index) {
093: this .objectFieldChanged(classname, fieldname,
094: new Byte(newValue), index);
095: }
096:
097: public void charFieldChanged(String classname, String fieldname,
098: char newValue, int index) {
099: this .objectFieldChanged(classname, fieldname, new Character(
100: newValue), index);
101: }
102:
103: public void doubleFieldChanged(String classname, String fieldname,
104: double newValue, int index) {
105: this .objectFieldChanged(classname, fieldname, new Double(
106: newValue), index);
107: }
108:
109: public void floatFieldChanged(String classname, String fieldname,
110: float newValue, int index) {
111: this .objectFieldChanged(classname, fieldname, new Float(
112: newValue), index);
113: }
114:
115: public void intFieldChanged(String classname, String fieldname,
116: int newValue, int index) {
117: this .objectFieldChanged(classname, fieldname, new Integer(
118: newValue), index);
119: }
120:
121: public void longFieldChanged(String classname, String fieldname,
122: long newValue, int index) {
123: this .objectFieldChanged(classname, fieldname,
124: new Long(newValue), index);
125: }
126:
127: public void shortFieldChanged(String classname, String fieldname,
128: short newValue, int index) {
129: this .objectFieldChanged(classname, fieldname, new Short(
130: newValue), index);
131: }
132:
133: public void logicalInvoke(int method, String methodName,
134: Object[] parameters) {
135: txManager.logicalInvoke(this , method, methodName, parameters);
136: }
137:
138: public void hydrate(DNA from, boolean force) throws DNAException {
139: throw new ImplementMe();
140: }
141:
142: public void resolveReference(String fieldName) {
143: // do nothing
144: }
145:
146: public void resolveArrayReference(int index) {
147: // do Nothing
148: }
149:
150: public boolean isShared() {
151: return false;
152: }
153:
154: public void resolveAllReferences() {
155: // do nothing
156: }
157:
158: public ObjectID setReference(String fieldName, ObjectID id) {
159: throw new ImplementMe();
160: }
161:
162: public void setArrayReference(int index, ObjectID id) {
163: throw new ImplementMe();
164: }
165:
166: public void clearReference(String fieldName) {
167: throw new ImplementMe();
168:
169: }
170:
171: public void setValue(String fieldName, Object obj) {
172: throw new ImplementMe();
173:
174: }
175:
176: public long getVersion() {
177: return version;
178: }
179:
180: public void setVersion(long version) {
181: throw new ImplementMe();
182: }
183:
184: public boolean dehydrateIfNew(DNAWriter writer) throws DNAException {
185: throw new ImplementMe();
186: }
187:
188: public void setIsNew() {
189: throw new ImplementMe();
190: }
191:
192: public boolean isNew() {
193: return false;
194: }
195:
196: public void markAccessed() {
197: throw new ImplementMe();
198: }
199:
200: public void clearAccessed() {
201: throw new ImplementMe();
202: }
203:
204: public boolean recentlyAccessed() {
205: throw new ImplementMe();
206: }
207:
208: public void objectFieldChangedByOffset(String classname,
209: long fieldOffset, Object newValue, int index) {
210: String fieldname = tcClass.getFieldNameByOffset(fieldOffset);
211: objectFieldChanged(classname, fieldname, newValue, index);
212: }
213:
214: public String getFieldNameByOffset(long fieldOffset) {
215: throw new ImplementMe();
216: }
217:
218: public void disableAutoLocking() {
219: throw new ImplementMe();
220: }
221:
222: public boolean autoLockingDisabled() {
223: return false;
224: }
225:
226: public boolean canEvict() {
227: throw new ImplementMe();
228: }
229:
230: public void objectArrayChanged(int startPos, Object[] array,
231: int length) {
232: throw new ImplementMe();
233: }
234:
235: public void primitiveArrayChanged(int startPos, Object arra,
236: int lengthy) {
237: throw new ImplementMe();
238: }
239:
240: public int accessCount(int factor) {
241: throw new ImplementMe();
242: }
243:
244: public void literalValueChanged(Object newValue, Object oldValue) {
245: throw new ImplementMe();
246: }
247:
248: public void setLiteralValue(Object newValue) {
249: throw new ImplementMe();
250: }
251:
252: public ArrayIndexOutOfBoundsException checkArrayIndex(int index) {
253: if (arrayLength < 0) {
254: throw new AssertionError();
255: }
256: if (index < 0 || index >= arrayLength) {
257: return new ArrayIndexOutOfBoundsException(index);
258: }
259: return null;
260: }
261:
262: public boolean isFieldPortableByOffset(long fieldOffset) {
263: throw new ImplementMe();
264: }
265:
266: }
|