org.camunda.bpm.engine.impl.bpmn.behavior
Class MultiInstanceActivityBehavior

java.lang.Object
  extended by org.camunda.bpm.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
      extended by org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior
All Implemented Interfaces:
CoreActivityBehavior<ActivityExecution>, ActivityBehavior, CompositeActivityBehavior, SignallableActivityBehavior, SubProcessActivityBehavior
Direct Known Subclasses:
ParallelMultiInstanceBehavior, SequentialMultiInstanceBehavior

public abstract class MultiInstanceActivityBehavior
extends FlowNodeActivityBehavior
implements CompositeActivityBehavior, SubProcessActivityBehavior

Implementation of the multi-instance functionality as described in the BPMN 2.0 spec. Multi instance functionality is implemented as an ActivityBehavior that wraps the original ActivityBehavior of the activity. Only subclasses of AbstractBpmnActivityBehavior can have multi-instance behavior. As such, special logic is contained in the AbstractBpmnActivityBehavior to delegate to the MultiInstanceActivityBehavior if needed.

Author:
Joram Barrez, Falko Menge

Field Summary
protected  ActivityImpl activity
           
protected  String collectionElementVariable
           
protected  Expression collectionExpression
           
protected  String collectionVariable
           
protected  Expression completionConditionExpression
           
protected  AbstractBpmnActivityBehavior innerActivityBehavior
           
protected  IoMapping ioMapping
           
protected static Logger LOGGER
           
protected  String LOOP_COUNTER
           
protected  Expression loopCardinalityExpression
           
protected  String NUMBER_OF_ACTIVE_INSTANCES
           
protected  String NUMBER_OF_COMPLETED_INSTANCES
           
protected  String NUMBER_OF_INSTANCES
           
 
Fields inherited from class org.camunda.bpm.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
bpmnActivityBehavior
 
Constructor Summary
MultiInstanceActivityBehavior(ActivityImpl activity, AbstractBpmnActivityBehavior innerActivityBehavior)
           
 
Method Summary
protected  void callActivityEndListeners(ActivityExecution execution)
          Since no transitions are followed when leaving the inner activity, it is needed to call the end listeners yourself.
 void completed(ActivityExecution execution)
          called after the process instance is destroyed for this activity to perform its outgoing control flow logic.
 void completing(DelegateExecution execution, DelegateExecution subProcessInstance)
          called before the process instance is destroyed to allow this activity to extract data from the sub process instance.
protected  boolean completionConditionSatisfied(ActivityExecution execution)
           
protected abstract  void createInstances(ActivityExecution execution, int nrOfInstances)
           
protected  boolean createInstancesIfPossible(ActivityExecution execution)
          protects the createInstance method - it is only called if the numberOfInstances is valid (negative is invalid -> exception; zero means the sub instances are skipped) Returns true if instances were created
 void execute(ActivityExecution execution)
          Default behaviour: just leave the activity with no extra functionality.
protected  void executeIoMapping(AbstractVariableScope scope)
           
protected  void executeOriginalBehavior(ActivityExecution execution, int loopCounter)
           
 String getCollectionElementVariable()
           
 Expression getCollectionExpression()
           
 String getCollectionVariable()
           
 Expression getCompletionConditionExpression()
           
protected  Integer getLocalLoopVariable(ActivityExecution execution, String variableName)
           
 Expression getLoopCardinalityExpression()
           
protected  Integer getLoopVariable(ActivityExecution execution, String variableName)
           
 boolean isExtraScopeNeeded()
           
 void lastExecutionEnded(ActivityExecution execution)
           
protected  void logLoopDetails(ActivityExecution execution, String custom, int loopCounter, int nrOfCompletedInstances, int nrOfActiveInstances, int nrOfInstances)
           
protected  int resolveLoopCardinality(ActivityExecution execution)
           
protected  int resolveNrOfInstances(ActivityExecution execution)
           
 void setCollectionElementVariable(String collectionElementVariable)
           
 void setCollectionExpression(Expression collectionExpression)
           
 void setCollectionVariable(String collectionVariable)
           
 void setCompletionConditionExpression(Expression completionConditionExpression)
           
 void setInnerActivityBehavior(AbstractBpmnActivityBehavior innerActivityBehavior)
           
 void setIoMapping(IoMapping ioMapping)
           
 void setLoopCardinalityExpression(Expression loopCardinalityExpression)
           
protected  void setLoopVariable(ActivityExecution execution, String variableName, Object value)
           
 void signal(ActivityExecution execution, String signalName, Object signalData)
           
protected  boolean usesCollection()
           
 
Methods inherited from class org.camunda.bpm.engine.impl.bpmn.behavior.FlowNodeActivityBehavior
leave, leaveIgnoreConditions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

NUMBER_OF_INSTANCES

protected final String NUMBER_OF_INSTANCES
See Also:
Constant Field Values

NUMBER_OF_ACTIVE_INSTANCES

protected final String NUMBER_OF_ACTIVE_INSTANCES
See Also:
Constant Field Values

NUMBER_OF_COMPLETED_INSTANCES

protected final String NUMBER_OF_COMPLETED_INSTANCES
See Also:
Constant Field Values

LOOP_COUNTER

protected final String LOOP_COUNTER
See Also:
Constant Field Values

activity

protected ActivityImpl activity

innerActivityBehavior

protected AbstractBpmnActivityBehavior innerActivityBehavior

loopCardinalityExpression

protected Expression loopCardinalityExpression

completionConditionExpression

protected Expression completionConditionExpression

collectionExpression

protected Expression collectionExpression

collectionVariable

protected String collectionVariable

collectionElementVariable

protected String collectionElementVariable

ioMapping

protected IoMapping ioMapping
Constructor Detail

MultiInstanceActivityBehavior

public MultiInstanceActivityBehavior(ActivityImpl activity,
                                     AbstractBpmnActivityBehavior innerActivityBehavior)
Parameters:
innerActivityBehavior - The original ActivityBehavior of the activity that will be wrapped inside this behavior.
isSequential - Indicates whether the multi instance behavior must be sequential or parallel
Method Detail

execute

public void execute(ActivityExecution execution)
             throws Exception
Description copied from class: FlowNodeActivityBehavior
Default behaviour: just leave the activity with no extra functionality.

Specified by:
execute in interface CoreActivityBehavior<ActivityExecution>
Specified by:
execute in interface ActivityBehavior
Overrides:
execute in class FlowNodeActivityBehavior
Throws:
Exception

createInstancesIfPossible

protected boolean createInstancesIfPossible(ActivityExecution execution)
                                     throws Exception
protects the createInstance method - it is only called if the numberOfInstances is valid (negative is invalid -> exception; zero means the sub instances are skipped) Returns true if instances were created

Throws:
Exception

createInstances

protected abstract void createInstances(ActivityExecution execution,
                                        int nrOfInstances)
                                 throws Exception
Throws:
Exception

signal

public void signal(ActivityExecution execution,
                   String signalName,
                   Object signalData)
            throws Exception
Specified by:
signal in interface SignallableActivityBehavior
Overrides:
signal in class FlowNodeActivityBehavior
Throws:
Exception

lastExecutionEnded

public void lastExecutionEnded(ActivityExecution execution)
Specified by:
lastExecutionEnded in interface CompositeActivityBehavior

completing

public void completing(DelegateExecution execution,
                       DelegateExecution subProcessInstance)
                throws Exception
Description copied from interface: SubProcessActivityBehavior
called 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:
completing in interface SubProcessActivityBehavior
Throws:
Exception

completed

public void completed(ActivityExecution execution)
               throws Exception
Description copied from interface: SubProcessActivityBehavior
called after the process instance is destroyed for this activity to perform its outgoing control flow logic.

Specified by:
completed in interface SubProcessActivityBehavior
Throws:
Exception

resolveNrOfInstances

protected int resolveNrOfInstances(ActivityExecution execution)

executeOriginalBehavior

protected void executeOriginalBehavior(ActivityExecution execution,
                                       int loopCounter)
                                throws Exception
Throws:
Exception

usesCollection

protected boolean usesCollection()

isExtraScopeNeeded

public boolean isExtraScopeNeeded()

resolveLoopCardinality

protected int resolveLoopCardinality(ActivityExecution execution)

completionConditionSatisfied

protected boolean completionConditionSatisfied(ActivityExecution execution)

setLoopVariable

protected void setLoopVariable(ActivityExecution execution,
                               String variableName,
                               Object value)

getLoopVariable

protected Integer getLoopVariable(ActivityExecution execution,
                                  String variableName)

getLocalLoopVariable

protected Integer getLocalLoopVariable(ActivityExecution execution,
                                       String variableName)

callActivityEndListeners

protected void callActivityEndListeners(ActivityExecution execution)
Since no transitions are followed when leaving the inner activity, it is needed to call the end listeners yourself.


logLoopDetails

protected void logLoopDetails(ActivityExecution execution,
                              String custom,
                              int loopCounter,
                              int nrOfCompletedInstances,
                              int nrOfActiveInstances,
                              int nrOfInstances)

getLoopCardinalityExpression

public Expression getLoopCardinalityExpression()

setLoopCardinalityExpression

public void setLoopCardinalityExpression(Expression loopCardinalityExpression)

getCompletionConditionExpression

public Expression getCompletionConditionExpression()

setCompletionConditionExpression

public void setCompletionConditionExpression(Expression completionConditionExpression)

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)

setInnerActivityBehavior

public void setInnerActivityBehavior(AbstractBpmnActivityBehavior innerActivityBehavior)

setIoMapping

public void setIoMapping(IoMapping ioMapping)

executeIoMapping

protected void executeIoMapping(AbstractVariableScope scope)


Copyright © 2014 camunda services GmbH. All rights reserved.