-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathConfigBuilder.java
More file actions
95 lines (78 loc) · 2.98 KB
/
Copy pathConfigBuilder.java
File metadata and controls
95 lines (78 loc) · 2.98 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package io.arex.inst.runtime.config;
import io.arex.inst.runtime.model.DynamicClassEntity;
import io.arex.inst.runtime.model.RecordRuleEntity;
import java.util.*;
public class ConfigBuilder {
private final Map<String, String> properties;
private boolean enableDebug = false;
private final String serviceName;
private List<DynamicClassEntity> dynamicClassList;
private Set<String> excludeServiceOperations;
private int dubboStreamReplayThreshold;
private int recordRate;
private List<RecordRuleEntity> recordRuleList;
private boolean existUrlParamRule;
private boolean existBodyParamRule;
public static ConfigBuilder create(String serviceName) {
return new ConfigBuilder(serviceName);
}
public ConfigBuilder(String serviceName) {
this.serviceName = serviceName;
properties = new HashMap<>();
}
public ConfigBuilder enableDebug(boolean enableDebug) {
this.enableDebug = enableDebug;
return this;
}
public ConfigBuilder dynamicClassList(List<DynamicClassEntity> dynamicClassList) {
this.dynamicClassList = dynamicClassList;
return this;
}
public ConfigBuilder excludeServiceOperations(Set<String> excludeServiceOperations) {
this.excludeServiceOperations = excludeServiceOperations;
return this;
}
public ConfigBuilder addProperty(String name, String value) {
if (value != null) {
properties.put(name, value);
}
return this;
}
// for: arex-instrumentation module
public ConfigBuilder addProperties(Properties properties) {
if (properties != null) {
for (String name : properties.stringPropertyNames()) {
addProperty(name, properties.getProperty(name));
}
}
return this;
}
public ConfigBuilder addProperties(Map<String, String> configMap) {
properties.putAll(configMap);
return this;
}
public ConfigBuilder dubboStreamReplayThreshold(int dubboStreamReplayThreshold) {
this.dubboStreamReplayThreshold = dubboStreamReplayThreshold;
return this;
}
public ConfigBuilder recordRate(int recordRate) {
this.recordRate = recordRate;
return this;
}
public ConfigBuilder recordRuleList(List<RecordRuleEntity> recordRuleList) {
this.recordRuleList = recordRuleList;
return this;
}
public ConfigBuilder existUrlParamRule(boolean existUrlParamRule) {
this.existUrlParamRule = existUrlParamRule;
return this;
}
public ConfigBuilder existBodyParamRule(boolean existBodyParamRule) {
this.existBodyParamRule = existBodyParamRule;
return this;
}
public void build() {
Config.update(enableDebug, serviceName, dynamicClassList, Collections.unmodifiableMap(new HashMap<>(properties)),
excludeServiceOperations, dubboStreamReplayThreshold, recordRate, recordRuleList, existUrlParamRule, existBodyParamRule);
}
}