Search in sources :

Example 1 with InstantiationStack

use of org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityInitStackNotifyListenerReturn method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    super.eventNotificationsCompleted(execution);
    ExecutionStartContext startContext = execution.getExecutionStartContext();
    InstantiationStack instantiationStack = startContext.getInstantiationStack();
    // if the stack has been instantiated
    if (instantiationStack.getActivities().isEmpty()) {
        // done
        return;
    } else {
        // else instantiate the activity stack further
        execution.setActivity(null);
        execution.performOperation(ACTIVITY_INIT_STACK_AND_RETURN);
    }
}
Also used : InstantiationStack(org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)

Example 2 with InstantiationStack

use of org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityInitStack method execute.

public void execute(PvmExecutionImpl execution) {
    ExecutionStartContext executionStartContext = execution.getExecutionStartContext();
    InstantiationStack instantiationStack = executionStartContext.getInstantiationStack();
    List<PvmActivity> activityStack = instantiationStack.getActivities();
    PvmActivity currentActivity = activityStack.remove(0);
    PvmExecutionImpl propagatingExecution = execution;
    if (currentActivity.isScope()) {
        propagatingExecution = execution.createExecution();
        execution.setActive(false);
        propagatingExecution.setActivity(currentActivity);
        propagatingExecution.initialize();
    } else {
        propagatingExecution.setActivity(currentActivity);
    }
    // notify listeners for the instantiated activity
    propagatingExecution.performOperation(operationOnScopeInitialization);
}
Also used : InstantiationStack(org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 3 with InstantiationStack

use of org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack 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

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