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