usedSubProcessDefinition = subProcessResolver.findSubProcess(subProcessElement);
}
// create the subprocess
ProcessInstance subProcessInstance = superProcessToken.createSubProcessInstance(usedSubProcessDefinition);
// fire the subprocess created event
fireEvent(Event.EVENTTYPE_SUBPROCESS_CREATED, executionContext);
// feed the readable variableInstances
if ((variableAccesses != null) && (!variableAccesses.isEmpty()))
{
ContextInstance superContextInstance = executionContext.getContextInstance();
ContextInstance subContextInstance = subProcessInstance.getContextInstance();
subContextInstance.setTransientVariables(superContextInstance.getTransientVariables());
// loop over all the variable accesses
for (VariableAccess variableAccess : variableAccesses)
{
// if this variable access is readable
if (variableAccess.isReadable())
{
// the variable is copied from the super process variable name
// to the sub process mapped name
String variableName = variableAccess.getVariableName();
Object value = superContextInstance.getVariable(variableName, superProcessToken);
String mappedName = variableAccess.getMappedName();
log.debug("copying super process var '" + variableName + "' to sub process var '" + mappedName + "': " + value);
if (value != null)
{
subContextInstance.setVariable(mappedName, value);
}
}
}
}
// send the signal to start the subprocess
subProcessInstance.signal();
}