decisionimpl.java

来自「一个java工作流引擎」· Java 代码 · 共 67 行

JAVA
67
字号
package org.jbpm.model.definition.impl;

import org.jbpm.*;
import org.jbpm.delegation.*;
import org.jbpm.model.definition.*;
import org.jbpm.model.execution.impl.*;

public class DecisionImpl extends NodeImpl implements Decision {

  private transient DelegationImpl decisionDelegation = null;
  
  public DecisionImpl() {}

  public DecisionImpl( String name ) {
    super( name );
  }

  public DelegationImpl getDecisionDelegation() { return this.decisionDelegation; }
  public void setDecisionDelegation(DelegationImpl decisionDelegation) { this.decisionDelegation = decisionDelegation; }

	public void acceptToken(ExecutionContextImpl executionContext) throws ExecutionException {
    // execute the actions on node entrance
    executeActions( EventType.DECISION_ENTER, executionContext );
    
    DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
    String transitionName = null;

    try {
      transitionName = decisionHandler.decide( executionContext );
    } catch (RuntimeException e) {
      decisionDelegation.handleException(e);
    }
    
    if ( transitionName == null ) {
      throw new IllegalTransitionException( "decision-handler of decision '" + name + "' return null instead of the name of a leaving transition" );
    }
    TransitionImpl transition = getLeavingTransition( transitionName );
    if ( transition == null ) {
      throw new IllegalTransitionException( "'" + transitionName + "' is not a leaving transition of decision '" + name + "'" );
    }

    // execute the actions on node exit
    executeActions( EventType.DECISION_LEAVE, executionContext );
    
    transition.acceptToken( executionContext );
  }
  
  public EventType getDefaultEventType() {
    return EventType.DECISION_ENTER; 
  }
  
  public String toString() {
    return "decision["+name+"]"; 
  }

  public void toXml(org.dom4j.Element element) {
    toXmlNameAndDescription( element );
    decisionDelegation.toXml( element.addElement( "delegation" ));
    toXmlActions( element );
    toXmlTransitions( element );
  }

	public String getTagName() {
		return "decision";
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?