Thanks, Joram.
I've done simplest test with multi instance script task and the history log looks… a little bit unexpected:
ACT_HI_ACTINST
[table][tr][h]ID_[/h][h]PROC_DEF_ID_[/h][h]PROC_INST_ID_[/h][h]EXECUTION_ID_[/h][h]ACT_ID_[/h][/tr]
[tr][td]6[/td][td]testProcessA:1:4[/td][td]5[/td][td]5[/td][td]startevent1[/td][/tr]
[tr][td]10[/td][td]testProcessA:1:4[/td][td]5[/td][td]9[/td][td]scripttask1[/td][/tr]
[tr][td]26[/td][td]testProcessA:1:4[/td][td]5[/td][td]18[/td][td]scripttask1[/td][/tr]
[tr][td]31[/td][td]testProcessA:1:4[/td][td]5[/td][td]19[/td][td]scripttask1[/td][/tr]
[tr][td]34[/td][td]testProcessA:1:4[/td][td]5[/td][td]5[/td][td]endevent3[/td][/tr]
[/table]
ACT_HI_VARINST
[table][tr][h]ID_[/h][h]PROC_INST_ID_[/h][h]EXECUTION_ID_[/h][h]NAME_[/h][/tr]
[tr][td]7[/td][td]5[/td][td]5[/td][td]orderId[/td][/tr]
[tr][td]11[/td][td]5[/td][td]9[/td][td]nrOfInstances[/td][/tr]
[tr][td]13[/td][td]5[/td][td]9[/td][td]nrOfCompletedInstances[/td][/tr]
[tr][td]15[/td][td]5[/td][td]9[/td][td]nrOfActiveInstances[/td][/tr]
[tr][td]20[/td][td]5[/td][td]17[/td][td]loopCounter[/td][/tr]
[tr][td]24[/td][td]5[/td][td]18[/td][td]loopCounter[/td][/tr]
[tr][td]29[/td][td]5[/td][td]19[/td][td]loopCounter[/td][/tr]
[/table]
Execution "9" is a scope. If we would not have this executionId in ACT_HI_ACTINST then we will not know how to retrieve "nrOfCompletedInstances" by executionId.
On the other hand.. if we dont have execution "17" in ACT_HI_ACTINST then we dont know nothing about execution with loopCounter=0
/
And about executions:
In runtime I've got each of the three execution using breakpoint in some test method of my test bean.
I always use Context.getExecutionContext().getExecution() in my beans to use current execution, I actualy do not use execution as argument in processes.
It was surprise: the first execution was a ScopeExecution, the second and the third was ConcurrentExecutions.
I just try to modify MultiInstanceActivityBehavior from
[java]
if (loopCounter == 0) {
callCustomActivityStartListeners(execution);
innerActivityBehavior.execute(execution);
} else {
execution.executeActivity(activity);
}
[/java]
to
[java]
if (loopCounter == 0) {
callCustomActivityStartListeners(execution);
try {
Context.setExecutionContext((ExecutionEntity)execution);
innerActivityBehavior.execute(execution);
} finally {
Context.removeExecutionContext();
}
} else {
execution.executeActivity(activity);
}
[/java]
I'm not shure if that was correct to set Execution Context there, but after that Context.getExecutionContext().getExecution() returns ConcurrentExecutions for each parallel instances.