美文网首页
flowable入门(八)自定义表达式解析方法

flowable入门(八)自定义表达式解析方法

作者: 走码人 | 来源:发表于2021-11-16 11:14 被阅读0次

1、实现抽象类AbstractFlowableVariableExpressionFunction

org.flowable.common.engine.impl.el.function.AbstractFlowableVariableExpressionFunction
public class TestExpressionFunction extends AbstractFlowableVariableExpressionFunction {

    final static String FUNCTION_NAME = "test";
    final static String FUNCTION_PREFIX = "c";

    public TestExpressionFunction () {
        super(FUNCTION_NAME);
    }

    @Override
    protected List<String> getFunctionPrefixOptions() {
        //前缀的别名
        return Arrays.asList("custom", "c");
    }

    @Override
    protected String getFinalFunctionPrefix() {
        return FUNCTION_PREFIX;
    }

    @Override
    protected boolean isMultiParameterFunction() {
        return true;
    }

    @Override
    public String prefix() {
        //重新定义函数的前缀
        return "c";
    }

    public static Object test(String variableName) {
        LOGGER.info("orgCheck");
        // TDOD 此处编写业务验证的逻辑,省略十万八千字
        return true;
    }
}

2、注入

//ProcessEngineConfigurationImpl processEngineCfgImpl
List<FlowableFunctionDelegate> customFlowableFunctionDelegates = processEngineCfgImpl.getCustomFlowableFunctionDelegates();
// 增加至流程配置中
if (null == customFlowableFunctionDelegates) {
    customFlowableFunctionDelegates = new ArrayList<FlowableFunctionDelegate>();
}
customFlowableFunctionDelegates.add(new TestExpressionFunction(null));
        processEngineCfgImpl.setCustomFlowableFunctionDelegates(customFlowableFunctionDelegates);

3、调用的demo

${c:test('123')}

在工作流设计中即可配置使用自定义的函数了

相关文章

网友评论

      本文标题:flowable入门(八)自定义表达式解析方法

      本文链接:https://www.haomeiwen.com/subject/pchhtrtx.html