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')}
在工作流设计中即可配置使用自定义的函数了
网友评论