1 43 package net.jforum.repository; 44 45 import java.io.FileInputStream ; 46 import java.util.Iterator ; 47 import java.util.Properties ; 48 49 import net.jforum.cache.CacheEngine; 50 import net.jforum.cache.Cacheable; 51 import net.jforum.exceptions.ConfigLoadException; 52 53 57 public class Tpl implements Cacheable 58 { 59 private static final String FQN = "templates"; 60 61 private static CacheEngine cache; 62 63 66 public void setCacheEngine(CacheEngine engine) 67 { 68 cache = engine; 69 } 70 71 78 public static void load(String filename) 79 { 80 try { 81 Properties p = new Properties (); 82 p.load(new FileInputStream (filename)); 83 84 for (Iterator iter = p.keySet().iterator(); iter.hasNext(); ) { 85 String key = (String )iter.next(); 86 87 cache.add(FQN, key, p.getProperty(key)); 88 } 89 } 90 catch (Exception e) { 91 e.printStackTrace(); 92 throw new ConfigLoadException("Error while trying to load " + filename + ": " + e); 93 } 94 } 95 96 102 public static String name(String key) 103 { 104 return (String )cache.get(FQN, key); 105 } 106 } 107 | Popular Tags |