ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
HistoryLevel historyLevel = configuration.getHistoryLevel();
if (historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE, this)) {
final HistoryEventProducer eventFactory = configuration.getHistoryEventProducer();
final HistoryEventHandler eventHandler = configuration.getHistoryEventHandler();
// publish start event for sub process instance
HistoryEvent hpise = eventFactory.createProcessInstanceStartEvt(subProcessInstance);
eventHandler.handleEvent(hpise);
// publish update event for current activity instance (containing the id of the sub process)
HistoryEvent haie = eventFactory.createActivityInstanceUpdateEvt(this, null);
eventHandler.handleEvent(haie);
}
return subProcessInstance;
}