@Override public void parse(BpmnParse bpmnParse, BaseElement element) { super.parse(bpmnParse, element); createExecutionListenersOnScope(bpmnParse, ((FlowNode) element).getExecutionListeners(), findActivity(bpmnParse, element.getId())); }
protected void executeSynchronous(FlowNode flowNode) { CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(execution); // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Create any boundary events, sub process boundary events will be created from the activity behavior List<ExecutionEntity> boundaryEventExecutions = null; List<BoundaryEvent> boundaryEvents = null; if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { boundaryEventExecutions = createBoundaryEvents(boundaryEvents, execution); } } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); } else { executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); LOGGER.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId()); CommandContextUtil.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true); } }
protected void executeSynchronous(FlowNode flowNode) { CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(execution); // Execution listener if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); LOGGER.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId()); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); if (processEngineConfiguration != null && processEngineConfiguration.getEventDispatcher().isEnabled()) { processEngineConfiguration.getEventDispatcher().dispatchEvent( FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_STARTED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } try { activityBehavior.execute(execution); } catch (BpmnError error) { // re-throw business fault so that it can be caught by an Error Intermediate Event or Error Event Sub-Process in the process ErrorPropagation.propagateError(error, execution); } catch (RuntimeException e) { if (LogMDC.isMDCEnabled()) { LogMDC.putMDCExecution(execution); } throw e; } }
protected void executeMultiInstanceSynchronous(FlowNode flowNode) { // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } if (!hasMultiInstanceRootExecution(execution, flowNode)) { execution = createMultiInstanceRootExecution(execution); } // Create any boundary events, sub process boundary events will be created from the activity behavior List<ExecutionEntity> boundaryEventExecutions = null; List<BoundaryEvent> boundaryEvents = null; if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { boundaryEventExecutions = createBoundaryEvents(boundaryEvents, execution); } } // Execute the multi instance behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); } else { throw new FlowableException("Expected an activity behavior in flow node " + flowNode.getId()); } }
protected void handleActivityEnd(FlowNode flowNode) { // a process instance execution can never leave a flow node, but it can pass here whilst cleaning up // hence the check for NOT being a process instance if (!execution.isProcessInstanceType()) { if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_END); } if (execution.isActive() && !flowNode.getOutgoingFlows().isEmpty() && !(flowNode instanceof ParallelGateway) // Parallel gw takes care of its own history && !(flowNode instanceof InclusiveGateway) // Inclusive gw takes care of its own history && !(flowNode instanceof SubProcess) // Subprocess handling creates and destroys scoped execution. The execution taking the seq flow is different from the one entering && (!(flowNode instanceof Activity) || ((Activity) flowNode).getLoopCharacteristics() == null) // Multi instance root execution leaving the node isn't stored in history ) { // If no sequence flow: will be handled by the deletion of executions CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityEnd(execution, null); } if (!(execution.getCurrentFlowElement() instanceof SubProcess) && !(flowNode instanceof Activity && ((Activity) flowNode).hasMultiInstanceLoopCharacteristics())) { CommandContextUtil.getEventDispatcher(commandContext).dispatchEvent( FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_COMPLETED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } } }