Class PvmExecutionImpl

    • Field Detail

      • ignoreAsync

        protected transient boolean ignoreAsync
      • isStarting

        protected transient boolean isStarting
        true for process instances in the initial phase. Currently this controls that historic variable updates created during this phase receive the initial flag (see HistoricVariableUpdateEventEntity#isInitial).
      • activity

        protected transient ActivityImpl activity
        current activity
      • nextActivity

        protected transient PvmActivity nextActivity
        the activity which is to be started next
      • transition

        protected transient TransitionImpl transition
        the transition that is currently being taken
      • transitionsToTake

        protected transient java.util.List<PvmTransition> transitionsToTake
        A list of outgoing transitions from the current activity that are going to be taken
      • activityInstanceId

        protected java.lang.String activityInstanceId
        the unique id of the current activity instance
      • caseInstanceId

        protected java.lang.String caseInstanceId
        the id of a case associated with this execution
      • deleteRoot

        protected boolean deleteRoot
      • deleteReason

        protected java.lang.String deleteReason
      • externallyTerminated

        protected boolean externallyTerminated
      • isActive

        protected boolean isActive
        indicates if this execution represents an active path of execution. Executions are made inactive in the following situations:
        • an execution enters a nested scope
        • an execution is split up into multiple concurrent executions, then the parent is made inactive.
        • an execution has arrived in a parallel gateway or join and that join has not yet activated/fired.
        • an execution is ended.
      • isScope

        protected boolean isScope
      • isConcurrent

        protected boolean isConcurrent
      • isEnded

        protected boolean isEnded
      • isEventScope

        protected boolean isEventScope
      • isRemoved

        protected boolean isRemoved
      • preserveScope

        protected boolean preserveScope
        transient; used for process instance modification to preserve a scope from getting deleted
      • activityInstanceState

        protected int activityInstanceState
        marks the current activity instance
      • activityInstanceEndListenersFailed

        protected boolean activityInstanceEndListenersFailed
      • sequenceCounter

        protected long sequenceCounter
      • delayedEvents

        protected transient java.util.List<DelayedVariableEvent> delayedEvents
        Contains the delayed variable events, which will be dispatched on a save point.
    • Constructor Detail

      • PvmExecutionImpl

        public PvmExecutionImpl()
    • Method Detail

      • createSubCaseInstance

        public abstract CmmnExecution createSubCaseInstance​(CmmnCaseDefinition caseDefinition,
                                                            java.lang.String businessKey)
        Description copied from interface: ActivityExecution

        Creates a new sub case instance.

        This execution will be the super execution of the created sub case instance.

        Specified by:
        createSubCaseInstance in interface ActivityExecution
        Parameters:
        caseDefinition - The CmmnCaseDefinition of the sub case instance.
        businessKey - The businessKey to be set on sub case instance.
      • initialize

        public abstract void initialize()
      • initializeTimerDeclarations

        public abstract void initializeTimerDeclarations()
      • executeIoMapping

        public void executeIoMapping()
      • start

        public void start​(java.util.Map<java.lang.String,​java.lang.Object> variables)
        Specified by:
        start in interface PvmProcessInstance
      • startWithFormProperties

        public void startWithFormProperties​(VariableMap formProperties)
      • start

        protected void start​(java.util.Map<java.lang.String,​java.lang.Object> variables,
                             VariableMap formProperties)
      • startWithoutExecuting

        public void startWithoutExecuting​(java.util.Map<java.lang.String,​java.lang.Object> variables)
        perform starting behavior but don't execute the initial activity
        Parameters:
        variables - the variables which are used for the start
      • fireHistoricProcessStartEvent

        public abstract void fireHistoricProcessStartEvent()
      • removeAllTasks

        public void removeAllTasks()
      • removeEventScopes

        protected void removeEventScopes()
      • clearScope

        public void clearScope​(java.lang.String reason,
                               boolean skipCustomListeners,
                               boolean skipIoMappings,
                               boolean externallyTerminated)
      • interrupt

        public void interrupt​(java.lang.String reason)
        Interrupts an execution
        Specified by:
        interrupt in interface ActivityExecution
      • interrupt

        public void interrupt​(java.lang.String reason,
                              boolean skipCustomListeners,
                              boolean skipIoMappings,
                              boolean externallyTerminated)
      • end

        public void end​(boolean completeScope)
        Ends an execution. Invokes end listeners for the current activity and notifies the flow scope execution of this happening which may result in the flow scope ending.
        Specified by:
        end in interface ActivityExecution
        Parameters:
        completeScope - true if ending the execution contributes to completing the BPMN 2.0 scope
      • endCompensation

        public void endCompensation()
        Description copied from interface: ActivityExecution
        Execution finished compensation. Removes this execution and notifies listeners.
        Specified by:
        endCompensation in interface ActivityExecution
      • propagateEnd

        public void propagateEnd()

        Precondition: execution is already ended but this has not been propagated yet.

        Propagates the ending of this execution to the flowscope execution; currently only supports the process instance execution

      • isRemoved

        public boolean isRemoved()
      • createConcurrentExecution

        public PvmExecutionImpl createConcurrentExecution()
      • deleteCascade

        public void deleteCascade​(java.lang.String deleteReason,
                                  boolean skipCustomListeners,
                                  boolean skipIoMappings)
      • deleteCascade

        public void deleteCascade​(java.lang.String deleteReason,
                                  boolean skipCustomListeners,
                                  boolean skipIoMappings,
                                  boolean externallyTerminated,
                                  boolean skipSubprocesses)
      • executeEventHandlerActivity

        public void executeEventHandlerActivity​(ActivityImpl eventHandlerActivity)
      • getReplacedBy

        public abstract PvmExecutionImpl getReplacedBy()

        Returns an execution that has replaced this execution for executing activities in their shared scope.

        Invariant: this execution and getReplacedBy() execute in the same scope.

      • resolveReplacedBy

        public PvmExecutionImpl resolveReplacedBy()
        Instead of getReplacedBy(), which returns the execution that this execution was directly replaced with, this resolves the chain of replacements (i.e. in the case the replacedBy execution itself was replaced again)
      • hasReplacedParent

        public boolean hasReplacedParent()
      • isReplacedByParent

        public boolean isReplacedByParent()
      • replace

        public void replace​(PvmExecutionImpl execution)

        Replace an execution by this execution. The replaced execution has a pointer (getReplacedBy()) to this execution. This pointer is maintained until the replaced execution is removed or this execution is removed/ended.

        This is used for two cases: Execution tree expansion and execution tree compaction

        • expansion: Before:
                 -------
                 |  e1 |  scope
                 -------
               
          After:
                 -------
                 |  e1 |  scope
                 -------
                    |
                 -------
                 |  e2 |  cc (no scope)
                 -------
               
          e2 replaces e1: it should receive all entities associated with the activity currently executed by e1; these are tasks, (local) variables, jobs (specific for the activity, not the scope)
        • compaction: Before:
                 -------
                 |  e1 |  scope
                 -------
                    |
                 -------
                 |  e2 |  cc (no scope)
                 -------
               
          After:
                 -------
                 |  e1 |  scope
                 -------
               
          e1 replaces e2: it should receive all entities associated with the activity currently executed by e2; these are tasks, (all) variables, all jobs
        See Also:
        createConcurrentExecution(), tryPruneLastConcurrentChild()
      • onConcurrentExpand

        public void onConcurrentExpand​(PvmExecutionImpl scopeExecution)
        Callback on tree expansion when this execution is used as the concurrent execution where the argument's children become a subordinate to. Note that this case is not the inverse of replace because replace has the semantics that the replacing execution can be used to continue execution of this execution's activity instance.
      • take

        public void take()
      • executeActivity

        public void executeActivity​(PvmActivity activity)
        Execute an activity which is not contained in normal flow (having no incoming sequence flows). Cannot be called for activities contained in normal flow.

        First, the ActivityStartBehavior is evaluated. In case the start behavior is not ActivityStartBehavior.DEFAULT, the corresponding start behavior is executed before executing the activity.

        For a given activity, the execution on which this method must be called depends on the type of the start behavior:

        Specified by:
        executeActivity in interface ActivityExecution
        Parameters:
        activity - the activity to start
      • executeActivitiesConcurrent

        public void executeActivitiesConcurrent​(java.util.List<PvmActivity> activityStack,
                                                PvmActivity targetActivity,
                                                PvmTransition targetTransition,
                                                java.util.Map<java.lang.String,​java.lang.Object> variables,
                                                java.util.Map<java.lang.String,​java.lang.Object> localVariables,
                                                boolean skipCustomListeners,
                                                boolean skipIoMappings)
        Instantiates the given activity stack under this execution. Sets the variables for the execution responsible to execute the most deeply nested activity.
        Parameters:
        activityStack - The most deeply nested activity is the last element in the list
      • instantiateScopes

        public java.util.Map<PvmActivity,​PvmExecutionImpl> instantiateScopes​(java.util.List<PvmActivity> activityStack,
                                                                                   boolean skipCustomListeners,
                                                                                   boolean skipIoMappings)
        Instantiates the given set of activities and returns the execution for the bottom-most activity
      • executeActivities

        public void executeActivities​(java.util.List<PvmActivity> activityStack,
                                      PvmActivity targetActivity,
                                      PvmTransition targetTransition,
                                      java.util.Map<java.lang.String,​java.lang.Object> variables,
                                      java.util.Map<java.lang.String,​java.lang.Object> localVariables,
                                      boolean skipCustomListeners,
                                      boolean skipIoMappings)
        Instantiates the given activity stack. Uses this execution to execute the highest activity in the stack. Sets the variables for the execution responsible to execute the most deeply nested activity.
        Parameters:
        activityStack - The most deeply nested activity is the last element in the list
      • getAllChildExecutions

        protected java.util.List<PvmExecutionImpl> getAllChildExecutions()
      • removeVariablesLocalInternal

        protected abstract void removeVariablesLocalInternal()
      • isActive

        public boolean isActive​(java.lang.String activityId)
      • inactivate

        public void inactivate()
        Description copied from interface: ActivityExecution
        Inactivates this execution. This is useful for example in a join: the execution still exists, but it is not longer active.
        Specified by:
        inactivate in interface ActivityExecution
      • getExecutions

        public abstract java.util.List<? extends PvmExecutionImpl> getExecutions()
        Description copied from interface: ActivityExecution
        returns the list of execution of which this execution the parent of. This is a copy of the actual list, so a modification has no direct effect.
        Specified by:
        getExecutions in interface ActivityExecution
      • getExecutionsAsCopy

        public abstract java.util.List<? extends PvmExecutionImpl> getExecutionsAsCopy()
      • getEventScopeExecutions

        public java.util.List<? extends PvmExecutionImpl> getEventScopeExecutions()
      • collectExecutions

        protected void collectExecutions​(java.lang.String activityId,
                                         java.util.List<PvmExecution> executions)
      • collectActiveActivityIds

        protected void collectActiveActivityIds​(java.util.List<java.lang.String> activeActivityIds)
      • setProcessBusinessKey

        public void setProcessBusinessKey​(java.lang.String businessKey)
        Description copied from interface: DelegateExecution
        Configure a business key on the process instance this execution is associated with.
        Specified by:
        setProcessBusinessKey in interface DelegateExecution
        Parameters:
        businessKey - the new business key
      • setProcessInstance

        public abstract void setProcessInstance​(PvmExecutionImpl pvmExecutionImpl)
      • getCaseInstanceId

        public java.lang.String getCaseInstanceId()
      • setCaseInstanceId

        public void setCaseInstanceId​(java.lang.String caseInstanceId)
      • getActivityId

        public java.lang.String getActivityId()
      • activityInstanceStarting

        public void activityInstanceStarting()
      • activityInstanceStarted

        public void activityInstanceStarted()
      • activityInstanceDone

        public void activityInstanceDone()
      • activityInstanceEndListenerFailure

        public void activityInstanceEndListenerFailure()
      • generateActivityInstanceId

        protected abstract java.lang.String generateActivityInstanceId​(java.lang.String activityId)
      • getParentId

        public java.lang.String getParentId()
        Description copied from interface: DelegateExecution
        Gets the id of the parent of this execution. If null, the execution represents a process-instance.
        Specified by:
        getParentId in interface DelegateExecution
      • hasChildren

        public boolean hasChildren()
        Specified by:
        hasChildren in interface ActivityExecution
        Returns:
        true if this execution has child executions (event scope executions or not)
      • setParent

        public void setParent​(PvmExecutionImpl parent)
        Sets the execution's parent and updates the old and new parents' set of child executions
      • setParentExecution

        public abstract void setParentExecution​(PvmExecutionImpl parent)
        Use #setParent to also update the child execution sets
      • getSuperExecution

        public abstract PvmExecutionImpl getSuperExecution()
        Description copied from interface: DelegateExecution
        In case this delegate execution is the process instance execution and this process instance was started by a call activity, this method returns the execution which executed the call activity in the super process instance.
        Specified by:
        getSuperExecution in interface DelegateExecution
        Returns:
        the super execution or null.
      • setSuperExecution

        public abstract void setSuperExecution​(PvmExecutionImpl superExecution)
      • getSubProcessInstance

        public abstract PvmExecutionImpl getSubProcessInstance()
      • setSubProcessInstance

        public abstract void setSubProcessInstance​(PvmExecutionImpl subProcessInstance)
      • getSuperCaseExecution

        public abstract CmmnExecution getSuperCaseExecution()
      • setSuperCaseExecution

        public abstract void setSuperCaseExecution​(CmmnExecution superCaseExecution)
      • getSubCaseInstance

        public abstract CmmnExecution getSubCaseInstance()
      • setSubCaseInstance

        public abstract void setSubCaseInstance​(CmmnExecution subCaseInstance)
      • getScopeActivity

        protected ScopeImpl getScopeActivity()
      • setScope

        public void setScope​(boolean isScope)
        Description copied from interface: ActivityExecution
        Changes whether this execution is a scope or not
        Specified by:
        setScope in interface ActivityExecution
      • findExecutionForFlowScope

        public PvmExecutionImpl findExecutionForFlowScope​(PvmScope targetFlowScope)
        For a given target flow scope, this method returns the corresponding scope execution.

        Precondition: the execution is active and executing an activity. Can be invoked for scope and non scope executions.

        Specified by:
        findExecutionForFlowScope in interface ActivityExecution
        Parameters:
        targetFlowScope - scope activity or process definition for which the scope execution should be found
        Returns:
        the scope execution for the provided targetFlowScope
      • getFlowScope

        protected ScopeImpl getFlowScope()
      • createActivityExecutionMapping

        protected java.util.Map<ScopeImpl,​PvmExecutionImpl> createActivityExecutionMapping​(ScopeImpl currentScope,
                                                                                                 java.util.Map<ScopeImpl,​PvmExecutionImpl> mapping)
        Creates an extended mapping based on this execution and the given existing mapping. Any entry mapping in mapping that corresponds to an ancestor scope of currentScope is reused.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getToStringIdentity

        protected java.lang.String getToStringIdentity()
      • setVariable

        public void setVariable​(java.lang.String variableName,
                                java.lang.Object value,
                                java.lang.String targetActivityId)
        Method to store variable in a specific scope identified by activity ID.
        Specified by:
        setVariable in interface DelegateExecution
        Parameters:
        variableName - - name of the variable
        value - - value of the variable
        targetActivityId - - activity ID which is associated with destination execution, if not existing - exception will be thrown
      • findExecutionForFlowScope

        protected PvmExecutionImpl findExecutionForFlowScope​(java.lang.String targetScopeId)
        Parameters:
        targetScopeId - - destination scope to be found in current execution tree
        Returns:
        execution with activity id corresponding to targetScopeId
      • getSequenceCounter

        public long getSequenceCounter()
      • setSequenceCounter

        public void setSequenceCounter​(long sequenceCounter)
      • incrementSequenceCounter

        public void incrementSequenceCounter()
      • isExternallyTerminated

        public boolean isExternallyTerminated()
      • setExternallyTerminated

        public void setExternallyTerminated​(boolean externallyTerminated)
      • getDeleteReason

        public java.lang.String getDeleteReason()
      • setDeleteReason

        public void setDeleteReason​(java.lang.String deleteReason)
      • isDeleteRoot

        public boolean isDeleteRoot()
      • setDeleteRoot

        public void setDeleteRoot​(boolean deleteRoot)
      • getTransitionsToTake

        public java.util.List<PvmTransition> getTransitionsToTake()
      • setTransitionsToTake

        public void setTransitionsToTake​(java.util.List<PvmTransition> transitionsToTake)
      • setTransition

        public void setTransition​(PvmTransition transition)
      • setConcurrent

        public void setConcurrent​(boolean isConcurrent)
        Description copied from interface: ActivityExecution
        changes the concurrent indicator on this execution.
        Specified by:
        setConcurrent in interface ActivityExecution
      • setCanceled

        public void setCanceled​(boolean canceled)
      • setCompleteScope

        public void setCompleteScope​(boolean completeScope)
      • setPreserveScope

        public void setPreserveScope​(boolean preserveScope)
      • isPreserveScope

        public boolean isPreserveScope()
      • getActivityInstanceState

        public int getActivityInstanceState()
      • isEventScope

        public boolean isEventScope()
      • setEventScope

        public void setEventScope​(boolean isEventScope)
      • disposeScopeInstantiationContext

        public void disposeScopeInstantiationContext()
      • isIgnoreAsync

        public boolean isIgnoreAsync()
      • setStarting

        public void setStarting​(boolean isStarting)
      • isStarting

        public boolean isStarting()
      • isProcessInstanceStarting

        public boolean isProcessInstanceStarting()
      • setProcessInstanceStarting

        public void setProcessInstanceStarting​(boolean starting)
      • setNextActivity

        public void setNextActivity​(PvmActivity nextActivity)
      • getParentScopeExecution

        public PvmExecutionImpl getParentScopeExecution​(boolean considerSuperExecution)
      • delayEvent

        public void delayEvent​(PvmExecutionImpl targetScope,
                               VariableEvent variableEvent)
        Delays a given variable event with the given target scope.
        Parameters:
        targetScope - the target scope of the variable event
        variableEvent - the variable event which should be delayed
      • delayEvent

        public void delayEvent​(DelayedVariableEvent delayedVariableEvent)
        Delays and stores the given DelayedVariableEvent on the process instance.
        Parameters:
        delayedVariableEvent - the DelayedVariableEvent which should be store on the process instance
      • getDelayedEvents

        public java.util.List<DelayedVariableEvent> getDelayedEvents()
        The current delayed variable events.
        Returns:
        a list of DelayedVariableEvent objects
      • clearDelayedEvents

        public void clearDelayedEvents()
        Cleares the current delayed variable events.
      • dispatchDelayedEventsAndPerformOperation

        public void dispatchDelayedEventsAndPerformOperation​(PvmAtomicOperation atomicOperation)
        Dispatches the current delayed variable events and performs the given atomic operation if the current state was not changed.
        Parameters:
        atomicOperation - the atomic operation which should be executed
      • dispatchDelayedEventsAndPerformOperation

        public void dispatchDelayedEventsAndPerformOperation​(Callback<PvmExecutionImpl,​java.lang.Void> continuation)
        Dispatches the current delayed variable events and performs the given atomic operation if the current state was not changed.
        Parameters:
        continuation - the atomic operation continuation which should be executed
      • continueIfExecutionDoesNotAffectNextOperation

        public void continueIfExecutionDoesNotAffectNextOperation​(Callback<PvmExecutionImpl,​java.lang.Void> dispatching,
                                                                  Callback<PvmExecutionImpl,​java.lang.Void> continuation,
                                                                  PvmExecutionImpl execution)
        Executes the given depending operations with the given execution. The execution state will be checked with the help of the activity instance id and activity id of the execution before and after the dispatching callback call. If the id's are not changed the continuation callback is called.
        Parameters:
        dispatching - the callback to dispatch the variable events
        continuation - the callback to continue with the next atomic operation
        execution - the execution which is used for the execution
      • dispatchScopeEvents

        protected void dispatchScopeEvents​(PvmExecutionImpl execution)
        Dispatches the current delayed variable events on the scope of the given execution.
        Parameters:
        execution - the execution on which scope the delayed variable should be dispatched
      • initActivityIds

        protected void initActivityIds​(java.util.List<DelayedVariableEvent> delayedEvents,
                                       java.util.Map<PvmExecutionImpl,​java.lang.String> activityInstanceIds,
                                       java.util.Map<PvmExecutionImpl,​java.lang.String> activityIds)
        Initializes the given maps with the target scopes and current activity id's and activity instance id's.
        Parameters:
        delayedEvents - the delayed events which contains the information about the target scope
        activityInstanceIds - the map which maps target scope to activity instance id
        activityIds - the map which maps target scope to activity id
      • createIncident

        public Incident createIncident​(java.lang.String incidentType,
                                       java.lang.String configuration)
        Returns the newest incident in this execution
        Specified by:
        createIncident in interface DelegateExecution
        Parameters:
        incidentType - the type of new incident
        configuration - configuration of the incident
        Returns:
        new incident
      • createIncident

        public Incident createIncident​(java.lang.String incidentType,
                                       java.lang.String configuration,
                                       java.lang.String message)
        Description copied from interface: DelegateExecution
        Create an incident associated with this execution
        Specified by:
        createIncident in interface DelegateExecution
        Parameters:
        incidentType - the type of incident
        Returns:
        a new incident
      • createIncidentContext

        protected IncidentContext createIncidentContext​(java.lang.String configuration)
      • resolveIncident

        public void resolveIncident​(java.lang.String incidentId)
        Resolves an incident with given id.
        Specified by:
        resolveIncident in interface DelegateExecution
        Parameters:
        incidentId -
      • findIncidentHandler

        public IncidentHandler findIncidentHandler​(java.lang.String incidentType)