1 21 package net.sf.packtag.util; 22 23 import java.io.File ; 24 import java.io.FileReader ; 25 import java.io.IOException ; 26 import java.util.Properties ; 27 28 29 30 37 public class Configuration { 38 39 private static Configuration instance; 40 private Properties configuration; 41 42 43 private static Configuration getInstance() { 44 if (instance == null) { 45 synchronized (Configuration.class) { 46 if (instance == null) { 47 instance = new Configuration(); 48 } 49 } 50 } 51 return instance; 52 } 53 54 55 public static String getCacheType() { 56 getInstance().getConfigurationCacheType(); 57 return null; 58 } 59 60 61 private Configuration() { 62 configuration = new Properties (getDefaults()); 63 File f = new File ("packtag.properties"); 64 if (f.exists()) { 65 try { 66 FileReader fr = new FileReader (f); 67 configuration.load(fr); 68 } 69 catch (IOException e) { 70 e.printStackTrace(); 71 } 72 } 73 } 74 75 76 private Properties getDefaults() { 77 Properties defaults = new Properties (); 78 defaults.setProperty("cache.type", "file"); 79 defaults.setProperty("cache.file.path", "pack"); 80 defaults.setProperty("cache.servlet.path", "/PackServlet"); 81 defaults.setProperty("resources.checktimestamps", "true"); 82 defaults.setProperty("hide.errors", "false"); 83 return defaults; 84 } 85 86 87 protected Properties getConfiguration() { 88 return configuration; 89 } 90 91 92 public String getConfigurationCacheType() { 93 return (String )getConfiguration().get("cache.type"); 94 } 95 } 96 | Popular Tags |