1 package be.dvw.administration.util; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 6 import java.util.Properties; 7 import java.io.*; 8 import java.net.URL; 9 10 import be.dvw.administration.mvc.taglibs.LeftMenuTag; 11 12 /*** 13 * Created by IntelliJ IDEA. 14 * User: Toon.Timbermont 15 * Date: Mar 24, 2005 16 * Time: 10:54:22 PM 17 * To change this template use File | Settings | File Templates. 18 */ 19 public class PropertyManager { 20 21 private static Properties PROPERTIES; 22 private static String PROPERTIES_FILE_PATH = "application.properties"; 23 private static Log LOG = LogFactory.getLog(PropertyManager.class); 24 25 private static void loadProperties() throws IOException { 26 27 LOG.debug("Loading application properties"); 28 29 InputStream is = FileUtils.getFileInputStream(PROPERTIES_FILE_PATH); 30 PROPERTIES = new Properties(); 31 PROPERTIES.load( is ); 32 is.close(); 33 34 LOG.debug("Properties loaded"); 35 36 } 37 38 public static String getProperty(String property) throws IOException 39 { 40 LOG.debug("Get Property " + property); 41 if ( PROPERTIES == null || PROPERTIES.isEmpty() || PROPERTIES.size() == 0) 42 try { 43 loadProperties(); 44 } catch (IOException e) { 45 LOG.fatal("Unable to read property file", e); 46 } 47 String propertyValue = PROPERTIES.getProperty(property); 48 LOG.debug("Returning property " + propertyValue); 49 return propertyValue; 50 } 51 52 53 54 }