1 27 package org.objectweb.speedo.mim.lib; 28 29 import org.objectweb.speedo.mim.api.LifeCycle; 30 import org.objectweb.speedo.mim.api.DetachedLifeCycle; 31 import org.objectweb.speedo.mim.api.SpeedoAccessor; 32 import org.objectweb.speedo.mim.api.SpeedoProxy; 33 import org.objectweb.perseus.cache.api.CacheEntry; 34 import org.objectweb.perseus.persistence.api.State; 35 36 import javax.jdo.JDOUserException; 37 38 44 public abstract class BasicSpeedoAccessor implements SpeedoAccessor { 45 46 52 53 protected byte jdoStatus = LifeCycle.initState(); 54 55 public byte detachedStatus = DetachedLifeCycle.initState(); 56 57 protected boolean isToMerge = false; 58 59 public SpeedoProxy proxy = null; 60 61 public boolean hasBeenFlush = false; 62 63 public BasicSpeedoAccessor() { 64 } 65 66 public BasicSpeedoAccessor(SpeedoProxy _proxy) { 67 this.proxy = _proxy; 68 } 69 70 73 public CacheEntry getCacheEntry() { 74 return proxy; 75 } 76 77 78 81 public Object getMemoryInstance() { 82 return this; 83 } 84 85 86 89 95 public void jdoChangeStatus(byte action) { 96 byte neo = LifeCycle.nextStatePersistenceCapable(jdoStatus, action); 97 if (neo == LifeCycle.ERROR) { 98 throw new JDOUserException("Operation " 99 + LifeCycle.actionToString(action) 100 + " not allowed with the status " 101 + LifeCycle.statusToString(jdoStatus)); 102 } 103 jdoStatus = neo; 104 } 105 106 112 public byte jdoGetStatus() { 113 return jdoStatus; 114 } 115 116 122 public void jdoSetStatus(byte newValue) { 123 jdoStatus = newValue; 124 } 125 126 public byte getDetachedStatus() { 127 return detachedStatus; 128 } 129 130 public void setDetachedStatus(byte newValue) { 131 detachedStatus = newValue; 132 } 133 134 137 public SpeedoProxy getSpeedoProxy() { 138 return proxy; 139 } 140 141 144 public void setSpeedoProxy(SpeedoProxy sp) { 145 proxy = sp; 146 } 147 148 public void prepareWrite() { 149 } 151 152 public void workingSetClosed() { 153 } 155 156 public boolean hasBeenFlush() { 157 return hasBeenFlush; 158 } 159 160 public void setFlushed(boolean val) { 161 hasBeenFlush = val; 162 } 163 164 public void changeVersion() { 165 } 167 168 public boolean checkVersion(SpeedoAccessor sa) { 169 return true; 170 } 171 172 public long getVersion() { 173 return 0; 174 } 175 176 public boolean isToMerge() { 177 return this.isToMerge; 178 } 179 public void makeToMerge(Object thinLock) { 180 this.isToMerge = true; 181 182 } 183 public State merge(State oldState) { 184 this.isToMerge = false; 185 return oldState; 186 } 187 188 public Object getUserKey(int cacheId) { 189 return null; 190 } 191 192 public void indexFieldModified(int cacheId, boolean rebind) { 193 } 194 } 195 | Popular Tags |