Search in sources :

Example 1 with ModificationObserverBehavior

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();
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) ModificationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)

Example 2 with ModificationObserverBehavior

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);
}
Also used : ModificationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)

Example 3 with ModificationObserverBehavior

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);
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) InstantiationStack(org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext) ModificationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Aggregations

ModificationObserverBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)3 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)2 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)1 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)1 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)1 InstantiationStack (org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack)1