我有一个关于如何解决我手中的情况的问题。问题是,我试图定义一个自定义流程,以便重复特定功能,但使用“父亲”流程指定的动态表达式。让我们将自定义流程称为“B”,将调用 B Activity 的流程称为“A”,然后...在我的 A 流程中,我将 B 流程指定为最近在服务任务中使用的目标表达式“customExpression” B进程的。问题是我不知道如何在服务任务中使用这个“customExpression”。
在A流程中
<process id="A" name="A" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<callActivity id="callactivity1" name="Custom Service Task" calledElement="B">
<extensionElements>
<activiti:in sourceExpression="${customSpringService.execute(execution)}"></activiti:in>
</extensionElements>
</callActivity>
<sequenceFlow id="flow10" sourceRef="startevent1" targetRef="callactivity1"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow11" sourceRef="callactivity1" targetRef="endevent1"></sequenceFlow>
</process>
在B进程中
<process id="B" name="B" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<serviceTask id="serviceTask1" name="Service Task 1" activiti:expression="${customExpression}"></serviceTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow7" sourceRef="startevent1" targetRef="serviceTask1"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="serviceTask1" targetRef="endevent1"></sequenceFlow>
</process>
我希望能很好地解释自己...... 非常感谢您的支持。
https://forums.activiti.org/content/call-activity-expression-how 中已发布问题
最佳答案
最后,我尝试了 Mark(来自 activiti 论坛)提出的解决方案,它工作得很好......
这是服务的代码
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.impl.context.Context;
import org.springframework.stereotype.Component;
@Component("customService")
public class CustomService {
public void executeExpression(String expression, DelegateExecution execution) {
Context.getProcessEngineConfiguration().getExpressionManager()
.createExpression(expression).getValue(execution);
}
}
这是服务任务中的
<serviceTask id="customServiceTask_execution" name="Custom Service Task" activiti:expression="${customService.executeExpression("${accountService.getAccount(execution)}", execution)}"></serviceTask>
我没有直接指定“${accountService.getAccount(execution)}”作为方法参数,而是使用从父进程传递的变量。
关于java - 调用 Activity - 表达式 - 如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36626935/