运行 Activiti

java 专栏收录该内容
88 篇文章 0 订阅

1.maven 配置文件

日志抽象类

import java.util.logging.Handler;import java.util.logging.LogManager;
import java.util.logging.Logger;import org.activiti.engine.impl.util.LogUtil;
import org.slf4j.bridge.SLF4JBridgeHandler;
public abstract class AbstractTest {  
    @BeforeClass  
    public static void routeLoggingToSlf4j() {                
        LogUtil.readJavaUtilLoggingConfigFromClasspath();    
        Logger rootLogger =        LogManager.getLogManager().getLogger("");    
        Handler[] handlers = rootLogger.getHandlers();    
        for (int i = 0; i < handlers.length; i++) {      
            rootLogger.removeHandler(handlers[i]);    
        }    
        SLF4JBridgeHandler.install();  
    }
}

3三种不同的工作方式

 

4.activiti 的API

2.启动引擎, 加载流程, 发起流程实例和查看待办任务

3.流程图示例

 

4.启动流程会执行到用户任务

5.测试用例

6.UserTask

<userTask id="usertask1" name="Complete order" activiti:candidateGroups="sales">      
    <documentation>book order user task</documentation>
</userTask>

7. 一个userTask 的状态

8. 给任务设置 candidate和complete

9.删除部署的流程

10.activiti内部的用户和用户组

11.在流程配置中,设置环境变量

12.Activiti会一面执行,一面往历史表里假数据

13.归档有4个等级可以配置

14.java对象执行activiti任务

public class ValidateService implements JavaDelegate {

  @Override
  public void execute(DelegateExecution execution) {
    System.out.println("execution id " + execution.getId());
    Long isbn = (Long) execution.getVariable("isbn");
    System.out.println("received isbn " + isbn);
    execution.setVariable("validatetime", new Date());
  }
}

14.指定执行人

<userTask id="usertask1" name="Complete order">
  <documentation>book order user task</documentation>
  <potentialOwner>
    <resourceAssignmentExpression>
      <formalExpression>sales</formalExpression>
    </resourceAssignmentExpression>
  </potentialOwner>
</userTask>

15 配置异步taskService

<serviceTask id="serviceTask1"
  name="Validate order"
  activiti:async="true"
  activiti:class="org.bpmnwithactiviti.chapter4.java.LongValidateService"/>

16. 通过任务注入 

<serviceTask id="serviceTask1" name="Validate order"
    activiti:class="org.bpmnwithactiviti.chapter4.
          java.ValidateServiceWithFields">
  <extensionElements>
    <activiti:field name="validatetext"
        stringValue="Validaton done at "/>
       <activiti:field name="isbn">
      <activiti:expression>
        ${isbn > 999999 ? isbn : 1000000 + isbn}
      </activiti:expression>
    </activiti:field>
  </extensionElements>
</serviceTask>
public class BookOrder implements Serializable {

  private static final long serialVersionUID = 1L;

  public Date validate(Long isbn) {
    System.out.println("received isbn " + isbn);
    return new Date();
  }
}
<serviceTask id="serviceTask1" name="Validate order"
    activiti:expression="#{bookOrder.validate(isbn)}"
    activiti:resultVariableName="validatetime"/>
<serviceTask id="serviceTask1" name="Validate order"
    activiti:expression="#{bookOrder.isbn}"
    activiti:resultVariableName="isbn"/>
<serviceTask id="serviceTask1" name="Validate order"
    activiti:delegateExpression="#{orderValidator}"/>

17. Activiti的Spring配置

18.嵌入Spring后的单元测测试

19.Spring Java Service Task

<serviceTask id="serviceTask1"
             name="Validate order"
             activiti:expression="#{order.validate(execution)}"/>
<bean id="order"
    class="org.bpmnwithactiviti.chapter4.spring.OrderService" />
public class OrderService {
  public void validate(DelegateExecution execution) {
    System.out.println("validating order for isbn " +
        execution.getVariable("isbn"));
  }
}

 

 

 

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值