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

2021-11-16  本文已影响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')}

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

上一篇 下一篇

猜你喜欢

热点阅读