diff --git a/build.gradle b/build.gradle index fc351ec..db35cb4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'java-library' } sourceSets { @@ -28,7 +29,9 @@ repositories { } dependencies { - implementation project(":common") - + api project(":common") + api 'io.prometheus:simpleclient:0.12.0' + api 'org.knowhowlab.osgi:sigar:1.6.5_01' + api fileTree(dir: 'libs', include: '*.jar') testImplementation 'junit:junit:4.13.2' } diff --git a/src/main/java/org/bdware/sc/ContractClient.java b/src/main/java/org/bdware/sc/ContractClient.java index 514f349..02400b7 100644 --- a/src/main/java/org/bdware/sc/ContractClient.java +++ b/src/main/java/org/bdware/sc/ContractClient.java @@ -3,7 +3,6 @@ package org.bdware.sc; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bdware.sc.ContractResult.Status; @@ -267,7 +266,7 @@ public class ContractClient { (isDebug ? "-debug" : "")); File directory = new File(""); LOGGER.debug("[CMD] path: " + directory.getAbsolutePath()); - LOGGER.debug(StringUtils.join(builder.command(), " ")); + LOGGER.debug(JsonUtil.toPrettyJson(builder.command())); Map map = builder.environment(); map.put("java.library.path", jniPath.getAbsolutePath() + osJni); diff --git a/src/main/java/org/bdware/sc/ContractStatusRecorder.java b/src/main/java/org/bdware/sc/ContractStatusRecorder.java index 5f47f1c..6b858db 100644 --- a/src/main/java/org/bdware/sc/ContractStatusRecorder.java +++ b/src/main/java/org/bdware/sc/ContractStatusRecorder.java @@ -1,6 +1,5 @@ package org.bdware.sc; -import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bdware.sc.ContractPort.PortVisitor; @@ -113,11 +112,15 @@ public class ContractStatusRecorder extends StatusRecorder { public void reSyncStatusAtStart() { List toPrint = new ArrayList<>(); + Set toRemove = new HashSet<>(); for (ContractMeta meta : getStatus().values()) { toPrint.add(meta.status + " " + meta.id + " " + meta.name + " "); + if (meta.contract == null) + toRemove.add(meta); } LOGGER.debug(JsonUtil.toPrettyJson(toPrint)); - + for (ContractMeta meta : toRemove) + remove(meta); for (String id : id2ContractClient.keySet()) { ContractMeta meta = getStatus().get(id); if (null == meta) { @@ -251,7 +254,7 @@ public class ContractStatusRecorder extends StatusRecorder { } public ContractClient getContractClient(String idOrName) { - if (StringUtils.isBlank(idOrName)) { + if (idOrName == null || idOrName.length() == 0) { return null; } // TODO ensure load contract client diff --git a/src/main/java/org/bdware/sc/DoipServiceInfoConfigurer.java b/src/main/java/org/bdware/sc/DoipServiceInfoConfigurer.java new file mode 100644 index 0000000..44754b8 --- /dev/null +++ b/src/main/java/org/bdware/sc/DoipServiceInfoConfigurer.java @@ -0,0 +1,14 @@ +package org.bdware.sc; + +import org.bdware.doip.application.DoipServiceConfig; +import org.bdware.doip.endpoint.doipServer.DoipServiceInfo; + +public interface DoipServiceInfoConfigurer { + String getServiceHandle(); + + String resetServiceConfig(String configJson); + + DoipServiceConfig getDoipServiceConfig(); + + DoipServiceInfo getDoipServiceInfo(); +} diff --git a/src/main/java/org/bdware/sc/units/MultiContractMeta.java b/src/main/java/org/bdware/sc/units/MultiContractMeta.java index 3198432..a8fa797 100644 --- a/src/main/java/org/bdware/sc/units/MultiContractMeta.java +++ b/src/main/java/org/bdware/sc/units/MultiContractMeta.java @@ -154,7 +154,16 @@ public class MultiContractMeta implements IDSerializable { public String[] getMembers() { return members; } - + public String joinMembers(String delimiter){ + StringBuilder sb = new StringBuilder(); + if (members.length > 0) + sb.append(members[0]); + else return ""; + for (int i = 1; i < members.length; i++) { + sb.append(delimiter).append(members[i]); + } + return sb.toString(); + } public void setMembers(String[] m) { members = m; }