Blame view

src/main/java/com/essa/framework/ConfigProperties.java 3.12 KB
79149350   suweicheng   开发梳理;
1
2
3
4
5
6
7
8
9
10
11
12
13
  package com.essa.framework;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Properties;
  
  /**
   * Created by weicheng on 2018/10/25.
   */
  public class ConfigProperties {
  
d6c2eca9   suweicheng   开发梳理;
14
      //浏览器名称
79149350   suweicheng   开发梳理;
15
      private String browserName;
d6c2eca9   suweicheng   开发梳理;
16
      //bpms首页url
79149350   suweicheng   开发梳理;
17
      private String serverURL;
d6c2eca9   suweicheng   开发梳理;
18
      //buyer首页url
79149350   suweicheng   开发梳理;
19
20
      private String buyerURL;
  
ca59c24b   suweicheng   开发梳理;
21
22
23
24
25
26
27
28
29
      // 数据库驱动名字
      private String jdbcName = null;
      // 数据库协议地址
      private String dbUrl = null;
      // 数据库用户名
      private String dbUser = null;
      // 数据库密码
      private String dbPassword = null;
  
79149350   suweicheng   开发梳理;
30
31
32
33
34
35
36
      private ConfigProperties() {
  
      }
  
      private static Map<String,ConfigProperties> configPropertiesMap = new HashMap<String,ConfigProperties>();
  
      static {
d6c2eca9   suweicheng   开发梳理;
37
          //读取各个环境的配置项
79149350   suweicheng   开发梳理;
38
39
40
41
42
43
44
45
46
47
          EnvEnum[] env = EnvEnum.values();
          for (EnvEnum envEnum : env) {
              try {
                  ConfigProperties configProperties = new ConfigProperties();
                  Properties p = new Properties();
                  InputStream ips = ClassLoader.getSystemResourceAsStream("conf/config_" + envEnum.getCode() +".properties");
                  p.load(ips);
                  configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释
                  configProperties.setBuyerURL(p.getProperty("buyerURL"));
                  configProperties.setServerURL(p.getProperty("serverURL"));
ca59c24b   suweicheng   开发梳理;
48
49
50
51
                  configProperties.setJdbcName(p.getProperty("jdbc.driver"));
                  configProperties.setDbUrl(p.getProperty("jdbc.url"));
                  configProperties.setDbUser(p.getProperty("jdbc.user"));
                  configProperties.setDbPassword(p.getProperty("jdbc.pwd"));
79149350   suweicheng   开发梳理;
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
82
83
84
85
86
                  configPropertiesMap.put(envEnum.getCode(),configProperties);
                  ips.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
      public static ConfigProperties getConfig(EnvEnum envEnum) {
          return configPropertiesMap.get(envEnum.getCode());
      }
  
      public String getBrowserName() {
          return browserName;
      }
  
      public void setBrowserName(String browserName) {
          this.browserName = browserName;
      }
  
      public String getServerURL() {
          return serverURL;
      }
  
      public void setServerURL(String serverURL) {
          this.serverURL = serverURL;
      }
  
      public String getBuyerURL() {
          return buyerURL;
      }
  
      public void setBuyerURL(String buyerURL) {
          this.buyerURL = buyerURL;
      }
ca59c24b   suweicheng   开发梳理;
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  
      public String getJdbcName() {
          return jdbcName;
      }
  
      public void setJdbcName(String jdbcName) {
          this.jdbcName = jdbcName;
      }
  
      public String getDbUrl() {
          return dbUrl;
      }
  
      public void setDbUrl(String dbUrl) {
          this.dbUrl = dbUrl;
      }
  
      public String getDbUser() {
          return dbUser;
      }
  
      public void setDbUser(String dbUser) {
          this.dbUser = dbUser;
      }
  
      public String getDbPassword() {
          return dbPassword;
      }
  
      public void setDbPassword(String dbPassword) {
          this.dbPassword = dbPassword;
      }
79149350   suweicheng   开发梳理;
119
  }