1 24 package org.objectweb.jalisto.se.impl.readonly; 25 26 import org.objectweb.jalisto.se.api.JalistoProperties; 27 import org.objectweb.jalisto.se.api.internal.*; 28 import org.objectweb.jalisto.se.api.internal.InternalPhysicalFileAccess; 29 import org.objectweb.jalisto.se.api.query.FieldDescription; 30 import org.objectweb.jalisto.se.impl.server.IfaIndex; 31 import org.objectweb.jalisto.se.impl.InFileAddress; 32 import org.objectweb.jalisto.se.impl.server.PhysicalOid; 33 import org.objectweb.jalisto.se.impl.server.page.*; 34 import org.objectweb.jalisto.se.impl.server.page.info.PageInfo; 35 import org.objectweb.jalisto.se.impl.trace.Trace; 36 import org.objectweb.jalisto.se.JalistoFactory; 37 38 public class LogicalPageAccessReadOnlyImpl implements LogicalSystemPageAccess { 39 40 public LogicalPageAccessReadOnlyImpl(JalistoProperties properties) { 41 InternalFactory internalFactory = JalistoFactory.getInternalFactory(); 42 tracer = internalFactory.getTracer(properties); 43 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : create new instance"); 44 physicalAccess = internalFactory.getInternalPhysicalAccess(properties); 45 ifaIndex = IfaIndex.getAnIfaIndex(physicalAccess, properties); 46 } 47 48 public String toString() { 49 return physicalAccess.toString(); 50 } 51 52 public InternalPhysicalFileAccess getPhysicalAccess() { 53 return physicalAccess; 54 } 55 56 public void begin(Object sessionId) { 57 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : begin() : nothing to do"); 58 } 59 60 public void commit(Object sessionId) { 61 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : commit()"); 62 physicalAccess.commit(); 63 } 64 65 public void rollback(Object sessionId) { 66 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : rollback()"); 67 physicalAccess.rollback(); 68 } 69 70 public void cleanAllNullValue() { 71 throw new UnsupportedOperationException (); 72 } 73 74 77 78 public PhysicalOid allocateNewFpoid(Object sessionId, Object clid) { 79 throw new UnsupportedOperationException (); 80 } 81 82 public void desallocateFpoid(Object sessionId, PhysicalOid fpoid) { 83 throw new UnsupportedOperationException (); 84 } 85 86 public void insertDatas(Object sessionId, PhysicalOid fpoid, DataWrapper datas) { 87 throw new UnsupportedOperationException (); 88 } 89 90 public DataWrapper readDatas(Object sessionId, PhysicalOid fpoid) { 91 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : readDatas({0})", fpoid); 92 InFileAddress ifa = getInstanceIfa(fpoid); 93 InstancePage dataPage = (InstancePage) physicalAccess.readFileObjectAt(ifa); 94 return (DataWrapper) dataPage.getDataAt(ifa); 95 } 96 97 public PhysicalOid updateDatas(Object sessionId, PhysicalOid fpoid, DataWrapper datas) { 98 throw new UnsupportedOperationException (); 99 } 100 101 public void deleteDatas(Object sessionId, PhysicalOid fpoid) { 102 throw new UnsupportedOperationException (); 103 } 104 105 106 109 110 public InFileAddress allocateNodeAddressAndInsert(Object sessionId, FieldDescription meta, DataWrapper node) { 111 throw new UnsupportedOperationException (); 112 } 113 114 public Object readNode(Object sessionId, InFileAddress ifa) { 115 NodePage page = (NodePage) physicalAccess.readFileObjectAt(ifa); 116 return page.getDataAt(ifa); 117 } 118 119 public void updateNode(Object sessionId, InFileAddress ifa, DataWrapper node) { 120 throw new UnsupportedOperationException (); 121 } 122 123 public void removeNode(Object sessionId, InFileAddress ifa) { 124 throw new UnsupportedOperationException (); 125 } 126 127 public InFileAddress allocateLeafAddressAndInsert(Object sessionId, FieldDescription meta, DataWrapper oids) { 128 throw new UnsupportedOperationException (); 129 } 130 131 public Object readLeaf(Object sessionId, InFileAddress ifa) { 132 LeafPage page = (LeafPage) physicalAccess.readFileObjectAt(ifa); 133 return page.getDataAt(ifa); 134 } 135 136 public void updateLeaf(Object sessionId, InFileAddress ifa, DataWrapper oids) { 137 throw new UnsupportedOperationException (); 138 } 139 140 public void removeLeaf(Object sessionId, InFileAddress ifa) { 141 throw new UnsupportedOperationException (); 142 } 143 144 147 148 private InFileAddress getInstanceIfa(PhysicalOid fpoid) { 149 InFileAddress systemIfa = ifaIndex.getPidIfa(fpoid.getPid()); 150 SystemPage systemPage = (SystemPage) physicalAccess.readFileObjectAt(systemIfa); 151 PageInfo infos = (PageInfo) systemPage.getDataAt(systemIfa); 152 InFileAddress instanceIfa = infos.getPageIfa(); 153 instanceIfa.setIndex(fpoid.getIidAsInteger().intValue()); 154 return instanceIfa; 155 } 156 157 public void updateIndexObject(InFileAddress ifa, DataWrapper indexObject) { 158 tracer.println(Trace.LOGICAL, "LogicalPageAccessImpl : updateIndexObject({0}, {1})", ifa, indexObject); 159 UserPage page = (UserPage) physicalAccess.readFileObjectAt(ifa); 160 page.setDataAt(ifa, indexObject); 161 physicalAccess.updateFileObject(page); 162 } 163 164 private IfaIndex ifaIndex; 165 private InternalPhysicalFileAccess physicalAccess; 166 167 168 private Trace tracer; 169 } 170 | Popular Tags |