summaryrefslogtreecommitdiff
path: root/src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java
diff options
context:
space:
mode:
authorcaohui <[email protected]>2020-04-29 14:32:05 +0800
committercaohui <[email protected]>2020-04-29 14:32:05 +0800
commitd15d7536f385ec4a1250ed15ed52fd6c05eb7431 (patch)
tree737ec8462ef62ac70caeee1533cbee4e76ceef98 /src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java
VoIP Knowledge Base sip-voip-completion Initial commit 202004291431HEADmaster
Diffstat (limited to 'src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java')
-rw-r--r--src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java b/src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java
new file mode 100644
index 0000000..2a21798
--- /dev/null
+++ b/src/main/java/cn/ac/iie/utils/RealtimeCountConfigurations.java
@@ -0,0 +1,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配置文件加载失败");
+ }
+ }
+}