08-20-2015 11:33 AM
activiti:delegateExpression as an alternative to activiti:classon both serviceTask's and taskListener's.activiti:class, one instance of a JavaDelegate is created for each serviceTask in a ProcessDefinition. When using activiti:delegateExpression, one instance of a JavaDelegate, peroid. This is as expected.serviceTask's which use different Expression's. For example:JavaDelegate:
@Component("processDefinitionBean")
public class ProcessDefinitionBean {
private Expression requiredVariable;
private Expression optionalVariable;
…
}
bpmn1.bpmn20.xml
…
<serviceTask id="serviceTask" name="Service task" activiti:delegateExpression="${processDefinitionBean}">
<extensionElements>
<activiti:field name="requiredVariable">
<activiti:expression>${requiredVariableValue}</activiti:expression>
</activiti:field>
<activiti:field name="optionalVariable">
<activiti:expression>${optionalVariableValue}</activiti:expression>
</activiti:field>
</serviceTask>
…
bpmn2.bpmn20.xml
…
<serviceTask id="serviceTask" name="Service task" activiti:delegateExpression="${processDefinitionBean}">
<extensionElements>
<activiti:field name="requiredVariable">
<activiti:expression>${requiredVariableValue}</activiti:expression>
</activiti:field>
</serviceTask>
…
bpmn1 is started, when it reaches the serviceTask it will initialise all three of the Expression's in the JavaDelegate. If an instance of bpmn2 is then started, when it reaches the serviceTask, the requiredVariable Expression is being set to the value in bpmn2, but the optionalVariable Expression is still set to the value from bpmn1. This is a pretty significant issue as it means that the processDefinitionBean is not in the state it expects to be in, and will either end up with a value it is not meant to have in it (should bpmn2 happen to set ${optionalVariableValue} somewhere along the way, or it will fall over because optionalVariableValue does not exist.activiti:class becuase there is one instance for each of the two serviceTask's, so there is no possibility that different combinations of activiti:field's can be set on the same isntance of a JavaDelegate.Expression's at the end of the exectute method in each of our JavaDelegate's - but I wonder if an official fix should be investigated (should this be considered a bug).
08-20-2015 06:52 PM
08-21-2015 05:25 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.