1 24 package org.objectweb.jalisto.se.impl.readonly; 25 26 import org.objectweb.jalisto.se.api.*; 27 import org.objectweb.jalisto.se.api.physical.PluggablePhysicalFileAccess; 28 import org.objectweb.jalisto.se.api.internal.*; 29 import org.objectweb.jalisto.se.impl.InFileAddress; 30 import org.objectweb.jalisto.se.JalistoFactory; 31 32 import java.util.Collection ; 33 import java.util.Map ; 34 35 public class InTransactionBaseImageReadOnly implements InTransactionBaseImage { 36 37 public InTransactionBaseImageReadOnly(PluggablePhysicalFileAccess physicalAccess, JalistoProperties properties) { 38 this.readObjects = JalistoFactory.getInternalFactory().getCache(properties, 39 properties.getPageCacheSize(), 40 "inTransactionBaseImageCache"); 41 this.physicalAccess = physicalAccess; 42 this.keepInMemory = properties.isKeepingInMemory(); 43 } 44 45 public boolean isWorking() { 46 return false; 47 } 48 49 public boolean startWorking() { 50 return true; 51 } 52 53 public void stopWorking() { 54 } 55 56 public void begin() { 57 } 58 59 public synchronized void commit() { 60 if (!keepInMemory) { 61 readObjects.clear(); 62 } 63 } 64 65 public synchronized void rollback() { 66 if (!keepInMemory) { 67 readObjects.clear(); 68 } 69 } 70 71 public synchronized JalistoObject readFileObjectAt(InFileAddress ifa) { 72 String address = ifa.getAddress(); 73 JalistoObject result = (JalistoObject) readObjects.get(address); 74 if (result != null) 75 return result; 76 result = physicalAccess.readFileObjectAt(ifa); 77 readObjects.put(address, result); 78 return result; 79 } 80 81 public Map getReadObjects() { 82 return readObjects; 83 } 84 85 public boolean isKeepInMemory() { 86 return keepInMemory; 87 } 88 89 public void setKeepInMemory(boolean keepInMemory) { 90 this.keepInMemory = keepInMemory; 91 } 92 93 94 public void deleteFileObject(InFileAddress ifa) { 95 throw new UnsupportedOperationException (); 96 } 97 98 public int getDeletedObjectsSize() { 99 throw new UnsupportedOperationException (); 100 } 101 102 public int getModifiedObjectsSize() { 103 throw new UnsupportedOperationException (); 104 } 105 106 public int getNewObjectsSize() { 107 throw new UnsupportedOperationException (); 108 } 109 110 public void insertFileObject(InFileAddress ifa, JalistoObject fo) { 111 throw new UnsupportedOperationException (); 112 } 113 114 public void updateFileObject(InFileAddress ifa, JalistoObject fo) { 115 throw new UnsupportedOperationException (); 116 } 117 118 public Collection getKeysStartingWith(String filter, boolean withOrder) { 119 return physicalAccess.getKeysStartingWith(filter); 120 } 121 122 private Map readObjects; 123 private PluggablePhysicalFileAccess physicalAccess; 124 private boolean keepInMemory; 125 } 126 | Popular Tags |