blob: 2a21798db607fd23d07457898b9afb9b443e8d38 (
plain)
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
|
package cn.ac.iie.utils;
import java.util.Properties;
//import com.nis.util.StringUtil;
public final class RealtimeCountConfigurations {
private static Properties propCommon = new Properties();//0
private static Properties propService = new Properties();//1
public static String getStringProperty(Integer type, String key) {
if(type == 0){
return propCommon.getProperty(key);
} else if(type == 1){
return propService.getProperty(key);
} else {
return null;
}
}
public static Integer getIntProperty(Integer type, String key) {
if(type == 0){
return Integer.parseInt(propCommon.getProperty(key));
} else if(type == 1){
return Integer.parseInt(propService.getProperty(key));
} else {
return null;
}
}
public static Long getLongProperty(Integer type, String key) {
if(type == 0){
return Long.parseLong(propCommon.getProperty(key));
} else if(type == 1){
return Long.parseLong(propService.getProperty(key));
} else {
return null;
}
}
public static Boolean getBooleanProperty(Integer type, String key) {
if(type == 0){
return propCommon.getProperty(key).toLowerCase().trim().equals("true");
} else if(type == 1){
return propService.getProperty(key).toLowerCase().trim().equals("true");
} else {
return null;
}
}
static {
try {
propCommon.load(RealtimeCountConfigurations.class.getClassLoader().getResourceAsStream("realtime_config.properties"));//0
propService.load(RealtimeCountConfigurations.class.getClassLoader().getResourceAsStream("storm_config.properties"));//1
/*prop.load(new FileInputStream(System.getProperty("user.dir")
+ File.separator + "config"+File.separator + "config.properties"));*/
System.out.println("realtime_config.properties加载成功");
System.out.println("storm_config.properties加载成功");
} catch (Exception e) {
propCommon = null;
propService = null;
System.err.println("RealtimeCountConfigurations配置文件加载失败");
}
}
}
|