forked from headissue/shariff-backend-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.java
61 lines (47 loc) · 1.46 KB
/
Config.java
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
package com.headissue.sharecount.proxy;
import java.util.Map;
public class Config {
private static Config instance = null;
final static String MAINTAINER = "SHARECOUNT_PROXY_MAINTAINER";
final static String DOMAINLIST = "SHARECOUNT_PROXY_DOMAINLIST";
final static String CACHESIZE = "SHARECOUNT_CACHE_SIZE";
final static String CACHEEXPIRY = "SHARECOUNT_CACHE_EXPIRY_MS";
String maintainer = "defaultMaintainer";
String domainList = ".*";
int cacheSize = 1000;
long cacheExpiryMilliSeconds = 1000 * 60 * 5;
public static synchronized Config getInstance() {
if (instance == null)
instance = ConfigBuilder.buildFromEnv();
return instance;
}
public String getMaintainer() {
return maintainer;
}
public String getDomainList() {
return domainList;
}
public int getCacheSize() {
return cacheSize;
}
public long getCacheExpiryMilliSeconds() {
return cacheExpiryMilliSeconds;
}
public Config(Map map) {
assert map != null;
domainList = ".*";
maintainer = "https://github.com/headissue/shariff-backend-java";
if (map.get(DOMAINLIST) != null) {
domainList = (String) map.get(DOMAINLIST);
}
if (map.get(MAINTAINER) != null) {
maintainer = (String) map.get(MAINTAINER);
}
if (map.get(CACHEEXPIRY) != null) {
cacheExpiryMilliSeconds = (Integer) map.get(CACHEEXPIRY);
}
if (map.get(CACHESIZE) != null) {
cacheSize = (Integer) map.get(CACHESIZE);
}
}
}