org.bdware.doip.cluster.entity.DDOEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
package org.bdware.doip.cluster.entity;
import com.google.gson.JsonObject;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.cluster.callback.AutoCancelRouteResultCallback;
import org.bdware.doip.cluster.callback.RouteCallback;
import org.bdware.doip.cluster.client.DoaClusterClient;
import org.bdware.doip.cluster.util.DOResolutionUtil;
import org.bdware.doip.cluster.util.RouteJoinUtil;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.codec.operations.BasicOperations;
import org.bdware.doip.endpoint.client.DoipMessageCallback;
import org.bdware.sc.bean.ForkInfo;
import org.bdware.sc.bean.JoinInfo;
import org.bdware.sc.bean.RouteInfo;
import org.bdware.sc.util.JsonUtil;
import wrp.jdk.nashorn.api.scripting.NashornScriptEngineUtil;
import java.util.HashMap;
import java.util.Map;
public class DDOEntity implements DOEntity {
// hello -> routeInfo
private final Map ddoRouteInfo;
// hello -> joinInfo
private final Map ddoJoinInfo;
private final Map ddoForkInfo;
private final String[] bdoList;
private final JsonObject bcoAccessRules;
final NashornScriptEngineUtil engineUtil;
private final JsonObject appendixes;
private final DoaClusterClient client;
private final JsonObject ddoInfo;
public DDOEntity(JsonObject ddoInfo, DoaClusterClient client) {
this.ddoInfo = ddoInfo;
String bcoId = ddoInfo.get("bcoId").getAsString();
appendixes = ddoInfo.get("appendixes").getAsJsonObject();
bcoAccessRules = appendixes.get(bcoId).getAsJsonObject().get("accessRules").getAsJsonObject();
ddoRouteInfo = DOResolutionUtil.getDDORouteInfo(bcoAccessRules);
ddoJoinInfo = DOResolutionUtil.getDDOJoinInfo(bcoAccessRules);
ddoForkInfo = DOResolutionUtil.getDDOForkInfo(bcoAccessRules);
bdoList = JsonUtil.fromJson(ddoInfo.get("bdoList"), String[].class);
this.client = client;
engineUtil = new NashornScriptEngineUtil(this);
}
public JsonObject getDdoInfo() {
return ddoInfo;
}
public DoaClusterClient getDoaClient() {
return client;
}
public Map getDdoRouteInfo() {
return ddoRouteInfo;
}
public NashornScriptEngineUtil getEngineUtil() {
return engineUtil;
}
public Map getDdoJoinInfo() {
return ddoJoinInfo;
}
public JsonObject getAppendixes() {
return appendixes;
}
public String[] getBDOList() {
return bdoList;
}
public JsonObject getAccessRules() {
return bcoAccessRules;
}
@Override
public BDWType getType() {
return BDWType.DDO;
}
@Override
public void sendMessage(DoaClusterClient client, DoipMessage doipMessage, DoipMessageCallback doipMessageCallback, EndpointConfig routerConfig) {
BasicOperations operation = BasicOperations.getDoOp(doipMessage.header.parameters.operation);
RouteCallback routeCallback = new RouteCallback(new HashMap<>(), client, doipMessage, doipMessageCallback, routerConfig, operation, engineUtil, ddoJoinInfo.get(operation.getName()), ddoForkInfo.get(operation.getName()), appendixes);
RouteJoinUtil.route(doipMessage, routerConfig, ddoRouteInfo.get(operation.getName()), engineUtil, new AutoCancelRouteResultCallback(routeCallback, 50));
}
}