⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 actionimpl.java

📁 一个java工作流引擎
💻 JAVA
字号:
package org.jbpm.model.definition.impl;

import org.apache.commons.logging.*;
import org.jbpm.*;
import org.jbpm.delegation.*;
import org.jbpm.model.definition.*;
import org.jbpm.model.execution.impl.*;
import org.jbpm.model.log.impl.*;

public class ActionImpl implements Action {

  private static boolean executeActionsFlag = true;

  private Long id = null;
  private int index = -1;
  private EventType eventType = null;
  private ElementImpl element = null;
  private transient DelegationImpl actionDelegation = null;

  public static void setExecuteActionsFlag(boolean executeActions) {
    executeActionsFlag = executeActions;
  }

  public ActionImpl() {
  }

  public ActionImpl(EventType eventType, DelegationImpl actionDelegation) {
    this.eventType = eventType;
    this.actionDelegation = actionDelegation;
  }

  public Long getId() {
    return this.id;
  }
  public void setId(Long id) {
    this.id = id;
  }

  public int getIndex() {
    return this.index;
  }
  public void setIndex(int index) {
    this.index = index;
  }

  public EventType getEventType() {
    return eventType;
  }
  public void setEventType(EventType eventType) {
    this.eventType = eventType;
  }

  public Element getElement() {
    return element;
  }
  public void setElement(ElementImpl element) {
    this.element = element;
  }

  public DelegationImpl getActionDelegation() {
    return this.actionDelegation;
  }
  public void setActionDelegation(DelegationImpl actionDelegation) {
    this.actionDelegation = actionDelegation;
  }

  public String toString() {
    if (actionDelegation != null) {
      return "action[" + id + "|" + actionDelegation.getClassName() + "]";
    } else {
      return "action[" + id + "]";
    }
  }

  public void execute(ExecutionContextImpl executionContext)
    throws DelegationException {
    if (executeActionsFlag) {

      ActionHandler actionHandler =
        (ActionHandler) actionDelegation.instantiate();

      try {
        actionHandler.execute(executionContext);
      } catch (RuntimeException e) {
        actionDelegation.handleException(e);
      }

      TokenImpl token = (TokenImpl) executionContext.getToken();
      token.add(new ActionLogImpl(this));
    }
    else {
      log.debug("Skipping action execution : " + actionDelegation.getClassName());
    }
  }

  public void undo(ExecutionContextImpl executionContext)
    throws DelegationException {
    UndoableActionHandler undoableActionHandler =
      (UndoableActionHandler) actionDelegation.instantiate();

    try {
      undoableActionHandler.undo(executionContext);
    } catch (RuntimeException e) {
      actionDelegation.handleException(e);
    }
  }

  public void toXml(org.dom4j.Element dom4jElement) {
    if (eventType != null) {
      if (eventType != element.getDefaultEventType()) {
        dom4jElement.addAttribute("event-type", eventType.toString());
      }
    }
    actionDelegation.toXml(dom4jElement.addElement("delegation"));
  }

  private static Log log = LogFactory.getLog(ActionImpl.class);
}

⌨️ 快捷键说明

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