Skip to content

Commit

Permalink
add some construction methods for more convenient use (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: chengxin05 <chengxin05@baidu.com>
  • Loading branch information
chengxin1374 and chmx-ustc authored Jul 19, 2023
1 parent 297e491 commit c31a536
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public HugeConfig(String configFile) {
this.configPath = configFile;
}

public HugeConfig(Map<String, Object> propertyMap) {
if (propertyMap == null) {
throw new ConfigException("The property map is null");
}

for (Map.Entry<String, Object> kv : propertyMap.entrySet()) {
this.addProperty(kv.getKey(), kv.getValue());
}
this.checkRequiredOptions();
}

private void loadConfig(Configuration config) {
if (config == null) {
throw new ConfigException("The config object is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ public EventHub() {
}

public EventHub(String name) {
LOG.debug("Create new EventHub: {}", name);
this(name, 1);
}

public EventHub(String name, int threadSize) {
LOG.debug("Create new EventHub {}", name);
this.name = name;
this.listeners = new ConcurrentHashMap<>();
EventHub.init(1);
EventHub.init(threadSize);
}

public static synchronized void init(int poolSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ public class RestResult {
private final String content;

public RestResult(Response response) {
this.status = response.getStatus();
this.headers = response.getHeaders();
this.content = response.readEntity(String.class);
this(response.getStatus(), response.readEntity(String.class),
response.getHeaders());
}

public RestResult(int status, String content,
MultivaluedMap<String, Object> headers) {
this.status = status;
this.headers = headers;
this.content = content;
}

public int status() {
Expand Down

0 comments on commit c31a536

Please sign in to comment.