Class MultiInstanceActivityBehavior
- java.lang.Object
-
- org.flowable.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
-
- org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior
-
- All Implemented Interfaces:
Serializable,ActivityBehavior,InterruptibleActivityBehaviour,SubProcessActivityBehavior,TriggerableActivityBehavior
- Direct Known Subclasses:
ParallelMultiInstanceBehavior,SequentialMultiInstanceBehavior
public abstract class MultiInstanceActivityBehavior extends FlowNodeActivityBehavior implements SubProcessActivityBehavior, InterruptibleActivityBehaviour
Implementation of the multi-instance functionality as described in the BPMN 2.0 spec. Multi instance functionality is implemented as anActivityBehaviorthat wraps the originalActivityBehaviorof the activity. Only subclasses ofAbstractBpmnActivityBehaviorcan have multi-instance behavior. As such, special logic is contained in theAbstractBpmnActivityBehaviorto delegate to theMultiInstanceActivityBehaviorif needed.- Author:
- Joram Barrez, Tijs Rademakers, Filip Hrisafov
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected org.flowable.bpmn.model.Activityactivityprotected org.flowable.bpmn.model.VariableAggregationDefinitionsaggregationsprotected StringcollectionElementIndexVariableprotected StringcollectionElementVariableprotected ExpressioncollectionExpressionprotected org.flowable.bpmn.model.CollectionHandlercollectionHandlerprotected StringcollectionStringprotected StringcollectionVariableprotected StringcompletionConditionprotected static StringDELETE_REASON_ENDprotected AbstractBpmnActivityBehaviorinnerActivityBehaviorprotected static org.slf4j.LoggerLOGGERprotected ExpressionloopCardinalityExpressionprotected static StringNUMBER_OF_ACTIVE_INSTANCESprotected static StringNUMBER_OF_COMPLETED_INSTANCESprotected static StringNUMBER_OF_INSTANCES-
Fields inherited from class org.flowable.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
bpmnActivityBehavior
-
-
Constructor Summary
Constructors Constructor Description MultiInstanceActivityBehavior(org.flowable.bpmn.model.Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaggregateVariablesForChildExecution(DelegateExecution childExecution, DelegateExecution miRootExecution)Aggregated the variables for the finished child multi instance executionprotected voidaggregateVariablesOfAllInstances(DelegateExecution multiInstanceRootExecution)Aggregates all variables that were stored before for each child instanceprotected FlowableMultiInstanceActivityCompletedEventbuildCompletedEvent(DelegateExecution execution, FlowableEngineEventType eventType)protected voidcallActivityEndListeners(DelegateExecution execution)Since no transitions are followed when leaving the inner activity, it is needed to call the end listeners yourself.protected voidcleanupMiRoot(DelegateExecution execution)voidcompleted(DelegateExecution execution)called after the process instance is destroyed for this activity to perform its outgoing control flow logic.voidcompleting(DelegateExecution execution, DelegateExecution subProcessInstance)called before the process instance is destroyed to allow this activity to extract data from the sub process instance.booleancompletionConditionSatisfied(DelegateExecution execution)protected FlowableCollectionHandlercreateFlowableCollectionHandler(org.flowable.bpmn.model.CollectionHandler handler, DelegateExecution execution)protected abstract intcreateInstances(DelegateExecution execution)voidexecute(DelegateExecution delegateExecution)Default behaviour: just leave the activity with no extra functionality.protected voidexecuteCompensationBoundaryEvents(org.flowable.bpmn.model.FlowElement flowElement, DelegateExecution execution)protected voidexecuteOriginalBehavior(DelegateExecution execution, ExecutionEntity multiInstanceRootExecution, int loopCounter)protected Collection<org.flowable.bpmn.model.BoundaryEvent>findBoundaryEventsForFlowNode(String processDefinitionId, org.flowable.bpmn.model.FlowElement flowElement)protected StringgetActiveValue(String originalValue, String propertyName, com.fasterxml.jackson.databind.node.ObjectNode taskElementProperties)org.flowable.bpmn.model.VariableAggregationDefinitionsgetAggregations()StringgetCollectionElementIndexVariable()StringgetCollectionElementVariable()ExpressiongetCollectionExpression()StringgetCollectionString()StringgetCollectionVariable()StringgetCompletionCondition()org.flowable.bpmn.model.CollectionHandlergetHandler()AbstractBpmnActivityBehaviorgetInnerActivityBehavior()protected DelegateExecutiongetInstanceExecution(DelegateExecution execution)protected IntegergetLocalLoopVariable(DelegateExecution execution, String variableName)ExpressiongetLoopCardinalityExpression()IntegergetLoopVariable(DelegateExecution execution, String variableName)org.flowable.variable.api.persistence.entity.VariableInstancegetLoopVariableInstance(DelegateExecution execution, String variableName)protected DelegateExecutiongetMultiInstanceRootExecution(DelegateExecution execution)protected org.flowable.bpmn.model.ProcessgetProcessDefinition(String processDefinitionId)protected booleanhasVariableAggregationDefinitions(DelegateExecution execution)protected voidinternalInterrupted(DelegateExecution execution)voidinterrupted(DelegateExecution execution)protected booleanisExtraScopeNeeded(org.flowable.bpmn.model.FlowNode flowNode)protected CollectioniterableToCollection(Iterable iterable)voidlastExecutionEnded(DelegateExecution execution)voidleave(DelegateExecution execution)Default way of leaving a BPMN 2.0 activity: evaluate the conditions on the outgoing sequence flow and take those that evaluate to true.protected voidlogLoopDetails(DelegateExecution execution, String custom, int loopCounter, int nrOfCompletedInstances, int nrOfActiveInstances, int nrOfInstances)protected CollectionresolveAndValidateCollection(DelegateExecution execution)protected ObjectresolveCollection(DelegateExecution execution)protected intresolveLoopCardinality(DelegateExecution execution)protected intresolveNrOfInstances(DelegateExecution execution)protected voidsendCompletedEvent(DelegateExecution execution)protected voidsendCompletedWithConditionEvent(DelegateExecution execution)voidsetAggregations(org.flowable.bpmn.model.VariableAggregationDefinitions aggregations)voidsetCollectionElementIndexVariable(String collectionElementIndexVariable)voidsetCollectionElementVariable(String collectionElementVariable)voidsetCollectionExpression(Expression collectionExpression)voidsetCollectionString(String collectionString)voidsetCollectionVariable(String collectionVariable)voidsetCompletionCondition(String completionCondition)voidsetHandler(org.flowable.bpmn.model.CollectionHandler collectionHandler)voidsetInnerActivityBehavior(AbstractBpmnActivityBehavior innerActivityBehavior)voidsetLoopCardinalityExpression(Expression loopCardinalityExpression)protected voidsetLoopVariable(DelegateExecution execution, String variableName, Object value)voidtrigger(DelegateExecution execution, String signalName, Object signalData)protected booleanusesCollection()-
Methods inherited from class org.flowable.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
leaveIgnoreConditions, parseActivityType
-
-
-
-
Field Detail
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
DELETE_REASON_END
protected static final String DELETE_REASON_END
- See Also:
- Constant Field Values
-
NUMBER_OF_INSTANCES
protected static final String NUMBER_OF_INSTANCES
- See Also:
- Constant Field Values
-
NUMBER_OF_ACTIVE_INSTANCES
protected static final String NUMBER_OF_ACTIVE_INSTANCES
- See Also:
- Constant Field Values
-
NUMBER_OF_COMPLETED_INSTANCES
protected static final String NUMBER_OF_COMPLETED_INSTANCES
- See Also:
- Constant Field Values
-
activity
protected org.flowable.bpmn.model.Activity activity
-
innerActivityBehavior
protected AbstractBpmnActivityBehavior innerActivityBehavior
-
loopCardinalityExpression
protected Expression loopCardinalityExpression
-
completionCondition
protected String completionCondition
-
collectionExpression
protected Expression collectionExpression
-
collectionVariable
protected String collectionVariable
-
collectionElementVariable
protected String collectionElementVariable
-
collectionString
protected String collectionString
-
collectionHandler
protected org.flowable.bpmn.model.CollectionHandler collectionHandler
-
aggregations
protected org.flowable.bpmn.model.VariableAggregationDefinitions aggregations
-
collectionElementIndexVariable
protected String collectionElementIndexVariable
-
-
Constructor Detail
-
MultiInstanceActivityBehavior
public MultiInstanceActivityBehavior(org.flowable.bpmn.model.Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior)- Parameters:
innerActivityBehavior- The originalActivityBehaviorof the activity that will be wrapped inside this behavior.
-
-
Method Detail
-
execute
public void execute(DelegateExecution delegateExecution)
Description copied from class:FlowNodeActivityBehaviorDefault behaviour: just leave the activity with no extra functionality.- Specified by:
executein interfaceActivityBehavior- Overrides:
executein classFlowNodeActivityBehavior
-
createInstances
protected abstract int createInstances(DelegateExecution execution)
-
leave
public void leave(DelegateExecution execution)
Description copied from class:FlowNodeActivityBehaviorDefault way of leaving a BPMN 2.0 activity: evaluate the conditions on the outgoing sequence flow and take those that evaluate to true.- Overrides:
leavein classFlowNodeActivityBehavior
-
hasVariableAggregationDefinitions
protected boolean hasVariableAggregationDefinitions(DelegateExecution execution)
-
aggregateVariablesForChildExecution
protected void aggregateVariablesForChildExecution(DelegateExecution childExecution, DelegateExecution miRootExecution)
Aggregated the variables for the finished child multi instance execution- Parameters:
childExecution- the child executionmiRootExecution- the multi instance root execution
-
aggregateVariablesOfAllInstances
protected void aggregateVariablesOfAllInstances(DelegateExecution multiInstanceRootExecution)
Aggregates all variables that were stored before for each child instance
-
cleanupMiRoot
protected void cleanupMiRoot(DelegateExecution execution)
-
executeCompensationBoundaryEvents
protected void executeCompensationBoundaryEvents(org.flowable.bpmn.model.FlowElement flowElement, DelegateExecution execution)
-
findBoundaryEventsForFlowNode
protected Collection<org.flowable.bpmn.model.BoundaryEvent> findBoundaryEventsForFlowNode(String processDefinitionId, org.flowable.bpmn.model.FlowElement flowElement)
-
getProcessDefinition
protected org.flowable.bpmn.model.Process getProcessDefinition(String processDefinitionId)
-
trigger
public void trigger(DelegateExecution execution, String signalName, Object signalData)
- Specified by:
triggerin interfaceTriggerableActivityBehavior- Overrides:
triggerin classFlowNodeActivityBehavior
-
lastExecutionEnded
public void lastExecutionEnded(DelegateExecution execution)
-
completing
public void completing(DelegateExecution execution, DelegateExecution subProcessInstance) throws Exception
Description copied from interface:SubProcessActivityBehaviorcalled before the process instance is destroyed to allow this activity to extract data from the sub process instance. No control flow should be done on the execution yet.- Specified by:
completingin interfaceSubProcessActivityBehavior- Throws:
Exception
-
completed
public void completed(DelegateExecution execution) throws Exception
Description copied from interface:SubProcessActivityBehaviorcalled after the process instance is destroyed for this activity to perform its outgoing control flow logic.- Specified by:
completedin interfaceSubProcessActivityBehavior- Throws:
Exception
-
interrupted
public void interrupted(DelegateExecution execution)
- Specified by:
interruptedin interfaceInterruptibleActivityBehaviour
-
internalInterrupted
protected void internalInterrupted(DelegateExecution execution)
-
completionConditionSatisfied
public boolean completionConditionSatisfied(DelegateExecution execution)
-
getLoopVariable
public Integer getLoopVariable(DelegateExecution execution, String variableName)
-
getLoopVariableInstance
public org.flowable.variable.api.persistence.entity.VariableInstance getLoopVariableInstance(DelegateExecution execution, String variableName)
-
sendCompletedWithConditionEvent
protected void sendCompletedWithConditionEvent(DelegateExecution execution)
-
sendCompletedEvent
protected void sendCompletedEvent(DelegateExecution execution)
-
buildCompletedEvent
protected FlowableMultiInstanceActivityCompletedEvent buildCompletedEvent(DelegateExecution execution, FlowableEngineEventType eventType)
-
resolveNrOfInstances
protected int resolveNrOfInstances(DelegateExecution execution)
-
executeOriginalBehavior
protected void executeOriginalBehavior(DelegateExecution execution, ExecutionEntity multiInstanceRootExecution, int loopCounter)
-
resolveAndValidateCollection
protected Collection resolveAndValidateCollection(DelegateExecution execution)
-
iterableToCollection
protected Collection iterableToCollection(Iterable iterable)
-
resolveCollection
protected Object resolveCollection(DelegateExecution execution)
-
usesCollection
protected boolean usesCollection()
-
isExtraScopeNeeded
protected boolean isExtraScopeNeeded(org.flowable.bpmn.model.FlowNode flowNode)
-
resolveLoopCardinality
protected int resolveLoopCardinality(DelegateExecution execution)
-
setLoopVariable
protected void setLoopVariable(DelegateExecution execution, String variableName, Object value)
-
getLocalLoopVariable
protected Integer getLocalLoopVariable(DelegateExecution execution, String variableName)
-
callActivityEndListeners
protected void callActivityEndListeners(DelegateExecution execution)
Since no transitions are followed when leaving the inner activity, it is needed to call the end listeners yourself.
-
logLoopDetails
protected void logLoopDetails(DelegateExecution execution, String custom, int loopCounter, int nrOfCompletedInstances, int nrOfActiveInstances, int nrOfInstances)
-
getMultiInstanceRootExecution
protected DelegateExecution getMultiInstanceRootExecution(DelegateExecution execution)
-
getInstanceExecution
protected DelegateExecution getInstanceExecution(DelegateExecution execution)
-
getActiveValue
protected String getActiveValue(String originalValue, String propertyName, com.fasterxml.jackson.databind.node.ObjectNode taskElementProperties)
-
createFlowableCollectionHandler
protected FlowableCollectionHandler createFlowableCollectionHandler(org.flowable.bpmn.model.CollectionHandler handler, DelegateExecution execution)
-
getLoopCardinalityExpression
public Expression getLoopCardinalityExpression()
-
setLoopCardinalityExpression
public void setLoopCardinalityExpression(Expression loopCardinalityExpression)
-
getCompletionCondition
public String getCompletionCondition()
-
setCompletionCondition
public void setCompletionCondition(String completionCondition)
-
getCollectionExpression
public Expression getCollectionExpression()
-
setCollectionExpression
public void setCollectionExpression(Expression collectionExpression)
-
getCollectionVariable
public String getCollectionVariable()
-
setCollectionVariable
public void setCollectionVariable(String collectionVariable)
-
getCollectionElementVariable
public String getCollectionElementVariable()
-
setCollectionElementVariable
public void setCollectionElementVariable(String collectionElementVariable)
-
getCollectionString
public String getCollectionString()
-
setCollectionString
public void setCollectionString(String collectionString)
-
getHandler
public org.flowable.bpmn.model.CollectionHandler getHandler()
-
setHandler
public void setHandler(org.flowable.bpmn.model.CollectionHandler collectionHandler)
-
getAggregations
public org.flowable.bpmn.model.VariableAggregationDefinitions getAggregations()
-
setAggregations
public void setAggregations(org.flowable.bpmn.model.VariableAggregationDefinitions aggregations)
-
getCollectionElementIndexVariable
public String getCollectionElementIndexVariable()
-
setCollectionElementIndexVariable
public void setCollectionElementIndexVariable(String collectionElementIndexVariable)
-
setInnerActivityBehavior
public void setInnerActivityBehavior(AbstractBpmnActivityBehavior innerActivityBehavior)
-
getInnerActivityBehavior
public AbstractBpmnActivityBehavior getInnerActivityBehavior()
-
-