1 package org.kuali.incubator;
2
3 import org.apache.log4j.Logger;
4
5 import java.io.File;
6 import java.io.FileInputStream;
7 import java.util.Properties;
8
9
10
11
12
13
14
15
16 public class PropertyUtil {
17 private static final Logger LOG = Logger.getLogger(PropertyUtil.class);
18 private static PropertyUtil propertyUtil = new PropertyUtil();
19 private String OLE_PROPERTIES_FILE_NAME = "env.properties";
20 private String environment;
21
22 public static PropertyUtil getPropertyUtil() {
23 return propertyUtil;
24 }
25
26 private Properties props;
27
28 private PropertyUtil() {
29 props = new Properties();
30 try {
31 props.load(getClass().getResourceAsStream(OLE_PROPERTIES_FILE_NAME));
32 String propsDir = System.getProperty("env.properties.home");
33 String fileSeparator = System.getProperty("file.separator");
34 File userPropsFile = new File(propsDir + fileSeparator + OLE_PROPERTIES_FILE_NAME);
35 if (userPropsFile.exists()) {
36 props.load(new FileInputStream(userPropsFile));
37 }
38 } catch (Exception e) {
39 LOG.error("Unable to load the project.properties file" + e.getMessage());
40 }
41 }
42
43 public String getProperty(String key) {
44 environment = System.getProperty("app.environment");
45 return props.getProperty(environment + "." + key);
46 }
47 }