您的位置:首页 > 教育 > 锐评 > 现在最新技术有哪些_旅游网站管理系统php_google引擎入口_百度运营推广

现在最新技术有哪些_旅游网站管理系统php_google引擎入口_百度运营推广

2026/2/6 8:08:59 来源:https://blog.csdn.net/wang0907/article/details/144295894  浏览:    关键词:现在最新技术有哪些_旅游网站管理系统php_google引擎入口_百度运营推广
现在最新技术有哪些_旅游网站管理系统php_google引擎入口_百度运营推广

写在前面

在实际的业务场景中,activiti所提供的基于uel表达式的网关表达式往往无法满足我们的需求,所以我们就需要根据具体的业务来定义自己的表达式,那么就需要自定义表达式的解析逻辑。本文就来看下如何实现。

1:正文

直接在这篇文章基础上来验证方案的可行性。
在经过网关时最终会执行到代码:

//org.activiti.engine.impl.el.JuelExpression.getValue
public Object getValue(VariableScope variableScope) {ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext(variableScope);try {ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext);Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation);return invocation.getInvocationResult();} catch (PropertyNotFoundException pnfe) {// ...}
}

其中代码Context.getProcessEngineConfiguration().getDelegateInterceptor()会获取一个org.activiti.engine.impl.interceptor.DelegateInterceptor的实例,默认返回的是DefaultDelegateInterceptor,接着执行handleInvocation方法来生成一个表达式true和false的结果,因此,我们只需要让getDelegateInterceptor方法返回自定义的DelegateInterceptor然后重写handleInvocation方法就可以了,而想要获取自定义的DelegateInterceptor类可以通过调用springProcessEngineConfiguration.setDelegateInterceptor(new HcDefaultDelegateInterceptor());完成,如下:

@Test
public void completeV1() {System.out.println("springProcessEngineConfiguration:" + springProcessEngineConfiguration);//        System.out.println("springExpressionManager:" + springExpressionManager);// 直属领导审批
//        taskService.complete("677507");// 部门领导审批
//        taskService.complete("680007");String taskId = "9b6ac294-b382-11ef-8cd0-989096ca675d";// 董事长审批
//        final Task task = taskService.createTaskQuery().taskId("c4f42bf8-b2ac-11ef-af73-989096ca675d").list().get(0);
//        Context.getProcessEngineConfiguration().setExpressionManager(null);//        60861b7e-b21a-11ef-b642-989096ca675d
//        runtimeService.removeVariable(task.getExecutionId(), "callEnd");// 这里必须删除老的任务相同变量名称的变量,不然设置新的任务变量降不生效taskService.removeVariable(taskId, "callEnd");Map<String, Object> objectMap = new HashMap<>();
//        objectMap.put("callEnd", 2); // 模拟用户不说再见的情况
//        taskService.complete("608c3601-b21a-11ef-b642-989096ca675d", objectMap);objectMap.put("callEnd", 2); // 模拟用户说再见的情况,流程就结束啦springProcessEngineConfiguration.setDelegateInterceptor(new HcDefaultDelegateInterceptor());taskService.complete(taskId, objectMap);}

HcDefaultDelegateInterceptor类如下:

public class HcDefaultDelegateInterceptor extends DefaultDelegateInterceptor {@Overridepublic void handleInvocation(DelegateInvocation invocation) {System.out.println("HcDefaultDelegateInterceptor.handleInvocation");
//        super.handleInvocation(invocation);final Class<DelegateInvocation> delegateInvocationClass = DelegateInvocation.class;try {// TODO 这里写业务逻辑判断条件的true和false,然后暴力访问设置到invocationResult中final Field invocationResult = delegateInvocationClass.getDeclaredField("invocationResult");invocationResult.setAccessible(true);invocationResult.set(invocation, false);
//            invocationResult.set(invocation, true);} catch (Exception e) {throw new RuntimeException(e);}}
}

执行自定义的业务逻辑获取true和false的结果后,设置到invocationResult属性中即可。比如这里写死设置false后,如果去完成任务的话则会抛出org.activiti.engine.ActivitiException: No outgoing sequence flow of the exclusive gateway 'exclusivegateway1' could be selected for continuing the process之类的错误:
在这里插入图片描述
就证明我们的代码生效了。

写在后面

参考文章列表

activiti学习之模拟聊天机器人(含结束监听)。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com