Configuration.java
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
public class Configuration extends PropertyPlaceholderConfigurer {
private static final Logger logger = Logger.getLogger(Configuration.class);
private static final Map<String, String> parameterMap = new HashMap();
private Resource location;
public void setLocation(Resource location) {
this.location = location;
}
public void loadProperties(Properties props) throws IOException {
PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
InputStream is = null;
try {
Resource location = this.location;
is = location.getInputStream();
propertiesPersister.load(props, is);
Iterator var6 = props.keySet().iterator();
while(var6.hasNext()) {
Object key = var6.next();
String code = props.getProperty((String)key).trim();
parameterMap.put((String)key, code);
}
} catch (Exception var11) {
logger.error("initialization error", var11);
var11.printStackTrace();
} finally {
if (is != null) {
is.close();
}
}
}
public Configuration() {
logger.setLevel(Level.INFO);
}
public String getProperty(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (str == null) {
String errMsg = String.format("config.properties key Error, can not find key [%s]", name);
logger.error(errMsg);
throw new LteException(errMsg);
} else {
return str.trim();
}
}
public String getPropertyMaybeNull(String name) throws LteException {
String str = (String)parameterMap.get(name);
if (StringUtils.isBlank(str)) {
str = "";
}
return str.trim();
}
}