use of org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior in project camunda-bpm-platform by camunda.
the class AbstractInstanceCancellationCmd method handleChildRemovalInScope.
protected void handleChildRemovalInScope(ExecutionEntity removedExecution) {
// TODO: the following should be closer to PvmAtomicOperationDeleteCascadeFireActivityEnd
// (note though that e.g. boundary events expect concurrent executions to be preserved)
//
// Idea: attempting to prune and synchronize on the parent is the default behavior when
// a concurrent child is removed, but scope activities implementing ModificationObserverBehavior
// override this default (and therefore *must* take care of reorganization themselves)
// notify the behavior that a concurrent execution has been removed
// must be set due to deleteCascade behavior
ActivityImpl activity = removedExecution.getActivity();
if (activity == null) {
return;
}
ScopeImpl flowScope = activity.getFlowScope();
PvmExecutionImpl scopeExecution = removedExecution.getParentScopeExecution(false);
PvmExecutionImpl executionInParentScope = removedExecution.isConcurrent() ? removedExecution : removedExecution.getParent();
if (flowScope.getActivityBehavior() != null && flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
// let child removal be handled by the scope itself
ModificationObserverBehavior behavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
behavior.destroyInnerInstance(executionInParentScope);
} else {
if (executionInParentScope.isConcurrent()) {
executionInParentScope.remove();
scopeExecution.tryPruneLastConcurrentChild();
scopeExecution.forceUpdate();
}
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior in project camunda-bpm-platform by camunda.
the class PvmExecutionImpl method executeActivitiesConcurrent.
/**
* Instantiates the given activity stack under this execution.
* Sets the variables for the execution responsible to execute the most deeply nested
* activity.
*
* @param activityStack The most deeply nested activity is the last element in the list
*/
public void executeActivitiesConcurrent(List<PvmActivity> activityStack, PvmActivity targetActivity, PvmTransition targetTransition, Map<String, Object> variables, Map<String, Object> localVariables, boolean skipCustomListeners, boolean skipIoMappings) {
ScopeImpl flowScope = null;
if (!activityStack.isEmpty()) {
flowScope = activityStack.get(0).getFlowScope();
} else if (targetActivity != null) {
flowScope = targetActivity.getFlowScope();
} else if (targetTransition != null) {
flowScope = targetTransition.getSource().getFlowScope();
}
PvmExecutionImpl propagatingExecution = null;
if (flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
ModificationObserverBehavior flowScopeBehavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
propagatingExecution = (PvmExecutionImpl) flowScopeBehavior.createInnerInstance(this);
} else {
propagatingExecution = createConcurrentExecution();
}
propagatingExecution.executeActivities(activityStack, targetActivity, targetTransition, variables, localVariables, skipCustomListeners, skipIoMappings);
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior in project camunda-bpm-platform by camunda.
the class PvmAtomicOperationActivityInitStackNotifyListenerStart method eventNotificationsCompleted.
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
super.eventNotificationsCompleted(execution);
execution.activityInstanceStarted();
ExecutionStartContext startContext = execution.getExecutionStartContext();
InstantiationStack instantiationStack = startContext.getInstantiationStack();
PvmExecutionImpl propagatingExecution = execution;
ActivityImpl activity = execution.getActivity();
if (activity.getActivityBehavior() instanceof ModificationObserverBehavior) {
ModificationObserverBehavior behavior = (ModificationObserverBehavior) activity.getActivityBehavior();
List<ActivityExecution> concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
propagatingExecution = (PvmExecutionImpl) concurrentExecutions.get(0);
}
// if the stack has been instantiated
if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetActivity() != null) {
// as if we are entering the target activity instance id via a transition
propagatingExecution.setActivityInstanceId(null);
// execute the target activity with this execution
startContext.applyVariables(propagatingExecution);
propagatingExecution.setActivity(instantiationStack.getTargetActivity());
propagatingExecution.performOperation(ACTIVITY_START_CREATE_SCOPE);
} else if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetTransition() != null) {
// as if we are entering the target activity instance id via a transition
propagatingExecution.setActivityInstanceId(null);
// execute the target transition with this execution
PvmTransition transition = instantiationStack.getTargetTransition();
startContext.applyVariables(propagatingExecution);
propagatingExecution.setActivity(transition.getSource());
propagatingExecution.setTransition((TransitionImpl) transition);
propagatingExecution.performOperation(TRANSITION_START_NOTIFY_LISTENER_TAKE);
} else {
// else instantiate the activity stack further
propagatingExecution.setActivity(null);
propagatingExecution.performOperation(ACTIVITY_INIT_STACK);
}
}
Aggregations