This is an automated email from the ASF dual-hosted git repository.
jermy pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-hugegraph-commons.git
The following commit(s) were added to refs/heads/master by this push:
new c31a536 add some construction methods for more convenient use (#132)
c31a536 is described below
commit c31a53641febb1008d45ddeb1fb45b7b765aeb5d
Author: ustcer <[email protected]>
AuthorDate: Wed Jul 19 21:06:52 2023 +0800
add some construction methods for more convenient use (#132)
Co-authored-by: chengxin05 <[email protected]>
---
.../main/java/org/apache/hugegraph/config/HugeConfig.java | 11 +++++++++++
.../src/main/java/org/apache/hugegraph/event/EventHub.java | 7 +++++--
.../src/main/java/org/apache/hugegraph/rest/RestResult.java | 12 +++++++++---
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git
a/hugegraph-common/src/main/java/org/apache/hugegraph/config/HugeConfig.java
b/hugegraph-common/src/main/java/org/apache/hugegraph/config/HugeConfig.java
index b765369..c48219f 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/config/HugeConfig.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/config/HugeConfig.java
@@ -55,6 +55,17 @@ public class HugeConfig extends PropertiesConfiguration {
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");
diff --git
a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java
b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java
index 0886e7e..5107fba 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java
@@ -57,11 +57,14 @@ public class 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) {
diff --git
a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestResult.java
b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestResult.java
index 813aeff..82b7f39 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestResult.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestResult.java
@@ -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() {