org.camunda.bpm.engine.impl.pvm.runtime
Class LegacyBehavior

java.lang.Object
  extended by org.camunda.bpm.engine.impl.pvm.runtime.LegacyBehavior

public class LegacyBehavior
extends Object

This class encapsulates legacy runtime behavior for the process engine.

Since 7.3 the behavior of certain bpmn elements has changed slightly.

1. Some elements which did not used to be scopes are now scopes:

2. In certain situations, executions which were both scope and concurrent were created. This used to be the case if a scope execution already had a single scope child execution and then concurrency was introduced (by a on interrupting boundary event or a non-interrupting event subprocess). In that case the existing scope execution was made concurrent. Starting from 7.3 this behavior is considered legacy. The new behavior is that the existing scope execution will not be made concurrent, instead, a new, concurrent execution will be created and be interleaved between the parent and the existing scope execution.

Since:
7.3
Author:
Daniel Meyer

Constructor Summary
LegacyBehavior()
           
 
Method Summary
protected static boolean areEqualEventSubscriptions(EventSubscriptionEntity subscription1, EventSubscriptionEntity subscription2)
          Checks if the parameters are the same apart from the execution id
static void cancelConcurrentScope(PvmExecutionImpl execution, PvmActivity cancelledScopeActivity)
          Cancels an execution which is both concurrent and scope.
static Map<ScopeImpl,PvmExecutionImpl> createActivityExecutionMapping(List<PvmExecutionImpl> scopeExecutions, List<ScopeImpl> scopes)
          Creates an activity execution mapping, when the scope hierarchy and the execution hierarchy are out of sync.
static void destroyConcurrentScope(PvmExecutionImpl execution)
          Destroys a concurrent scope Execution.
static boolean destroySecondNonScope(PvmExecutionImpl execution)
          Destroy an execution for an activity that was previously not a scope and now is (e.g.
static PvmExecutionImpl determinePropagatingExecutionOnEnd(PvmExecutionImpl propagatingExecution, Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
          Tolerates the broken execution trees fixed with CAM-3727 where there may be more ancestor scope executions than ancestor flow scopes; In that case, the argument execution is removed, the parent execution of the argument is returned such that one level of mismatch is corrected.
protected static void ensureConcurrent(PvmExecutionImpl execution)
           
protected static void ensureConcurrentScope(PvmExecutionImpl execution)
           
protected static void ensureScope(PvmExecutionImpl execution)
           
static boolean eventSubprocessComplete(ActivityExecution scopeExecution)
           
static boolean eventSubprocessConcurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution)
           
protected static PvmExecutionImpl findCompensationThrowingAncestorExecution(PvmExecutionImpl execution)
           
static PvmExecutionImpl getScopeExecution(ScopeImpl scope, Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
          In case the process instance was migrated from a previous version, activities which are now parsed as scopes do not have scope executions.
protected static ScopeImpl getTopMostScope(List<ScopeImpl> scopes)
           
static boolean hasInvalidIntermediaryActivityId(PvmExecutionImpl execution)
          In general, only leaf executions have activity ids.
protected static boolean isActivityWrappedInMultiInstanceBody(ActivityImpl activity)
           
protected static boolean isAsync(ActivityImpl activity)
           
protected static boolean isAsyncJobDefinition(JobDefinitionEntity jobDefinition)
           
static boolean isCompensationThrowing(PvmExecutionImpl execution)
           
static boolean isCompensationThrowing(PvmExecutionImpl execution, Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
          Returns true if the given execution is in a compensation-throwing activity but there is no dedicated scope execution in the given mapping.
static boolean isConcurrentScope(PvmExecutionImpl propagatingExecution)
          Concurrent + scope executions are legacy and could occur in processes with non-interrupting boundary events or event subprocesses
protected static boolean isLegacyAsyncAtMultiInstance(PvmExecutionImpl execution)
          This returns true only if the provided execution has reached its wait state in a legacy engine version, because only in that case, it can be async and waiting at the inner activity wrapped by the miBody.
protected static boolean isLegacyBehaviorRequired(ActivityExecution scopeExecution)
          This method
protected static boolean isMultiInstanceInCompensation(ActivityImpl activity, PvmExecutionImpl scopeExecutionCandidate)
           
static void migrateMultiInstanceJobDefinitions(ProcessDefinitionEntity processDefinition, List<JobDefinitionEntity> jobDefinitions)
          When deploying an async job definition for an activity wrapped in an miBody, set the activity id to the miBody except the wrapped activity is marked as async.
static void parseCancelBoundaryEvent(ActivityImpl activity)
           
static void pruneConcurrentScope(PvmExecutionImpl execution)
          Prunes a concurrent scope.
static void removeLegacyNonScopesFromMapping(Map<ScopeImpl,PvmExecutionImpl> mapping)
          Remove all entries for legacy non-scopes given that the assigned scope execution is also responsible for another scope
static void removeLegacySubscriptionOnParent(ExecutionEntity execution, EventSubscriptionEntity eventSubscription)
          Required for migrating active sequential MI receive tasks.
static void repairMultiInstanceAsyncJob(ExecutionEntity execution)
          When executing an async job for an activity wrapped in an miBody, set the execution to the miBody except the wrapped activity is marked as async.
static void repairParentRelationships(Collection<ActivityInstanceImpl> values, String processInstanceId)
          This is relevant for GetActivityInstanceCmd where in case of legacy multi-instance execution trees, the default algorithm omits multi-instance activity instances.
static boolean signalCancelBoundaryEvent(String signalName)
          With prior versions, the boundary event was already executed when compensation was performed; Thus, after compensation completes, the execution is signalled waiting at the boundary event.
protected static
<T> boolean
valuesEqual(T value1, T value2)
           
protected static boolean wasNoScope(ActivityImpl activity, PvmExecutionImpl scopeExecutionCandidate)
          Determines whether the given scope was a scope in previous versions
protected static boolean wasNoScope72(ActivityImpl activity)
           
protected static boolean wasNoScope73(ActivityImpl activity, PvmExecutionImpl scopeExecutionCandidate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LegacyBehavior

public LegacyBehavior()
Method Detail

pruneConcurrentScope

public static void pruneConcurrentScope(PvmExecutionImpl execution)
Prunes a concurrent scope. This can only happen if (a) the process instance has been migrated from a previous version to a new version of the process engine This is an inverse operation to #createConcurrentScope(PvmExecutionImpl). See: javadoc of this class for note about concurrent scopes.

Parameters:
execution -

cancelConcurrentScope

public static void cancelConcurrentScope(PvmExecutionImpl execution,
                                         PvmActivity cancelledScopeActivity)
Cancels an execution which is both concurrent and scope. This can only happen if (a) the process instance has been migrated from a previous version to a new version of the process engine See: javadoc of this class for note about concurrent scopes.

Parameters:
execution - the concurrent scope execution to destroy
cancellingActivity - the activity that cancels the execution; it must hold that cancellingActivity's event scope is the scope the execution is responsible for

destroyConcurrentScope

public static void destroyConcurrentScope(PvmExecutionImpl execution)
Destroys a concurrent scope Execution. This can only happen if (a) the process instance has been migrated from a previous version to a 7.3+ version of the process engine See: javadoc of this class for note about concurrent scopes.

Parameters:
execution - the execution to destroy

eventSubprocessComplete

public static boolean eventSubprocessComplete(ActivityExecution scopeExecution)

eventSubprocessConcurrentChildExecutionEnded

public static boolean eventSubprocessConcurrentChildExecutionEnded(ActivityExecution scopeExecution,
                                                                   ActivityExecution endedExecution)

destroySecondNonScope

public static boolean destroySecondNonScope(PvmExecutionImpl execution)
Destroy an execution for an activity that was previously not a scope and now is (e.g. event subprocess)


isLegacyBehaviorRequired

protected static boolean isLegacyBehaviorRequired(ActivityExecution scopeExecution)
This method

Parameters:
scopeExecution -
isLegacyBehaviorTurnedOff -
Returns:

getScopeExecution

public static PvmExecutionImpl getScopeExecution(ScopeImpl scope,
                                                 Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
In case the process instance was migrated from a previous version, activities which are now parsed as scopes do not have scope executions. Use the flow scopes of these activities in order to find their execution. - For an event subprocess this is the scope execution of the scope in which the event subprocess is embeded in - For a multi instance sequential subprocess this is the multi instace scope body.

Parameters:
targetScope -
activityExecutionMapping -
Returns:

ensureConcurrentScope

protected static void ensureConcurrentScope(PvmExecutionImpl execution)

ensureConcurrent

protected static void ensureConcurrent(PvmExecutionImpl execution)

ensureScope

protected static void ensureScope(PvmExecutionImpl execution)

createActivityExecutionMapping

public static Map<ScopeImpl,PvmExecutionImpl> createActivityExecutionMapping(List<PvmExecutionImpl> scopeExecutions,
                                                                             List<ScopeImpl> scopes)
Creates an activity execution mapping, when the scope hierarchy and the execution hierarchy are out of sync.

Parameters:
scopeExecutions -
scopes -
Returns:

wasNoScope

protected static boolean wasNoScope(ActivityImpl activity,
                                    PvmExecutionImpl scopeExecutionCandidate)
Determines whether the given scope was a scope in previous versions


wasNoScope72

protected static boolean wasNoScope72(ActivityImpl activity)

wasNoScope73

protected static boolean wasNoScope73(ActivityImpl activity,
                                      PvmExecutionImpl scopeExecutionCandidate)

isMultiInstanceInCompensation

protected static boolean isMultiInstanceInCompensation(ActivityImpl activity,
                                                       PvmExecutionImpl scopeExecutionCandidate)

isLegacyAsyncAtMultiInstance

protected static boolean isLegacyAsyncAtMultiInstance(PvmExecutionImpl execution)
This returns true only if the provided execution has reached its wait state in a legacy engine version, because only in that case, it can be async and waiting at the inner activity wrapped by the miBody. In versions >= 7.3, the execution would reference the multi-instance body instead.


determinePropagatingExecutionOnEnd

public static PvmExecutionImpl determinePropagatingExecutionOnEnd(PvmExecutionImpl propagatingExecution,
                                                                  Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
Tolerates the broken execution trees fixed with CAM-3727 where there may be more ancestor scope executions than ancestor flow scopes; In that case, the argument execution is removed, the parent execution of the argument is returned such that one level of mismatch is corrected. Note that this does not necessarily skip the correct scope execution, since the broken parent-child relationships may be anywhere in the tree (e.g. consider a non-interrupting boundary event followed by a subprocess (i.e. scope), when the subprocess ends, we would skip the subprocess's execution).


isConcurrentScope

public static boolean isConcurrentScope(PvmExecutionImpl propagatingExecution)
Concurrent + scope executions are legacy and could occur in processes with non-interrupting boundary events or event subprocesses


removeLegacySubscriptionOnParent

public static void removeLegacySubscriptionOnParent(ExecutionEntity execution,
                                                    EventSubscriptionEntity eventSubscription)

Required for migrating active sequential MI receive tasks. These activities were formerly not scope, but are now. This has the following implications:

Before migration:

After migration:

Thus, this method removes the subscription on the miBody scope


areEqualEventSubscriptions

protected static boolean areEqualEventSubscriptions(EventSubscriptionEntity subscription1,
                                                    EventSubscriptionEntity subscription2)
Checks if the parameters are the same apart from the execution id


valuesEqual

protected static <T> boolean valuesEqual(T value1,
                                         T value2)

removeLegacyNonScopesFromMapping

public static void removeLegacyNonScopesFromMapping(Map<ScopeImpl,PvmExecutionImpl> mapping)
Remove all entries for legacy non-scopes given that the assigned scope execution is also responsible for another scope


getTopMostScope

protected static ScopeImpl getTopMostScope(List<ScopeImpl> scopes)

repairParentRelationships

public static void repairParentRelationships(Collection<ActivityInstanceImpl> values,
                                             String processInstanceId)
This is relevant for GetActivityInstanceCmd where in case of legacy multi-instance execution trees, the default algorithm omits multi-instance activity instances.


migrateMultiInstanceJobDefinitions

public static void migrateMultiInstanceJobDefinitions(ProcessDefinitionEntity processDefinition,
                                                      List<JobDefinitionEntity> jobDefinitions)
When deploying an async job definition for an activity wrapped in an miBody, set the activity id to the miBody except the wrapped activity is marked as async. Background: in <= 7.2 async job definitions were created for the inner activity, although the semantics are that they are executed before the miBody is entered


isAsync

protected static boolean isAsync(ActivityImpl activity)

isAsyncJobDefinition

protected static boolean isAsyncJobDefinition(JobDefinitionEntity jobDefinition)

isActivityWrappedInMultiInstanceBody

protected static boolean isActivityWrappedInMultiInstanceBody(ActivityImpl activity)

repairMultiInstanceAsyncJob

public static void repairMultiInstanceAsyncJob(ExecutionEntity execution)
When executing an async job for an activity wrapped in an miBody, set the execution to the miBody except the wrapped activity is marked as async. Background: in <= 7.2 async jobs were created for the inner activity, although the semantics are that they are executed before the miBody is entered


signalCancelBoundaryEvent

public static boolean signalCancelBoundaryEvent(String signalName)
With prior versions, the boundary event was already executed when compensation was performed; Thus, after compensation completes, the execution is signalled waiting at the boundary event.


parseCancelBoundaryEvent

public static void parseCancelBoundaryEvent(ActivityImpl activity)
See Also:
signalCancelBoundaryEvent(String)

hasInvalidIntermediaryActivityId

public static boolean hasInvalidIntermediaryActivityId(PvmExecutionImpl execution)

In general, only leaf executions have activity ids.

Exception to that rule: compensation throwing executions.

Legacy exception (<= 7.2) to that rule: miBody executions and parallel gateway executions

Returns:
true, if the argument is not a leaf and has an invalid (i.e. legacy) non-null activity id

isCompensationThrowing

public static boolean isCompensationThrowing(PvmExecutionImpl execution,
                                             Map<ScopeImpl,PvmExecutionImpl> activityExecutionMapping)
Returns true if the given execution is in a compensation-throwing activity but there is no dedicated scope execution in the given mapping.


isCompensationThrowing

public static boolean isCompensationThrowing(PvmExecutionImpl execution)

findCompensationThrowingAncestorExecution

protected static PvmExecutionImpl findCompensationThrowingAncestorExecution(PvmExecutionImpl execution)


Copyright © 2015 camunda services GmbH. All rights reserved.