mirror of
https://gitee.com/BDWare/common
synced 2025-01-10 01:44:16 +00:00
feat: support fork annotation
This commit is contained in:
parent
6d5f005f6e
commit
bb71895f6e
@ -55,7 +55,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
group = "org.bdware.sc"
|
group = "org.bdware.sc"
|
||||||
|
|
||||||
version = "1.7.8"
|
version = "1.7.9"
|
||||||
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
||||||
|
|
||||||
task copyLibs(type: Copy) {
|
task copyLibs(type: Copy) {
|
||||||
|
@ -3,6 +3,7 @@ package org.bdware.sc.node;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
import org.bdware.sc.bean.DoipOperationInfo;
|
import org.bdware.sc.bean.DoipOperationInfo;
|
||||||
|
import org.bdware.sc.bean.ForkInfo;
|
||||||
import org.bdware.sc.bean.JoinInfo;
|
import org.bdware.sc.bean.JoinInfo;
|
||||||
import org.bdware.sc.bean.RouteInfo;
|
import org.bdware.sc.bean.RouteInfo;
|
||||||
import org.bdware.sc.event.REvent.REventSemantics;
|
import org.bdware.sc.event.REvent.REventSemantics;
|
||||||
@ -238,6 +239,7 @@ public class ContractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void maintainRouteJoinInfo(JsonObject methodRouteInfoMap, JsonObject methodJoinInfoMap,
|
public void maintainRouteJoinInfo(JsonObject methodRouteInfoMap, JsonObject methodJoinInfoMap,
|
||||||
|
JsonObject methodForkInfoMap,
|
||||||
JsonObject dependentFunctions) {
|
JsonObject dependentFunctions) {
|
||||||
// all functions存了ContractNode中,所有的FunctionNode
|
// all functions存了ContractNode中,所有的FunctionNode
|
||||||
List<FunctionNode> allFunctions = getFunctions();
|
List<FunctionNode> allFunctions = getFunctions();
|
||||||
@ -247,11 +249,12 @@ public class ContractNode {
|
|||||||
if (doopAnnotation != null && doipOperationInfo != null) {
|
if (doopAnnotation != null && doipOperationInfo != null) {
|
||||||
RouteInfo routeInfo = functionNode.getRouteInfo();
|
RouteInfo routeInfo = functionNode.getRouteInfo();
|
||||||
JoinInfo joinInfo = functionNode.getJoinInfo();
|
JoinInfo joinInfo = functionNode.getJoinInfo();
|
||||||
|
ForkInfo forkInfo = functionNode.getForkInfo();
|
||||||
if (routeInfo != null) {
|
if (routeInfo != null) {
|
||||||
packSourceFunctionAndDependentFunctions(getFunction(routeInfo.funcName),
|
packSourceFunctionAndDependentFunctions(getFunction(routeInfo.funcName),
|
||||||
dependentFunctions);
|
dependentFunctions);
|
||||||
methodRouteInfoMap.add(doipOperationInfo.operationName,
|
methodRouteInfoMap.add(doipOperationInfo.operationName,
|
||||||
JsonUtil.parseObjectAsJsonObject(routeInfo));
|
JsonUtil.parseObjectAsJsonObject(routeInfo));
|
||||||
}
|
}
|
||||||
if (joinInfo != null) {
|
if (joinInfo != null) {
|
||||||
packSourceFunctionAndDependentFunctions(getFunction(joinInfo.joinCountFuncName),
|
packSourceFunctionAndDependentFunctions(getFunction(joinInfo.joinCountFuncName),
|
||||||
@ -261,6 +264,13 @@ public class ContractNode {
|
|||||||
methodJoinInfoMap.add(doipOperationInfo.operationName,
|
methodJoinInfoMap.add(doipOperationInfo.operationName,
|
||||||
JsonUtil.parseObjectAsJsonObject(joinInfo));
|
JsonUtil.parseObjectAsJsonObject(joinInfo));
|
||||||
}
|
}
|
||||||
|
if (forkInfo != null) {
|
||||||
|
packSourceFunctionAndDependentFunctions(getFunction(forkInfo.funcName),
|
||||||
|
dependentFunctions);
|
||||||
|
methodForkInfoMap.add(doipOperationInfo.operationName,
|
||||||
|
JsonUtil.parseObjectAsJsonObject(forkInfo));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +280,7 @@ public class ContractNode {
|
|||||||
if (doopAnnotation != null && doipOperationInfo != null) {
|
if (doopAnnotation != null && doipOperationInfo != null) {
|
||||||
RouteInfo routeInfo = interfaceNode.getRouteInfo();
|
RouteInfo routeInfo = interfaceNode.getRouteInfo();
|
||||||
JoinInfo joinInfo = interfaceNode.getJoinInfo();
|
JoinInfo joinInfo = interfaceNode.getJoinInfo();
|
||||||
|
ForkInfo forkInfo = interfaceNode.getForkInfo();
|
||||||
if (routeInfo != null) {
|
if (routeInfo != null) {
|
||||||
packSourceFunctionAndDependentFunctions(getFunction(routeInfo.funcName),
|
packSourceFunctionAndDependentFunctions(getFunction(routeInfo.funcName),
|
||||||
dependentFunctions);
|
dependentFunctions);
|
||||||
@ -284,6 +295,12 @@ public class ContractNode {
|
|||||||
methodJoinInfoMap.add(doipOperationInfo.operationName,
|
methodJoinInfoMap.add(doipOperationInfo.operationName,
|
||||||
JsonUtil.parseObjectAsJsonObject(joinInfo));
|
JsonUtil.parseObjectAsJsonObject(joinInfo));
|
||||||
}
|
}
|
||||||
|
if (forkInfo != null) {
|
||||||
|
packSourceFunctionAndDependentFunctions(getFunction(forkInfo.funcName),
|
||||||
|
dependentFunctions);
|
||||||
|
methodForkInfoMap.add(doipOperationInfo.operationName,
|
||||||
|
JsonUtil.parseObjectAsJsonObject(routeInfo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.bdware.sc.node;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import org.bdware.sc.bean.DoipOperationInfo;
|
import org.bdware.sc.bean.DoipOperationInfo;
|
||||||
|
import org.bdware.sc.bean.ForkInfo;
|
||||||
import org.bdware.sc.bean.JoinInfo;
|
import org.bdware.sc.bean.JoinInfo;
|
||||||
import org.bdware.sc.bean.RouteInfo;
|
import org.bdware.sc.bean.RouteInfo;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public class FunctionNode extends Script {
|
|||||||
private JsonElement homoEncryptConf;
|
private JsonElement homoEncryptConf;
|
||||||
private JsonElement homoDecryptConf;
|
private JsonElement homoDecryptConf;
|
||||||
public transient Class compiledClazz;
|
public transient Class compiledClazz;
|
||||||
|
private ForkInfo forkInfo;
|
||||||
|
|
||||||
public FunctionNode(String name, String fileName) {
|
public FunctionNode(String name, String fileName) {
|
||||||
this.functionName = name;
|
this.functionName = name;
|
||||||
@ -302,4 +304,12 @@ public class FunctionNode extends Script {
|
|||||||
return node;
|
return node;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setForkInfo(ForkInfo forkInfo) {
|
||||||
|
this.forkInfo = forkInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForkInfo getForkInfo() {
|
||||||
|
return forkInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.bdware.sc.node;
|
package org.bdware.sc.node;
|
||||||
|
|
||||||
import org.bdware.sc.bean.DoipOperationInfo;
|
import org.bdware.sc.bean.DoipOperationInfo;
|
||||||
|
import org.bdware.sc.bean.ForkInfo;
|
||||||
import org.bdware.sc.bean.JoinInfo;
|
import org.bdware.sc.bean.JoinInfo;
|
||||||
import org.bdware.sc.bean.RouteInfo;
|
import org.bdware.sc.bean.RouteInfo;
|
||||||
|
|
||||||
@ -153,4 +154,14 @@ public class InterfaceNode extends Script {
|
|||||||
return node;
|
return node;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ForkInfo forkInfo;
|
||||||
|
|
||||||
|
public void setForkInfo(ForkInfo forkInfo) {
|
||||||
|
this.forkInfo = forkInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForkInfo getForkInfo() {
|
||||||
|
return forkInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
src/main/entry/org/bdware/sc/bean/ForkInfo.java
Normal file
21
src/main/entry/org/bdware/sc/bean/ForkInfo.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package org.bdware.sc.bean;
|
||||||
|
|
||||||
|
import org.bdware.sc.node.AnnotationNode;
|
||||||
|
import org.bdware.sc.node.ContractNode;
|
||||||
|
import org.bdware.sc.util.JsonUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class ForkInfo implements Serializable {
|
||||||
|
public String funcName;
|
||||||
|
|
||||||
|
public static ForkInfo create(AnnotationNode annotationNode, ContractNode contractNode) {
|
||||||
|
ForkInfo info = new ForkInfo();
|
||||||
|
if (annotationNode.getArgs().size() == 1) {
|
||||||
|
String str = annotationNode.getArgs().get(0);
|
||||||
|
info = JsonUtil.fromJson(str, ForkInfo.class);
|
||||||
|
}
|
||||||
|
System.out.println("[ForkInfo] annotationNode:" + JsonUtil.toJson(annotationNode));
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user