1 8 package org.ozoneDB.core.storage.gammaStore; 9 10 import java.io.File ; 11 import java.io.IOException ; 12 import java.util.Collection ; 13 import java.util.List ; 14 import java.util.Properties ; 15 import java.util.logging.Logger ; 16 import org.ozoneDB.core.storage.PropertyInfo; 17 18 22 public class RandomAccessFileStorageFactory extends FileStorageFactory { 23 24 private static Logger log = Logger.getLogger(RandomAccessFileStorageFactory.class.getName()); 25 26 public static final PropertyInfo MODE = new PropertyInfo( 27 ".mode", 28 "one of r, rw, rws, rwd", 29 "rws", 30 "mode for opening the storage files; see mode in java.util.RandomAccessFile#RandomAccessFile(java.io.File, String)", 31 new String [] { 32 "rw", "rwd" 33 } 34 ); 35 36 private String mode; 37 38 41 public RandomAccessFileStorageFactory(Properties properties, String prefix) { 42 super(properties, prefix); 43 String property = getPrefix() + MODE.getKey(); 44 setMode(properties.getProperty(property, MODE.getDefaultValue())); 45 } 46 47 public Storage createStorage(String name) throws IOException { 48 File file = nameToFile(name); 49 ensureParentsExist(file); 50 return new RandomAccessFileStorage(file, getMode()); 51 } 52 53 private String getMode() { 55 return mode; 56 } 57 58 private void setMode(String mode) { 60 this.mode = mode; 61 } 62 63 public Collection getPropertyInfos() { 64 Collection result = super.getPropertyInfos(); 65 result.add(MODE); 66 return result; 67 } 68 69 } 70 | Popular Tags |