proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/MaxWaitTimeOperator.java
MaxWaitTimeOperator
wrappedByTimeout
class MaxWaitTimeOperator extends BaseOperator<Condition> { @Override public Condition build(Object[] objects) throws Exception { OperatorHelper.checkObjectSizeEqTwo(objects); Executable executable = OperatorHelper.convert(objects[0], Executable.class); // 获取传入的时间参数 Integer maxW...
TimeoutCondition timeoutCondition = new TimeoutCondition(); timeoutCondition.addExecutable(executable); timeoutCondition.setMaxWaitTime(maxWaitTime); timeoutCondition.setMaxWaitTimeUnit(getMaxWaitTimeUnit()); return timeoutCondition;
878
65
943
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.Condition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.Condition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/MustOperator.java
MustOperator
build
class MustOperator extends BaseOperator<WhenCondition> { @Override public WhenCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGteTwo(objects); String errorMsg = "The caller must be WhenCondition item"; WhenCondition whenCondition = OperatorHelper.convert(objects[0], WhenCondition.class, errorMsg); // 解析指定完成的任务 ID 集合 Set<String> specifyIdSet = new HashSet<>(); for (int i = 1; i < objects.length; i+...
44
241
285
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.WhenCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.WhenCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NodeOperator.java
NodeOperator
build
class NodeOperator extends BaseOperator<Node> { @Override public Node build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqOne(objects); String nodeId = OperatorHelper.convert(objects[0], String.class); if (FlowBus.containNode(nodeId)) { // 找到对应节点 return FlowBus.getNode(nodeId); } else { // 生成代理节点 return new FallbackNode(nodeId...
44
101
145
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.Node build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.Node executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NotOperator.java
NotOperator
build
class NotOperator extends BaseOperator<NotCondition> { @Override public NotCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqOne(objects); Object object = objects[0]; OperatorHelper.checkObjMustBeBooleanTypeItem(object); Executable item = OperatorHelper.convert(object, Executable.class); NotCondition notCondition = new NotCondition(); notCondition.setItem(item...
44
91
135
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.NotCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.NotCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/OrOperator.java
OrOperator
build
class OrOperator extends BaseOperator<AndOrCondition> { @Override public AndOrCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGteTwo(objects); AndOrCondition andOrCondition = new AndOrCondition(); andOrCondition.setBooleanConditionType(BooleanConditionTypeEnum.OR); for (Object object : objects){ OperatorHelper.checkObjMustBeBooleanTypeItem(object); Execu...
46
119
165
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.AndOrCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.AndOrCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ParallelOperator.java
ParallelOperator
build
class ParallelOperator extends BaseOperator<LoopCondition> { @Override public LoopCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqTwo(objects); String errorMsg = "The caller must be LoopCondition item"; LoopCondition loopCondition = OperatorHelper.convert(objects[0], LoopCondition.class, errorMsg); Boolean parallel = OperatorHelper.convert(objects[1], Boolean.class); loopC...
46
99
145
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.LoopCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.LoopCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/PreOperator.java
PreOperator
build
class PreOperator extends BaseOperator<PreCondition> { @Override public PreCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGtZero(objects); PreCondition preCondition = new PreCondition(); for (Object obj : objects) { OperatorHelper.checkObjMustBeCommonTypeItem(obj); preCondition.addExecutable(OperatorHelper.convert(obj, Executable.class)); } return preCondition;
44
88
132
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.PreCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.PreCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/RetryOperator.java
RetryOperator
build
class RetryOperator extends BaseOperator<Condition> { @Override public Condition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGteTwo(objects); Executable executable = OperatorHelper.convert(objects[0], Executable.class); Integer retryTimes = OperatorHelper.convert(objects[1], Integer.class); RetryCondition retryCondition = new RetryCondition(); retryCondition.addExecutable...
44
218
262
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.Condition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.Condition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/SwitchOperator.java
SwitchOperator
build
class SwitchOperator extends BaseOperator<SwitchCondition> { @Override public SwitchCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqOne(objects); OperatorHelper.checkObjMustBeSwitchTypeItem(objects[0]); Node switchNode = OperatorHelper.convert(objects[0], Node.class); SwitchCondition switchCondition = new SwitchCondition(); switchCondition.setSwitchNode(switchNode); return switchCondition;
44
90
134
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.SwitchCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.SwitchCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/TagOperator.java
TagOperator
build
class TagOperator extends BaseOperator<Executable> { @Override public Executable build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqTwo(objects); Executable refObj = OperatorHelper.convert(objects[0], Executable.class); String tag = OperatorHelper.convert(objects[1], String.class); //如果解析的对象是一个Chain,由于Chain对象全局唯一,无法再进行复制 //所以如果要给chain设置tag,则需要套上一个THEN,在THEN上面设置tag if (refObj instanceof Chain){ Then...
43
198
241
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.Executable build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.Executable executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ThenOperator.java
ThenOperator
build
class ThenOperator extends BaseOperator<ThenCondition> { @Override public ThenCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGtZero(objects); ThenCondition thenCondition = new ThenCondition(); for (Object obj : objects) { OperatorHelper.checkObjMustBeCommonTypeItem(obj); thenCondition.addExecutable(OperatorHelper.convert(obj, Executable.class)); } return thenCondition;
44
88
132
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.ThenCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.ThenCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ThreadPoolOperator.java
ThreadPoolOperator
build
class ThreadPoolOperator extends BaseOperator<WhenCondition> { @Override public WhenCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqTwo(objects); String errorMsg = "The caller must be WhenCondition item"; WhenCondition whenCondition = OperatorHelper.convert(objects[0], WhenCondition.class, errorMsg); whenCondition.setThreadExecutorClass(OperatorHelper.convert(objects[1], String.class)); return whenCondi...
45
92
137
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.WhenCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.WhenCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ToOperator.java
ToOperator
build
class ToOperator extends BaseOperator<SwitchCondition> { @Override public SwitchCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGteTwo(objects); String errorMsg = "The caller must be SwitchCondition item"; SwitchCondition switchCondition = OperatorHelper.convert(objects[0], SwitchCondition.class, errorMsg); for (int i = 1; i < objects.length; i++) { OperatorHelper.checkObjMustBeCommonTypeItem(objects[...
44
142
186
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.SwitchCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.SwitchCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java
WhenOperator
build
class WhenOperator extends BaseOperator<WhenCondition> { @Override public WhenCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeGtZero(objects); WhenCondition whenCondition = new WhenCondition(); LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); for (Object obj : objects) { OperatorHelper.checkObjMustBeCommonTypeItem(obj); whenCondition.addExecutable(OperatorHelper.convert(obj, Executable...
44
131
175
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.WhenCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.WhenCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhileOperator.java
WhileOperator
build
class WhileOperator extends BaseOperator<WhileCondition> { @Override public WhileCondition build(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} }
OperatorHelper.checkObjectSizeEqOne(objects); OperatorHelper.checkObjMustBeBooleanTypeItem(objects[0]); Executable whileItem = OperatorHelper.convert(objects[0], Executable.class); WhileCondition whileCondition = new WhileCondition(); whileCondition.setWhileItem(whileItem); return whileCondition;
44
91
135
<methods>public non-sealed void <init>() ,public abstract com.yomahub.liteflow.flow.element.condition.WhileCondition build(java.lang.Object[]) throws java.lang.Exception,public com.yomahub.liteflow.flow.element.condition.WhileCondition executeInner(java.lang.Object[]) throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/base/BaseOperator.java
BaseOperator
executeInner
class BaseOperator<T extends Executable> extends Operator { @Override public T executeInner(Object[] objects) throws Exception {<FILL_FUNCTION_BODY>} /** * 构建 EL 条件 * @param objects objects * @return Condition * @throws Exception Exception */ public abstract T build(Object[] objects) throws Exception; ...
try { OperatorHelper.checkItemNotNull(objects); return build(objects); } catch (QLException e) { throw e; } catch (Exception e) { throw new ELParseException("errors occurred in EL parsing"); }
93
77
170
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/ComponentInitializer.java
ComponentInitializer
buildNodeExecutorClass
class ComponentInitializer { private static ComponentInitializer instance; public static ComponentInitializer loadInstance() { if (ObjectUtil.isNull(instance)) { instance = new ComponentInitializer(); } return instance; } public NodeComponent initComponent(NodeComponent nodeComponent, NodeTypeEnum type,...
Class<?> nodeExecutorClass; try { nodeExecutorClass = Class.forName(liteflowConfig.getNodeExecutorClass()); } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage()); } return (Class<? extends NodeExecutor>) nodeExecutorClass;
625
86
711
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutorHolder.java
FlowExecutorHolder
loadInstance
class FlowExecutorHolder { private static FlowExecutor flowExecutor; public static FlowExecutor loadInstance(LiteflowConfig liteflowConfig) { if (ObjectUtil.isNull(flowExecutor)) { flowExecutor = new FlowExecutor(liteflowConfig); } return flowExecutor; } public static FlowExecutor loadInstance() {<FILL_...
if (ObjectUtil.isNull(flowExecutor)) { throw new FlowExecutorNotInitException("flow executor is not initialized yet"); } return flowExecutor;
146
45
191
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeForComponent.java
NodeForComponent
process
class NodeForComponent extends NodeComponent { @Override public void process() throws Exception {<FILL_FUNCTION_BODY>} public abstract int processFor() throws Exception; @Override @SuppressWarnings("unchecked") public Integer getItemResultMetaValue(Integer slotIndex) { return DataBus.getSlot(slotIndex).getFo...
int forCount = processFor(); Slot slot = this.getSlot(); slot.setForResult(this.getMetaValueKey(), forCount);
103
45
148
<methods>public void <init>() ,public void afterProcess() ,public void beforeProcess() ,public void doRollback() throws java.lang.Exception,public void execute() throws java.lang.Exception,public java.lang.String getChainId() ,public java.lang.String getChainName() ,public T getCmpData(Class<T>) ,public T getContextBea...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeIteratorComponent.java
NodeIteratorComponent
process
class NodeIteratorComponent extends NodeComponent { @Override public void process() throws Exception {<FILL_FUNCTION_BODY>} public abstract Iterator<?> processIterator() throws Exception; @Override @SuppressWarnings("unchecked") public Iterator<?> getItemResultMetaValue(Integer slotIndex) { return DataBus.ge...
Iterator<?> it = processIterator(); Slot slot = this.getSlot(); slot.setIteratorResult(this.getMetaValueKey(), it);
111
47
158
<methods>public void <init>() ,public void afterProcess() ,public void beforeProcess() ,public void doRollback() throws java.lang.Exception,public void execute() throws java.lang.Exception,public java.lang.String getChainId() ,public java.lang.String getChainName() ,public T getCmpData(Class<T>) ,public T getContextBea...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptBooleanComponent.java
ScriptBooleanComponent
processBoolean
class ScriptBooleanComponent extends NodeBooleanComponent implements ScriptComponent { @Override public boolean processBoolean() throws Exception {<FILL_FUNCTION_BODY>} @Override public void loadScript(String script, String language) { ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNod...
ScriptExecuteWrap wrap = this.buildWrap(this); return (boolean) ScriptExecutorFactory.loadInstance() .getScriptExecutor(this.getRefNode().getLanguage()) .execute(wrap);
84
54
138
<methods>public non-sealed void <init>() ,public java.lang.Boolean getItemResultMetaValue(java.lang.Integer) ,public void process() throws java.lang.Exception,public abstract boolean processBoolean() throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptForComponent.java
ScriptForComponent
processFor
class ScriptForComponent extends NodeForComponent implements ScriptComponent { @Override public int processFor() throws Exception {<FILL_FUNCTION_BODY>} @Override public void loadScript(String script, String language) { ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script); ...
ScriptExecuteWrap wrap = this.buildWrap(this); return (int) ScriptExecutorFactory.loadInstance() .getScriptExecutor(this.getRefNode().getLanguage()) .execute(wrap);
84
54
138
<methods>public non-sealed void <init>() ,public java.lang.Integer getItemResultMetaValue(java.lang.Integer) ,public void process() throws java.lang.Exception,public abstract int processFor() throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/ScriptSwitchComponent.java
ScriptSwitchComponent
processSwitch
class ScriptSwitchComponent extends NodeSwitchComponent implements ScriptComponent { @Override public String processSwitch() throws Exception {<FILL_FUNCTION_BODY>} @Override public void loadScript(String script, String language) { ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(...
ScriptExecuteWrap wrap = this.buildWrap(this); return (String) ScriptExecutorFactory.loadInstance() .getScriptExecutor(this.getRefNode().getLanguage()) .execute(wrap);
84
54
138
<methods>public non-sealed void <init>() ,public java.lang.String getItemResultMetaValue(java.lang.Integer) ,public void process() throws java.lang.Exception,public abstract java.lang.String processSwitch() throws java.lang.Exception<variables>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/DeclComponentProxy.java
AopInvocationHandler
invoke
class AopInvocationHandler implements InvocationHandler { private DeclWarpBean declWarpBean; public AopInvocationHandler(DeclWarpBean declWarpBean) { this.declWarpBean = declWarpBean; } @Override public Object invoke(Object proxy, Method method, Object[] args) thro...
// 获取当前调用方法,是否在被代理的对象方法里面(根据@LiteFlowMethod这个标注去判断) // 如果在里面,则返回那个LiteFlowMethodBean,不在则返回null MethodWrapBean currentMethodWrapBean = declWarpBean.getMethodWrapBeanList().stream() .filter(methodWrapBean -> methodWrapBean.getLiteflowMethod().value().getMethodName(...
104
475
579
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/LiteFlowProxyUtil.java
LiteFlowProxyUtil
getUserClass
class LiteFlowProxyUtil { private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowProxyUtil.class); /** * 判断一个bean是否是声明式组件 */ public static boolean isDeclareCmp(Class<?> clazz) { // 查看bean里的method是否有方法标记了@LiteflowMethod标注 // 这里的bean有可能是cglib加强过的class,所以要先进行个判断 Class<?> targetClass = getUserCla...
if (clazz.getName().contains("$$")) { Class<?> superclass = clazz.getSuperclass(); if (superclass != null && superclass != Object.class) { return superclass; } } return clazz;
480
71
551
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java
LiteflowResponse
newResponse
class LiteflowResponse { private String chainId; private boolean success; private String code; private String message; private Exception cause; private Slot slot; public LiteflowResponse() { } public static LiteflowResponse newMainResponse(Slot slot) { return newResponse(slot, slot.getException()); ...
LiteflowResponse response = new LiteflowResponse(); response.setChainId(slot.getChainId()); if (e != null) { response.setSuccess(false); response.setCause(e); response.setMessage(response.getCause().getMessage()); response.setCode(response.getCause() instanceof LiteFlowException ? ((LiteFlowExce...
1,057
159
1,216
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java
Chain
execute
class Chain implements Executable{ private static final LFLog LOG = LFLoggerManager.getLogger(Chain.class); private String chainId; private Executable routeItem; private List<Condition> conditionList = new ArrayList<>(); private String el; private boolean isCompiled = true; public Chain(String chainName) ...
if (BooleanUtil.isFalse(isCompiled)) { LiteFlowChainELBuilder.buildUnCompileChain(this); } if (CollUtil.isEmpty(conditionList)) { throw new FlowSystemException("no conditionList in this chain[" + chainId + "]"); } Slot slot = DataBus.getSlot(slotIndex); try { // 设置主ChainName slot.setChainId(ch...
826
330
1,156
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Condition.java
Condition
getExecutableOne
class Condition implements Executable{ private String id; private String tag; /** * 可执行元素的集合 */ private final Map<String, List<Executable>> executableGroup = new HashMap<>(); /** * 当前所在的ChainName 如果对于子流程来说,那这个就是子流程所在的Chain */ private String currChainId; @Override public void execute(Integer slotInd...
List<Executable> list = getExecutableList(groupKey); if (CollUtil.isEmpty(list)) { return null; } else { return list.get(0); }
1,192
57
1,249
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/FallbackNode.java
FallbackNode
loadFallBackNode
class FallbackNode extends Node { // 原节点 id private String expectedNodeId; // 降级节点 private Node fallbackNode; public FallbackNode() { this.setType(NodeTypeEnum.FALLBACK); } public FallbackNode(String expectedNodeId) { this(); this.expectedNodeId = expectedNodeId; ...
if (ObjectUtil.isNotNull(this.fallbackNode)) { // 已经加载过了 return; } Slot slot = DataBus.getSlot(slotIndex); Condition curCondition = slot.getCurrentCondition(); if (ObjectUtil.isNull(curCondition)) { throw new FlowSystemException("The current e...
1,352
200
1,552
<methods>public void <init>() ,public void <init>(com.yomahub.liteflow.core.NodeComponent) ,public com.yomahub.liteflow.flow.element.Node clone() throws java.lang.CloneNotSupportedException,public void execute(java.lang.Integer) throws java.lang.Exception,public boolean getAccessResult() ,public java.lang.String getCla...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AbstractCondition.java
AbstractCondition
executeCondition
class AbstractCondition extends Condition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_ABSTRACT; } }
throw new ChainNotImplementedException(StrUtil.format("chain[{}] contains unimplemented variables, cannot be executed", this.getCurrChainId()));
71
43
114
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AndOrCondition.java
AndOrConditionPredicate
getItemResultMetaValue
class AndOrConditionPredicate implements Predicate<Executable> { private final Integer slotIndex; public AndOrConditionPredicate(Integer slotIndex) { this.slotIndex = slotIndex; } @Override public boolean test(Executable executable) { try { ...
Slot slot = DataBus.getSlot(slotIndex); String resultKey = StrUtil.format("{}_{}",this.getClass().getName(),this.hashCode()); return slot.getAndOrResult(resultKey);
190
60
250
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/CatchCondition.java
CatchCondition
executeCondition
class CatchCondition extends Condition { private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_CATCH; } pub...
Slot slot = DataBus.getSlot(slotIndex); try { Executable catchExecutable = this.getCatchItem(); if (ObjectUtil.isNull(catchExecutable)) { String errorInfo = "no catch item find"; throw new CatchErrorException(errorInfo); } catchExecutable.setCurrChainId(this.getCurrChainId()); catchExecutabl...
216
306
522
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/FinallyCondition.java
FinallyCondition
executeCondition
class FinallyCondition extends Condition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_FINALLY; } }
for (Executable executableItem : this.getExecutableList()) { executableItem.setCurrChainId(this.getCurrChainId()); executableItem.execute(slotIndex); }
69
57
126
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ForCondition.java
ForCondition
executeCondition
class ForCondition extends LoopCondition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_FOR; } public Node getForNode() { return (Node) th...
Slot slot = DataBus.getSlot(slotIndex); Node forNode = this.getForNode(); if (ObjectUtil.isNull(forNode)) { String errorInfo = StrUtil.format("[{}]:no for-node found", slot.getRequestId()); throw new NoForNodeException(errorInfo); } // 提前设置 chainId,避免无法在...
141
766
907
<methods>public non-sealed void <init>() ,public boolean isParallel() ,public void setBreakItem(com.yomahub.liteflow.flow.element.Executable) ,public void setDoExecutor(com.yomahub.liteflow.flow.element.Executable) ,public void setParallel(boolean) <variables>private boolean parallel
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IfCondition.java
IfCondition
executeCondition
class IfCondition extends Condition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_IF; } public Executable getTrueCaseExecutableItem() { return this.getExecutableOne(Co...
Executable ifItem = this.getIfItem(); // 提前设置 chainId,避免无法在 isAccess 方法中获取到 ifItem.setCurrChainId(this.getCurrChainId()); // 先去判断isAccess方法,如果isAccess方法都返回false,整个IF表达式不执行 if (!ifItem.isAccess(slotIndex)) { return; } // 先执行IF节点 ifItem.execute(slotIndex); // 拿到If执行过的结果 boolean ifResult = ifIt...
298
688
986
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IteratorCondition.java
IteratorCondition
executeCondition
class IteratorCondition extends LoopCondition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_ITERATOR; } public Node getIteratorNode() { r...
Slot slot = DataBus.getSlot(slotIndex); Node iteratorNode = this.getIteratorNode(); if (ObjectUtil.isNull(iteratorNode)) { String errorInfo = StrUtil.format("[{}]:no iterator-node found", slot.getRequestId()); throw new NoIteratorNodeException(errorInfo); } ...
150
877
1,027
<methods>public non-sealed void <init>() ,public boolean isParallel() ,public void setBreakItem(com.yomahub.liteflow.flow.element.Executable) ,public void setDoExecutor(com.yomahub.liteflow.flow.element.Executable) ,public void setParallel(boolean) <variables>private boolean parallel
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/LoopCondition.java
LoopCondition
setCurrLoopObject
class LoopCondition extends Condition { //判断循环是否并行执行,默认为false private boolean parallel = false; protected Executable getBreakItem() { return this.getExecutableOne(ConditionKey.BREAK_KEY); } public void setBreakItem(Executable breakNode) { this.addExecutable(ConditionKey.BREAK_KEY, ...
if (executableItem instanceof Chain) { ((Chain) executableItem).getConditionList().forEach(condition -> setCurrLoopObject(condition, obj)); } else if (executableItem instanceof Condition) { ((Condition) executableItem).getExecutableGroup() .forEach((key, valu...
1,221
130
1,351
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/NotCondition.java
NotCondition
executeCondition
class NotCondition extends Condition { private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override @SuppressWarnings("unchecked") public Boolean getItemResultMetaValue(Intege...
Executable item = this.getItem(); item.setCurrChainId(this.getCurrChainId()); item.execute(slotIndex); boolean flag = item.getItemResultMetaValue(slotIndex); LOG.info("the result of boolean component [{}] is [{}]", item.getId(), flag); Slot slot = DataBus.getSlot(slot...
255
146
401
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/PreCondition.java
PreCondition
executeCondition
class PreCondition extends Condition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_PRE; } }
for (Executable executableItem : this.getExecutableList()) { executableItem.setCurrChainId(this.getCurrChainId()); executableItem.execute(slotIndex); }
66
57
123
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/RetryCondition.java
RetryCondition
executeCondition
class RetryCondition extends ThenCondition{ private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); private Integer retryTimes; private Class<? extends Exception>[] retryForExceptions = new Class[] { Exception.class }; public Class<? extends Exception>[] getRetryForExceptions() { ...
int retryTimes = this.getRetryTimes() < 0 ? 0 : this.getRetryTimes(); List<Class<? extends Exception>> forExceptions = Arrays.asList(this.getRetryForExceptions()); for (int i = 0; i <= retryTimes; i ++) { try { if(i == 0) { super.executeCondition(...
500
319
819
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addFinallyCondition(com.yomahub.liteflow.flow.element.condition.FinallyCondition) ,public void addPreCondition(com.yomahub.liteflow.flow.element.condition.PreCondition) ,public void executeCond...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java
SwitchCondition
executeCondition
class SwitchCondition extends Condition { private final String TAG_PREFIX = "tag"; private final String TAG_FLAG = ":"; @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_SWIT...
// 获取switch node Node switchNode = this.getSwitchNode(); // 获取target List List<Executable> targetList = this.getTargetList(); // 提前设置 chainId,避免无法在 isAccess 方法中获取到 switchNode.setCurrChainId(this.getCurrChainId()); // 先去判断isAccess方法,如果isAccess方法都返回false,整个SWITCH表达式不执行 if (!switchNode.isAccess(slotInde...
310
763
1,073
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ThenCondition.java
ThenCondition
executeCondition
class ThenCondition extends Condition { @Override public ConditionTypeEnum getConditionType() { return ConditionTypeEnum.TYPE_THEN; } @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} @Override public void addExecutable(Executable executable) { if (executabl...
List<PreCondition> preConditionList = this.getPreConditionList(); List<FinallyCondition> finallyConditionList = this.getFinallyConditionList(); try { for (PreCondition preCondition : preConditionList) { preCondition.setCurrChainId(this.getCurrChainId()); preCondition.execute(slotIndex); } for ...
361
458
819
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/TimeoutCondition.java
TimeoutCondition
getCurrentExecutableId
class TimeoutCondition extends WhenCondition { @Override public void executeCondition(Integer slotIndex) throws Exception { try { super.executeCondition(slotIndex); } catch (WhenTimeoutException ex) { // 将 WhenTimeoutException 转换为 TimeoutException String errM...
// TimeoutCondition 只有一个 Executable Executable executable = this.getExecutableList().get(0); if (ObjectUtil.isNotNull(executable.getId())) { // 已经有 id 了 return executable.getId(); } // 定义 id switch (executable.getExecuteType()) { // ch...
206
179
385
<methods>public non-sealed void <init>() ,public void executeCondition(java.lang.Integer) throws java.lang.Exception,public com.yomahub.liteflow.enums.ConditionTypeEnum getConditionType() ,public java.lang.String getGroup() ,public java.lang.Integer getMaxWaitTime() ,public java.util.concurrent.TimeUnit getMaxWaitTimeU...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhenCondition.java
WhenCondition
executeAsyncCondition
class WhenCondition extends Condition { private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); // 只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行 private boolean ignoreError = false; // 只在when类型下有效,用于不同node进行同组合并,相同的组会进行合并,不同的组不会进行合并 // 此属性已弃用 private String group = LocalDefaultFlowConstant.DE...
// 获取并发执行策略 ParallelStrategyExecutor parallelStrategyExecutor = ParallelStrategyHelper.loadInstance().buildParallelExecutor(this.getParallelStrategy()); // 执行并发逻辑 parallelStrategyExecutor.execute(this, slotIndex);
744
68
812
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang....
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhileCondition.java
WhileCondition
executeCondition
class WhileCondition extends LoopCondition { @Override public void executeCondition(Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} private boolean getWhileResult(Integer slotIndex, int loopIndex) throws Exception { Executable whileItem = this.getWhileItem(); // 执行while组件 setLoopIndex(whileItem, l...
Executable whileItem = this.getWhileItem(); // 提前设置 chainId,避免无法在 isAccess 方法中获取到 whileItem.setCurrChainId(this.getCurrChainId()); // 先去判断isAccess方法,如果isAccess方法都返回false,整个WHILE表达式不执行 if (!whileItem.isAccess(slotIndex)) { return; } // 获得要循环的可执行对象 Executable executableItem = this.getDoExecutor(); ...
219
640
859
<methods>public non-sealed void <init>() ,public boolean isParallel() ,public void setBreakItem(com.yomahub.liteflow.flow.element.Executable) ,public void setDoExecutor(com.yomahub.liteflow.flow.element.Executable) ,public void setParallel(boolean) <variables>private boolean parallel
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/entity/CmpStep.java
CmpStep
equals
class CmpStep { private String nodeId; private String nodeName; private String tag; private CmpStepTypeEnum stepType; private Date startTime; private Date endTime; // 消耗的时间,毫秒为单位 private Long timeSpent; // 是否成功 private boolean success; // 有exception,success一定为false // 但是success为false,不一定有exception,...
if (ObjectUtil.isNull(obj)) { return false; } else { if (getClass() != obj.getClass()) { return false; } else { if (((CmpStep) obj).getNodeId().equals(this.getNodeId())) { return true; } else { return false; } } }
1,290
105
1,395
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutor.java
NodeExecutor
execute
class NodeExecutor { protected final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); /** * 执行器执行入口-若需要更大维度的执行方式可以重写该方法 */ public void execute(NodeComponent instance) throws Exception {<FILL_FUNCTION_BODY>} /** * 执行重试逻辑 - 子类通过实现该方法进行重试逻辑的控制 */ protected void retry(NodeComponent instance, int curr...
int retryCount = instance.getRetryCount(); List<Class<? extends Exception>> forExceptions = Arrays.asList(instance.getRetryForExceptions()); for (int i = 0; i <= retryCount; i++) { try { // 先执行一次 if (i == 0) { instance.execute(); } else { // 进入重试逻辑 retry(instance, i); } ...
202
283
485
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/executor/NodeExecutorHelper.java
Holder
buildNodeExecutor
class Holder { static final NodeExecutorHelper INSTANCE = new NodeExecutorHelper(); } /** * 获取帮助者的实例 * @return */ public static NodeExecutorHelper loadInstance() { // 外围类能直接访问内部类(不管是否是静态的)的私有变量 return Holder.INSTANCE; } public NodeExecutor buildNodeExecutor(Class<? extends NodeExecutor> nodeExecuto...
if (nodeExecutorClass == null) { // 此处使用默认的节点执行器进行执行 nodeExecutorClass = DefaultNodeExecutor.class; } NodeExecutor nodeExecutor = nodeExecutorMap.get(nodeExecutorClass); // 此处无需使用同步锁进行同步-因为即使同时创建了两个实例,但是添加到缓存中的只会存在一个且不会存在并发问题-具体是由ConcurrentMap保证 if (ObjectUtil.isNull(nodeExecutor)) { // 获取重试执行器实例 ...
127
198
325
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java
IdGeneratorHolder
init
class IdGeneratorHolder { private RequestIdGenerator requestIdGenerator; private static IdGeneratorHolder INSTANCE = new IdGeneratorHolder(); public static void init() {<FILL_FUNCTION_BODY>} public static IdGeneratorHolder getInstance() { return INSTANCE; } public String generate() { if (ObjectUtil.isNul...
try { LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); String requestIdGeneratorClass = liteflowConfig.getRequestIdGeneratorClass(); RequestIdGenerator requestIdGenerator; if (StrUtil.isBlank(requestIdGeneratorClass)) { requestIdGenerator = new DefaultRequestIdGenerator(); } else { ...
167
202
369
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/CompletableFutureExpand.java
Canceller
accept
class Canceller implements BiConsumer<Object, Throwable> { final Future<?> future; Canceller(Future<?> future) { this.future = future; } public void accept(Object ignore, Throwable ex) {<FILL_FUNCTION_BODY>} }
if (null == ex && null != future && !future.isDone()) { future.cancel(false); }
81
34
115
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/CompletableFutureTimeout.java
DaemonThreadFactory
timeoutAfter
class DaemonThreadFactory implements ThreadFactory { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setDaemon(true); t.setName("CompletableFutureDelayScheduler"); return t; } } static final ScheduledThreadPoolExecutor delayer; // 注意,这里使用一个线程就可以搞定 因为这个线程并不真...
CompletableFuture<T> result = new CompletableFuture<T>(); // timeout 时间后 抛出TimeoutException 类似于sentinel / watcher CompletableFutureTimeout.Delayer.delayer.schedule(() -> result.completeExceptionally(new TimeoutException()), timeout, unit); return result;
211
85
296
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/LoopFutureObj.java
LoopFutureObj
fail
class LoopFutureObj { private String executorName; private boolean success; private Exception ex; public static LoopFutureObj success(String executorName) { LoopFutureObj result = new LoopFutureObj(); result.setSuccess(true); result.setExecutorName(executorName); return...
LoopFutureObj result = new LoopFutureObj(); result.setSuccess(false); result.setExecutorName(executorName); result.setEx(ex); return result;
252
52
304
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/ParallelSupplier.java
ParallelSupplier
get
class ParallelSupplier implements Supplier<WhenFutureObj> { private static final LFLog LOG = LFLoggerManager.getLogger(ParallelSupplier.class); private final Executable executableItem; private final String currChainId; private final Integer slotIndex; public ParallelSupplier(Executable executableItem, String ...
try { executableItem.setCurrChainId(currChainId); executableItem.execute(slotIndex); return WhenFutureObj.success(executableItem.getId()); } catch (Exception e) { return WhenFutureObj.fail(executableItem.getId(), e); }
156
86
242
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/WhenFutureObj.java
WhenFutureObj
success
class WhenFutureObj { private boolean success; private boolean timeout; private String executorId; private Exception ex; public static WhenFutureObj success(String executorId) {<FILL_FUNCTION_BODY>} public static WhenFutureObj fail(String executorId, Exception ex) { WhenFutureObj result = new WhenFutureOb...
WhenFutureObj result = new WhenFutureObj(); result.setSuccess(true); result.setTimeout(false); result.setExecutorId(executorId); return result;
402
54
456
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/AllOfParallelExecutor.java
AllOfParallelExecutor
execute
class AllOfParallelExecutor extends ParallelStrategyExecutor { @Override public void execute(WhenCondition whenCondition, Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} // 在 allOf 这个场景中,不需要过滤 @Override protected Stream<Executable> filterAccess(Stream<Executable> stream, Integer slotInd...
// 获取所有 CompletableFuture 任务 List<CompletableFuture<WhenFutureObj>> whenAllTaskList = this.getWhenAllTaskList(whenCondition, slotIndex); // 把这些 CompletableFuture 通过 allOf 合成一个 CompletableFuture,表明完成所有任务 CompletableFuture<?> specifyTask = CompletableFuture.allOf(whenAllTaskList.toArray...
107
136
243
<methods>public non-sealed void <init>() ,public abstract void execute(com.yomahub.liteflow.flow.element.condition.WhenCondition, java.lang.Integer) throws java.lang.Exception<variables>protected final com.yomahub.liteflow.log.LFLog LOG
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/AnyOfParallelExecutor.java
AnyOfParallelExecutor
execute
class AnyOfParallelExecutor extends ParallelStrategyExecutor { @Override public void execute(WhenCondition whenCondition, Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} }
// 获取所有 CompletableFuture 任务 List<CompletableFuture<WhenFutureObj>> whenAllTaskList = this.getWhenAllTaskList(whenCondition, slotIndex); // 把这些 CompletableFuture 通过 anyOf 合成一个 CompletableFuture,表明完成任一任务 CompletableFuture<?> specifyTask = CompletableFuture.anyOf(whenAllTaskList.toArray...
51
137
188
<methods>public non-sealed void <init>() ,public abstract void execute(com.yomahub.liteflow.flow.element.condition.WhenCondition, java.lang.Integer) throws java.lang.Exception<variables>protected final com.yomahub.liteflow.log.LFLog LOG
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyHelper.java
Holder
getParallelStrategyExecutor
class Holder { static final ParallelStrategyHelper INSTANCE = new ParallelStrategyHelper(); } public static ParallelStrategyHelper loadInstance() { return ParallelStrategyHelper.Holder.INSTANCE; } private ParallelStrategyExecutor getParallelStrategyExecutor(ParallelStrategyEnum paral...
try { ParallelStrategyExecutor strategyExecutor = strategyExecutorMap.get(parallelStrategyEnum); if (ObjUtil.isNotNull(strategyExecutor)) return strategyExecutor; Class<ParallelStrategyExecutor> executorClass = (Class<ParallelStrategyExecutor>) Class.forName(parallelStrateg...
91
161
252
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/SpecifyParallelExecutor.java
SpecifyParallelExecutor
execute
class SpecifyParallelExecutor extends ParallelStrategyExecutor { @Override public void execute(WhenCondition whenCondition, Integer slotIndex) throws Exception {<FILL_FUNCTION_BODY>} }
String currChainId = whenCondition.getCurrChainId(); // 设置 whenCondition 参数 this.setWhenConditionParams(whenCondition); // 获取 WHEN 所需线程池 ExecutorService parallelExecutor = getWhenExecutorService(whenCondition); // 指定完成的任务 CompletableFuture<?> specifyTask; ...
51
697
748
<methods>public non-sealed void <init>() ,public abstract void execute(com.yomahub.liteflow.flow.element.condition.WhenCondition, java.lang.Integer) throws java.lang.Exception<variables>protected final com.yomahub.liteflow.log.LFLog LOG
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/log/LFLoggerManager.java
LFLoggerManager
getLogger
class LFLoggerManager { private static final Map<String, LFLog> logMap = new HashMap<>(); private static final TransmittableThreadLocal<String> requestIdTL = new TransmittableThreadLocal<>(); public static LFLog getLogger(Class<?> clazz){<FILL_FUNCTION_BODY>} public static void setRequestId(String r...
if (logMap.containsKey(clazz.getName())){ return logMap.get(clazz.getName()); }else{ Logger log = LoggerFactory.getLogger(clazz.getName()); LFLog lfLog = new LFLog(log); logMap.put(clazz.getName(), lfLog); return lfLog; }
158
97
255
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/CompStatistics.java
CompStatistics
compareTo
class CompStatistics implements Comparable<CompStatistics> { private String componentClazzName; private long timeSpent; private long memorySpent; private long recordTime; public CompStatistics(String componentClazzName, long timeSpent) { this.componentClazzName = componentClazzName; this.timeSpent = timeS...
if (o != null) { return this.recordTime >= o.getRecordTime() ? -1 : 1; } return 1;
306
43
349
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorBus.java
MonitorBus
printStatistics
class MonitorBus { private LiteflowConfig liteflowConfig; private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); private final ConcurrentHashMap<String, BoundedPriorityBlockingQueue<CompStatistics>> statisticsMap = new ConcurrentHashMap<>(); private final ScheduledExecutorService printLogSchedule...
try { Map<String, BigDecimal> compAverageTimeSpent = new HashMap<String, BigDecimal>(); for (Entry<String, BoundedPriorityBlockingQueue<CompStatistics>> entry : statisticsMap.entrySet()) { long totalTimeSpent = 0; for (CompStatistics statistics : entry.getValue()) { totalTimeSpent += statistics.g...
482
538
1,020
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorFile.java
MonitorFile
reloadRule
class MonitorFile { private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); private final Set<String> PATH_SET = new HashSet<>(); public static MonitorFile getInstance() { return Singleton.get(MonitorFile.class); } /** * 添加监听文件路径 * @param path 文件路径 */ public void addMonitorFilePath(Strin...
try { FlowExecutorHolder.loadInstance().reloadRule(); } catch (Exception e) { LOG.error("reload rule error", e); }
518
45
563
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/base/BaseJsonFlowParser.java
BaseJsonFlowParser
parse
class BaseJsonFlowParser implements FlowParser { private final Set<String> CHAIN_NAME_SET = new CopyOnWriteArraySet<>(); public void parse(String content) throws Exception { parse(ListUtil.toList(content)); } @Override public void parse(List<String> contentList) throws Exception {<FILL_FUNCTION_BODY>} /** ...
if (CollectionUtil.isEmpty(contentList)) { return; } List<JsonNode> jsonObjectList = ListUtil.toList(); for (String content : contentList) { JsonNode flowJsonNode = JsonUtil.parseObject(content); jsonObjectList.add(flowJsonNode); } ParserHelper.parseNodeJson(jsonObjectList); ParserHelper.parseC...
133
127
260
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/base/BaseXmlFlowParser.java
BaseXmlFlowParser
parse
class BaseXmlFlowParser implements FlowParser { private final Set<String> CHAIN_NAME_SET = new HashSet<>(); public void parse(String content) throws Exception { parse(ListUtil.toList(content)); } @Override public void parse(List<String> contentList) throws Exception {<FILL_FUNCTION_BODY>} /** * 解析一个 chain...
if (CollectionUtil.isEmpty(contentList)) { return; } List<Document> documentList = ListUtil.toList(); for (String content : contentList) { Document document = DocumentHelper.parseText(content); documentList.add(document); } ParserHelper.parseNodeDocument(documentList); ParserHelper.parseChainDo...
125
117
242
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/base/BaseYmlFlowParser.java
BaseYmlFlowParser
parse
class BaseYmlFlowParser implements FlowParser { private final Set<String> CHAIN_NAME_SET = new HashSet<>(); public void parse(String content) throws Exception { parse(ListUtil.toList(content)); } @Override public void parse(List<String> contentList) throws Exception {<FILL_FUNCTION_BODY>} protected JsonNode...
if (CollectionUtil.isEmpty(contentList)) { return; } List<JsonNode> jsonObjectList = ListUtil.toList(); for (String content : contentList) { JsonNode ruleObject = convertToJson(content); jsonObjectList.add(ruleObject); } Consumer<JsonNode> parseOneChainConsumer = this::parseOneChain; ParserHel...
195
142
337
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/ClassParserFactory.java
ClassParserFactory
forName
class ClassParserFactory implements FlowParserFactory { @Override public BaseJsonFlowParser createJsonELParser(String path) { Class<?> c = forName(path); return (JsonFlowELParser) ContextAwareHolder.loadContextAware().registerBean(c); } @Override public BaseXmlFlowParser createXmlELParser(String path) { Cl...
try { return Class.forName(path); } catch (ClassNotFoundException e) { throw new RuntimeException(e); }
219
45
264
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/FlowParserProvider.java
FlowParserProvider
lookup
class FlowParserProvider { private static final LFLog LOG = LFLoggerManager.getLogger(FlowExecutor.class); private static final FlowParserFactory LOCAL_PARSER_FACTORY = new LocalParserFactory(); /** * 使用 map 枚举不同类型的 Parser,用于解耦如下的 if 判断 <pre> * if (ReUtil.isMatch(LOCAL_XML_CONFIG_REGEX, path)) { * return f...
// 自定义类必须实现以上实现类,否则报错 String errorMsg = StrUtil.format("can't support the format {}", path); // 本地文件 if (isLocalConfig(path)) { // 遍历枚举 map 找到对应 factory Predicate<String> dictKey = LOCAL_PARSER_DICT.keySet() .stream() .filter(key -> key.test(path)) .findFirst() .orElseThrow(() -> new Err...
1,363
434
1,797
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/NodeConvertHelper.java
NodeConvertHelper
convert
class NodeConvertHelper { /*script节点的修改/添加*/ public static void changeScriptNode(NodeSimpleVO nodeSimpleVO, String newValue) { // 有语言类型 if (StrUtil.isNotBlank(nodeSimpleVO.getLanguage())) { LiteFlowNodeBuilder.createScriptNode() .setId(nodeSimpleVO.getNodeId()) ...
// 不需要去理解这串正则,就是一个匹配冒号的 // 一定得是a:b,或是a:b:c...这种完整类型的字符串的 List<String> matchItemList = ReUtil.findAllGroup0("(?<=[^:]:)[^:]+|[^:]+(?=:[^:])", scriptKey); if (CollUtil.isEmpty(matchItemList)) { return null; } NodeSimpleVO nodeSimpleVO = new NodeSimpleVO(); ...
589
304
893
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfigGetter.java
LiteflowConfigGetter
get
class LiteflowConfigGetter { private static LiteflowConfig liteflowConfig; public static LiteflowConfig get() {<FILL_FUNCTION_BODY>} public static void clean() { liteflowConfig = null; } public static void setLiteflowConfig(LiteflowConfig liteflowConfig) { LiteflowConfigGetter.liteflowConfig = liteflowConf...
if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = ContextAwareHolder.loadContextAware().getBean(LiteflowConfig.class); // 这里liteflowConfig不可能为null // 如果在springboot环境,由于自动装配,所以不可能为null // 在spring环境,如果xml没配置,在FlowExecutor的init时候就已经报错了 // 非spring环境下,FlowExecutorHolder.loadInstance(config)的时候,会把co...
111
178
289
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/ScriptExecutor.java
ScriptExecutor
bindParam
class ScriptExecutor { public ScriptExecutor init(){ return this; } public abstract void load(String nodeId, String script); // 卸载脚本(不包含 node) public abstract void unLoad(String nodeId); // 获取该执行器下的所有 nodeId public abstract List<String> getNodeIds(); public Object execute(ScriptExecuteWrap wrap) throws E...
// 往脚本语言绑定表里循环增加绑定上下文的key // key的规则为自定义上下文的simpleName // 比如你的自定义上下文为AbcContext,那么key就为:abcContext // 这里不统一放一个map的原因是考虑到有些用户会调用上下文里的方法,而不是参数,所以脚本语言的绑定表里也是放多个上下文 DataBus.getContextBeanList(wrap.getSlotIndex()).forEach(tuple -> putConsumer.accept(tuple.get(0), tuple.get(1))); // 把wrap对象转换成元数据map Map<String...
372
373
745
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/ScriptExecutorFactory.java
ScriptExecutorFactory
loadInstance
class ScriptExecutorFactory { private static ScriptExecutorFactory scriptExecutorFactory; private final Map<String, ScriptExecutor> scriptExecutorMap = new HashMap<>(); private final String NONE_LANGUAGE = "none"; public static ScriptExecutorFactory loadInstance() {<FILL_FUNCTION_BODY>} public ScriptExecutor ...
if (ObjectUtil.isNull(scriptExecutorFactory)) { scriptExecutorFactory = new ScriptExecutorFactory(); } return scriptExecutorFactory;
433
40
473
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/jsr223/JSR223ScriptExecutor.java
JSR223ScriptExecutor
compile
class JSR223ScriptExecutor extends ScriptExecutor { protected final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); private ScriptEngine scriptEngine; private final Map<String, CompiledScript> compiledScriptMap = new CopyOnWriteHashMap<>(); @Override public ScriptExecutor init() { ScriptEngineManager...
if(scriptEngine == null) { LOG.error("script engine has not init"); } return ((Compilable) scriptEngine).compile(convertScript(script));
514
47
561
<methods>public non-sealed void <init>() ,public void bindParam(com.yomahub.liteflow.script.ScriptExecuteWrap, BiConsumer<java.lang.String,java.lang.Object>, BiConsumer<java.lang.String,java.lang.Object>) ,public abstract void cleanCache() ,public abstract java.lang.Object compile(java.lang.String) throws java.lang.Exc...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptBeanProxy.java
ScriptBeanProxy
getProxyScriptBean
class ScriptBeanProxy { private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); private final Object bean; private final Class<?> orignalClass; private final ScriptBean scriptBeanAnno; public ScriptBeanProxy(Object bean, Class<?> orignalClass, ScriptBean scriptBeanAnno) { this.bean = bean; t...
// 获取bean里所有的method,包括超类里的 List<String> methodNameList = Arrays.stream(orignalClass.getMethods()) .map(Method::getName) .collect(Collectors.toList()); // 首先看@ScriptBean标注里的includeMethodName属性 // 如果没有配置,则认为是全部的method,如果有配置,就取配置的method if (ArrayUtil.isNotEmpty(scriptBeanAnno.includeMethodName())) { m...
510
487
997
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptMethodProxy.java
ScriptMethodProxy
getProxyScriptMethod
class ScriptMethodProxy { /** * 被代理的 bean */ private final Object bean; /** * 原始的类 */ private final Class<?> orignalClass; private final List<Method> scriptMethods; public ScriptMethodProxy(Object bean, Class<?> orignalClass, List<Method> scriptMethods) { this.bean = bean; this.orignalClass = orig...
try { return new ByteBuddy().subclass(orignalClass) .name(buildClassName()) // 设置生成的类名 .implement(bean.getClass().getInterfaces()) .method(ElementMatchers.any()) .intercept(InvocationHandlerAdapter.of(new AopInvocationHandler(bean, scriptMethods))) .annotateType(orignalClass.getAnnotations())...
512
181
693
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/script/validator/ScriptValidator.java
ScriptValidator
validateScript
class ScriptValidator { private static final LFLog LOG = LFLoggerManager.getLogger(ScriptValidator.class); private static Map<ScriptTypeEnum, ScriptExecutor> scriptExecutors; static { List<ScriptExecutor> scriptExecutorList = new ArrayList<>(); scriptExecutors = new HashMap<>(); S...
// 未加载任何脚本模块 if(scriptExecutors.isEmpty()){ LOG.error("The loaded script modules not found."); return false; } // 指定脚本语言未加载 if (scriptType != null && !scriptExecutors.containsKey(scriptType)) { LOG.error(StrUtil.format("Specified script langu...
481
278
759
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java
DataBus
offerIndex
class DataBus { private static final LFLog LOG = LFLoggerManager.getLogger(DataBus.class); public static AtomicInteger OCCUPY_COUNT = new AtomicInteger(0); /** * 这里为什么采用ConcurrentHashMap作为slot存放的容器? * 因为ConcurrentHashMap的随机取值复杂度也和数组一样为O(1),并且没有并发问题,还有自动扩容的功能 * 用数组的话,扩容涉及copy,线程安全问题还要自己处理 */ private stati...
try { // 这里有没有并发问题? // 没有,因为QUEUE的类型为ConcurrentLinkedQueue,并发情况下,每次取到的index不会相同 // 当然前提是QUEUE里面的值不会重复,但是这个是由其他机制来保证的 Integer slotIndex = QUEUE.poll(); if (ObjectUtil.isNull(slotIndex)) { // 只有在扩容的时候需要用到synchronized重量级锁 // 扩一次容,增强原来size的0.75,因为初始slot容量为1024,从某种层面来说,即便并发很大。但是扩容的次数不会很多。 // 因...
1,003
505
1,508
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java
DefaultContext
putDataMap
class DefaultContext { private final ConcurrentHashMap<String, Object> dataMap = new ConcurrentHashMap<>(); private <T> void putDataMap(String key, T t) {<FILL_FUNCTION_BODY>} public boolean hasData(String key) { return dataMap.containsKey(key); } public <T> T getData(String key) { return (T) dataMap.get(k...
if (ObjectUtil.isNull(t)) { throw new NullParamException("data can't accept null param"); } dataMap.put(key, t);
144
48
192
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/CmpAroundAspectHolder.java
CmpAroundAspectHolder
loadCmpAroundAspect
class CmpAroundAspectHolder { private static CmpAroundAspect cmpAroundAspect; public static CmpAroundAspect loadCmpAroundAspect() {<FILL_FUNCTION_BODY>} public static void clean() { cmpAroundAspect = null; } }
if (ObjectUtil.isNull(cmpAroundAspect)) { List<CmpAroundAspect> list = new ArrayList<>(); ServiceLoader.load(CmpAroundAspect.class).forEach(list::add); list.sort(Comparator.comparingInt(CmpAroundAspect::priority)); cmpAroundAspect = list.get(0); } return cmpAroundAspect;
82
115
197
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/ContextAwareHolder.java
ContextAwareHolder
loadContextAware
class ContextAwareHolder { private static ContextAware contextAware; public static ContextAware loadContextAware() {<FILL_FUNCTION_BODY>} public static void clean() { contextAware = null; } }
if (ObjectUtil.isNull(contextAware)) { List<ContextAware> list = new ArrayList<>(); ServiceLoader.load(ContextAware.class).forEach(list::add); list.sort(Comparator.comparingInt(ContextAware::priority)); contextAware = list.get(0); } return contextAware;
65
98
163
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/ContextCmpInitHolder.java
ContextCmpInitHolder
loadContextCmpInit
class ContextCmpInitHolder { private static ContextCmpInit contextCmpInit; public static ContextCmpInit loadContextCmpInit() {<FILL_FUNCTION_BODY>} public static void clean() { contextCmpInit = null; } }
if (ObjectUtil.isNull(contextCmpInit)) { List<ContextCmpInit> list = new ArrayList<>(); ServiceLoader.load(ContextCmpInit.class).forEach(list::add); list.sort(Comparator.comparingInt(ContextCmpInit::priority)); contextCmpInit = list.get(0); } return contextCmpInit;
71
104
175
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/DeclComponentParserHolder.java
DeclComponentParserHolder
loadDeclComponentParser
class DeclComponentParserHolder { private static DeclComponentParser declComponentParser; public static DeclComponentParser loadDeclComponentParser(){<FILL_FUNCTION_BODY>} }
if (ObjectUtil.isNull(declComponentParser)) { List<DeclComponentParser> list = new ArrayList<>(); ServiceLoader.load(DeclComponentParser.class).forEach(list::add); list.sort(Comparator.comparingInt(DeclComponentParser::priority)); declComponentParser = list.get(0...
46
94
140
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/LiteflowComponentSupportHolder.java
LiteflowComponentSupportHolder
loadLiteflowComponentSupport
class LiteflowComponentSupportHolder { private static LiteflowComponentSupport liteflowComponentSupport; public static LiteflowComponentSupport loadLiteflowComponentSupport() {<FILL_FUNCTION_BODY>} public static void clean() { liteflowComponentSupport = null; } }
if (ObjectUtil.isNull(liteflowComponentSupport)) { List<LiteflowComponentSupport> list = new ArrayList<>(); ServiceLoader.load(LiteflowComponentSupport.class).forEach(list::add); list.sort(Comparator.comparingInt(LiteflowComponentSupport::priority)); liteflowComponentSupport = list.get(0); } return l...
77
110
187
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/holder/PathContentParserHolder.java
PathContentParserHolder
loadContextAware
class PathContentParserHolder { private static PathContentParser pathContentParser; public static PathContentParser loadContextAware() {<FILL_FUNCTION_BODY>} public static void clean() { pathContentParser = null; } }
if (ObjectUtil.isNull(pathContentParser)) { List<PathContentParser> list = new ArrayList<>(); ServiceLoader.load(PathContentParser.class).forEach(list::add); list.sort(Comparator.comparingInt(PathContentParser::priority)); pathContentParser = list.get(0); } return pathContentParser;
65
98
163
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalDeclComponentParser.java
LocalDeclComponentParser
parseDeclBean
class LocalDeclComponentParser implements DeclComponentParser { @Override public List<DeclWarpBean> parseDeclBean(Class<?> clazz) { throw new NotSupportDeclException("the declaration component is not supported in non-spring environment."); } @Override public List<DeclWarpBean> parseDeclBean...
throw new NotSupportDeclException("the declaration component is not supported in non-spring environment.");
131
24
155
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java
LocalPathContentParser
parseContent
class LocalPathContentParser implements PathContentParser { private final static String FILE_URL_PREFIX = "file:"; private final static String CLASSPATH_URL_PREFIX = "classpath:"; @Override public List<String> parseContent(List<String> pathList) throws Exception {<FILL_FUNCTION_BODY>} @Override public List<St...
if (CollectionUtil.isEmpty(pathList)) { throw new ConfigErrorException("rule source must not be null"); } List<String> absolutePathList = PathMatchUtil.searchAbsolutePath(pathList); List<String> contentList = new ArrayList<>(); for (String path : absolutePathList) { if (FileUtil.isAbsolutePath(path) ...
376
225
601
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java
Holder
getExecutorService
class Holder { static final ExecutorHelper INSTANCE = new ExecutorHelper(); } public static ExecutorHelper loadInstance() { return Holder.INSTANCE; } /** * * <p> * @param pool 需要关闭的线程组. */ public void shutdownAwaitTermination(ExecutorService pool) { shutdownAwaitTermination(pool, 60L); } /** ...
try { String key; if (StrUtil.isBlank(conditionHash)){ key = clazz; }else{ key = StrUtil.format("{}_{}", clazz, conditionHash); } ExecutorService executorServiceFromCache = executorServiceMap.get(key); if (ObjectUtil.isNotNull(executorServiceFromCache)) { return executorServiceFromCach...
873
253
1,126
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultMainExecutorBuilder.java
LiteFlowDefaultMainExecutorBuilder
buildExecutor
class LiteFlowDefaultMainExecutorBuilder implements ExecutorBuilder { @Override public ExecutorService buildExecutor() {<FILL_FUNCTION_BODY>} }
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); // 只有在非spring的场景下liteflowConfig才会为null if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = new LiteflowConfig(); } return buildDefaultExecutor(liteflowConfig.getMainExecutorWorks(), liteflowConfig.getMainExecutorWorks()*2, 200, "main-th...
42
118
160
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultParallelLoopExecutorBuilder.java
LiteFlowDefaultParallelLoopExecutorBuilder
buildExecutor
class LiteFlowDefaultParallelLoopExecutorBuilder implements ExecutorBuilder { @Override public ExecutorService buildExecutor() {<FILL_FUNCTION_BODY>} }
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); // 只有在非spring的场景下liteflowConfig才会为null if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = new LiteflowConfig(); } return buildDefaultExecutor(liteflowConfig.getParallelMaxWorkers(), liteflowConfig.get...
44
123
167
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultWhenExecutorBuilder.java
LiteFlowDefaultWhenExecutorBuilder
buildExecutor
class LiteFlowDefaultWhenExecutorBuilder implements ExecutorBuilder { @Override public ExecutorService buildExecutor() {<FILL_FUNCTION_BODY>} }
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); // 只有在非spring的场景下liteflowConfig才会为null if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = new LiteflowConfig(); } return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhe...
42
123
165
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/BoundedPriorityBlockingQueue.java
BoundedPriorityBlockingQueue
offer
class BoundedPriorityBlockingQueue<E> extends PriorityBlockingQueue<E> { private static final long serialVersionUID = -1; // 容量 private final int capacity; private final Comparator<? super E> comparator; public BoundedPriorityBlockingQueue(int capacity) { this(capacity, null); } /** * 构造 * @param capa...
if (size() >= capacity) { E head = peek(); if (this.comparator().compare(e, head) <= 0) { return true; } // 当队列满时,就要淘汰顶端队列 poll(); } return super.offer(e);
531
86
617
<methods>public void <init>() ,public void <init>(int) ,public void <init>(Collection<? extends E>) ,public void <init>(int, Comparator<? super E>) ,public boolean add(E) ,public void clear() ,public Comparator<? super E> comparator() ,public boolean contains(java.lang.Object) ,public int drainTo(Collection<? super E>)...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/CopyOnWriteHashMap.java
CopyOnWriteHashMap
duplicate
class CopyOnWriteHashMap<K, V> extends ConcurrentHashMap<K, V> { volatile ConcurrentHashMap<K, V> view; private ConcurrentHashMap<K, V> duplicate(ConcurrentHashMap<K, V> original) {<FILL_FUNCTION_BODY>} public CopyOnWriteHashMap(ConcurrentHashMap<K, V> that) { this.view = duplicate(that); } public CopyOnWrit...
// SUBTLETY: note that original.entrySet() grabs the entire contents of the // original Map in a // single call. This means that if the original map is Thread-safe or another // CopyOnWriteHashMap, // we can safely iterate over the list of entries. return new ConcurrentHashMap<>(original);
789
87
876
<methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends K,? extends V>) ,public void <init>(int, float) ,public void <init>(int, float, int) ,public void clear() ,public V compute(K, BiFunction<? super K,? super V,? extends V>) ,public V computeIfAbsent(K, Function<? super K,? extends V...
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/ElRegexUtil.java
ElRegexUtil
replaceAbstractChain
class ElRegexUtil { // java 注释的正则表达式 private static final String REGEX_COMMENT = "(?<!(:|@))\\/\\/.*|\\/\\*(\\s|.)*?\\*\\/"; // abstractChain 占位符正则表达式 private static final String REGEX_ABSTRACT_HOLDER = "\\{\\{\\s*([a-zA-Z_][a-zA-Z_\\d]*|\\d+)\\s*\\}\\}(?![\\s]*=)"; /** * 移除 el 表达式中的注释,支持 ja...
//匹配抽象chain的占位符 Pattern placeHolder = Pattern.compile(REGEX_ABSTRACT_HOLDER); Matcher placeHolderMatcher = placeHolder.matcher(abstractChain); while (placeHolderMatcher.find()) { //到implChain中找到对应的占位符实现 String holder = placeHolderMatcher.group(1); Pat...
523
246
769
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/JsonUtil.java
JsonUtil
parseObject
class JsonUtil { private static final LFLog LOG = LFLoggerManager.getLogger(JsonUtil.class); private static final ObjectMapper objectMapper = new ObjectMapper(); private JsonUtil() { } static { objectMapper.setTimeZone(TimeZone.getDefault()); } public static String toJsonString(Object object) { if (Obje...
if (StrUtil.isEmpty(json)) { return null; } try { return objectMapper.readValue(json, clazz); } catch (IOException e) { String errMsg = StrUtil.format("Error while parsing text [{}],reason: {}", json, e.getMessage()); LOG.error(e.getMessage(), e); throw new JsonProcessException(errMsg); }
366
111
477
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/LOGOPrinter.java
LOGOPrinter
print
class LOGOPrinter { private static final LFLog LOG = LFLoggerManager.getLogger(LOGOPrinter.class); /** * LiteFlow 当前版本号 */ private static final String VERSION_NO = getVersion(); public static void print() {<FILL_FUNCTION_BODY>} private static String getVersion() { return Optional.ofNullable(LOGOPrinter.c...
StringBuilder str = new StringBuilder("\n"); str.append( "================================================================================================\n"); str.append(" _ ___ _____ _____ _____ _ _____ __\n"); str.append(" | | |_ _|_ _| ____| | ___| | / _ \\ \\ / /\...
130
325
455
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/LimitQueue.java
LimitQueue
offer
class LimitQueue<E> implements Queue<E> { /** * 队列长度,实例化类的时候指定 */ private int limit; Queue<E> queue = new ConcurrentLinkedQueue<>(); public LimitQueue(int limit) { this.limit = limit; } @Override public boolean offer(E e) {<FILL_FUNCTION_BODY>} @Override public E poll() { return queue.poll(); } ...
if (queue.size() >= limit) { // 如果超出长度,入队时,先出队 queue.poll(); } return queue.offer(e);
554
53
607
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/LiteFlowExecutorPoolShutdown.java
LiteFlowExecutorPoolShutdown
destroy
class LiteFlowExecutorPoolShutdown { private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowExecutorPoolShutdown.class); public void destroy() throws Exception {<FILL_FUNCTION_BODY>} }
ExecutorService executorService = ContextAwareHolder.loadContextAware().getBean("whenExecutors"); LOG.info("Start closing the liteflow-when-calls..."); ExecutorHelper.loadInstance().shutdownAwaitTermination(executorService); LOG.info("Succeed closing the liteflow-when-calls ok...");
62
93
155
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/PathMatchUtil.java
PathMatchUtil
searchAbsolutePath
class PathMatchUtil { public static List<String> searchAbsolutePath(List<String> pathList) {<FILL_FUNCTION_BODY>} private static void searchAbsolutePath(String baseDir, String path, List<String> absolutePathList) { AntPathMatcher pathMatcher = new AntPathMatcher(); File dir = new File(baseDir)...
List<String> absolutePathList = new ArrayList<>(); for (String path : pathList) { // 只对绝对路径进行处理 if(FileUtil.isAbsolutePath(path)) { if(!path.contains("*")) { absolutePathList.add(path); } else { ...
225
302
527
<no_super_class>
dromara_liteflow
liteflow/liteflow-core/src/main/java/com/yomahub/liteflow/util/RuleParsePluginUtil.java
RuleParsePluginUtil
parseIdKey
class RuleParsePluginUtil { private static final String CHAIN_XML_PATTERN = "<chain id=\"{}\" enable=\"{}\">{}</chain>"; private static final String NODE_ITEM_XML_PATTERN = "<node id=\"{}\" name=\"{}\" type=\"{}\" enable=\"{}\"><![CDATA[{}]]></node>"; private static final String NODE_ITEM_WITH_LANGUAGE_XML...
String[] idProp = idKey.split(StrPool.COLON); if (idProp.length == 2) { String id = idProp[0]; String enableStr = idProp[1]; return new Pair<>(Boolean.TRUE.toString().equalsIgnoreCase(enableStr), id); } return new Pair<>(Boolean.TRUE, idKey);
849
95
944
<no_super_class>
dromara_liteflow
liteflow/liteflow-el-builder/src/main/java/com/yomahub/liteflow/builder/el/AndELWrapper.java
AndELWrapper
toEL
class AndELWrapper extends ELWrapper { public AndELWrapper(ELWrapper... elWrappers){ this.addWrapper(elWrappers); } public AndELWrapper and(Object ... object){ ELWrapper[] wrapper = ELBus.convertToLogicOpt(object); this.addWrapper(wrapper); return this; } @Override...
checkMaxWaitSeconds(); // 根据depth是否为null,决定输出是否格式化 Integer sonDepth = depth == null ? null : depth + 1; StringBuilder sb = new StringBuilder(); processWrapperTabs(sb, depth); sb.append("AND("); processWrapperNewLine(sb, depth); // 处理子表达式的输出并串接 f...
234
238
472
<methods>public non-sealed void <init>() ,public com.yomahub.liteflow.builder.el.ELWrapper id(java.lang.String) ,public com.yomahub.liteflow.builder.el.ELWrapper tag(java.lang.String) ,public java.lang.String toEL() ,public java.lang.String toEL(boolean) <variables>private java.lang.String data,private java.lang.String...
dromara_liteflow
liteflow/liteflow-el-builder/src/main/java/com/yomahub/liteflow/builder/el/CatchELWrapper.java
CatchELWrapper
toEL
class CatchELWrapper extends ELWrapper { public CatchELWrapper(ELWrapper elWrapper){ this.addWrapper(elWrapper); } public CatchELWrapper doOpt(Object object){ ELWrapper elWrapper = ELBus.convertToNonLogicOpt(object); this.addWrapper(elWrapper); return this; } @Over...
checkMaxWaitSeconds(); Integer sonDepth = depth == null ? null : depth + 1; StringBuilder sb = new StringBuilder(); // 处理 CATCH() 语句的输出 processWrapperTabs(sb, depth); sb.append("CATCH("); processWrapperNewLine(sb, depth); sb.append(this.getElWrapperList...
237
274
511
<methods>public non-sealed void <init>() ,public com.yomahub.liteflow.builder.el.ELWrapper id(java.lang.String) ,public com.yomahub.liteflow.builder.el.ELWrapper tag(java.lang.String) ,public java.lang.String toEL() ,public java.lang.String toEL(boolean) <variables>private java.lang.String data,private java.lang.String...