首页 > 其他分享 >Activiti7 基础篇 Activiti类关系图

Activiti7 基础篇 Activiti类关系图

时间:2023-03-19 21:56:17浏览次数:38  
标签:xml ProcessEngineConfiguration 配置文件 activiti cfg Activiti 基础 Activiti7

上面我们完成了Activiti数据库表的生成,java代码中我们调用Activiti的工具类,下面来了解Activiti的类关系

 一、类关系图

 

 

新版本,IdentityService,FormService两个Serivce都已经删除了。

 

二、 activiti.cfg.xml

activiti的引擎配置文件,包括:ProcessEngineConfiguration的定义、数据源定义、事务管理器等,此文件其实就是一个spring配置文件。

三、 流程引擎配置类

流程引擎的配置类(ProcessEngineConfiguration),通过ProcessEngineConfiguration可以创建工作流引擎ProceccEngine,常用的两种方法如下:

四、 StandaloneProcessEngineConfiguration

使用StandaloneProcessEngineConfigurationActiviti可以单独运行,来创建ProcessEngine,Activiti会自己处理事务。

配置文件方式:

通常在activiti.cfg.xml配置文件中定义一个id为 processEngineConfiguration 的bean.

方法如下:

<bean id="processEngineConfiguration"
          class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <!--配置数据库相关的信息-->
        <!--数据库驱动-->
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
        <!--数据库链接-->
        <property name="jdbcUrl" value="jdbc:mysql:///activiti"/>
        <!--数据库用户名-->
        <property name="jdbcUsername" value="root"/>
        <!--数据库密码-->
        <property name="jdbcPassword" value="123456"/>
        <!--actviti数据库表在生成时的策略  true - 如果数据库中已经存在相应的表,那么直接使用,如果不存在,那么会创建-->
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>

还可以加入连接池:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contex
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql:///activiti"/>
        <property name="username" value="root"/>
        <property name="password" value="123456"/>
        <property name="maxActive" value="3"/>
        <property name="maxIdle" value="1"/>
    </bean>
    <!--在默认方式下 bean的id  固定为 processEngineConfiguration-->
    <bean id="processEngineConfiguration"
          class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <!--引入上面配置好的 链接池-->
        <property name="dataSource" ref="dataSource"/>
        <!--actviti数据库表在生成时的策略  true - 如果数据库中已经存在相应的表,那么直接使用,如果不存在,那么会创建-->
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>
</beans>

五、 SpringProcessEngineConfiguration

通过org.activiti.spring.SpringProcessEngineConfiguration 与Spring整合。

创建spring与activiti的整合配置文件:

activity-spring.cfg.xml(名称可修改)

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
 xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
       http://www.springframework.org/schema/mvc 
       http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
       http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd 
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-3.1.xsd ">
    <!-- 工作流引擎配置bean -->
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
       <!-- 数据源 -->
       <property name="dataSource" ref="dataSource" />
       <!-- 使用spring事务管理器 -->
       <property name="transactionManager" ref="transactionManager" />
       <!-- 数据库策略 -->
       <property name="databaseSchemaUpdate" value="drop-create" />
       <!-- activiti的定时任务关闭 -->
      <property name="jobExecutorActivate" value="false" />
    </bean>
    <!-- 流程引擎 -->
    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
       <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>
    <!-- 资源服务service -->
    <bean id="repositoryService" factory-bean="processEngine"
       factory-method="getRepositoryService" />
    <!-- 流程运行service -->
    <bean id="runtimeService" factory-bean="processEngine"
       factory-method="getRuntimeService" />
    <!-- 任务管理service -->
    <bean id="taskService" factory-bean="processEngine"
       factory-method="getTaskService" />
    <!-- 历史管理service -->
    <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
    <!-- 用户管理service -->
    <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
    <!-- 引擎管理service -->
    <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
    <!-- 数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
       <property name="driverClassName" value="com.mysql.jdbc.Driver" />
       <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
       <property name="username" value="root" />
       <property name="password" value="mysql" />
       <property name="maxActive" value="3" />
       <property name="maxIdle" value="1" />
    </bean>
    <!-- 事务管理器 -->
    <bean id="transactionManager"
     class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
       <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 通知 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
       <tx:attributes></tx:attributes>
           <!-- 传播行为 -->
           <tx:method name="save*" propagation="REQUIRED" />
           <tx:method name="insert*" propagation="REQUIRED" />
           <tx:method name="delete*" propagation="REQUIRED" />
           <tx:method name="update*" propagation="REQUIRED" />
           <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
           <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
        </tx:attributes>
    </tx:advice>
    <!-- 切面,根据具体项目修改切点配置 -->
    <aop:config proxy-target-class="true">
       <aop:advisor advice-ref="txAdvice"  pointcut="execution(* com.itheima.ihrm.service.impl.*.(..))"* />
   </aop:config>
</beans>

创建processEngineConfiguration

ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml")

上边的代码要求activiti.cfg.xml中必须有一个processEngineConfiguration的bean

也可以使用下边的方法,更改bean 的名字:

ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource, String beanName);

 

标签:xml,ProcessEngineConfiguration,配置文件,activiti,cfg,Activiti,基础,Activiti7
From: https://www.cnblogs.com/mangoubiubiu/p/17234477.html

相关文章

  • Activiti7 基础篇 环境搭建
    一、创建Maven工程及相关配置1、pom.xml<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/......
  • 打牢JavaScript 基础,看这篇
    原文链接:​   ​​https://note.noxussj.top/?source=51cto​​变量声明​在JavaScript程序中,使用一个变量之前应当先声明。变量是使用关键字 ​​var​​ 来声明的......
  • Activiti7 基础篇 介绍及概述
    一、工作流介绍1.1概念工作流(Workflow),就是通过计算机对业务流程自动化执行管理。它主要解决的是“使在多个参与者之间按照某种预定义的规则自动进行传递文档、信息或......
  • 性能测试基础知识体系
    转载:https://www.cnblogs.com/imyalost/p/14966389.html谈起性能测试,大家经常聊的是高并发、高可用、性能优化、全链路压测等Topic,听起来都挺高大上,但这些概念追本溯源,还......
  • python基础(9)
    1.注册功能:用户输入账号密码,按照“egon:18”的格式存入文件。  2.基于上述注册信息,完成验证功能即用户验证的账号密码来源于文件验证成功打印loginsucessful验证......
  • Android 开发入门(1)| 准备 | 开发环境 | 开发基础
    0x01准备(1)概述安卓(Android)基于Linux内核开发的操作系统,由Google等领导开发。(2)版本Android版本号API发布时间Android14-2023Android13332022.......
  • 基础dp
    珂爱的dp们区间dp在\(dp\)的状态设计中,设计以区间为状态的\(dp\)或以区间为阶段进行的\(dp\)即为区间\(dp\),一般有最值问题和计数问题,一般方程为\[f[l][r][.........
  • acwing算法基础课整理
    acwing算法基础课整理模板基础算法排序快速排序#include<iostream>usingnamespacestd;constintN=1e6+10;intq[N];intn;voidquick_sort(intq[],in......
  • 最小生成树及相关基础应用
    算法kruskal,这是我春季赛前突击的一个算法,当时我貌似并查集都不怎么会,还是现学的...先说一下这个基础算法的思路吧,先把所有边按照边权排序,把每棵树当作一棵子树,如果他们在......
  • Linux基础命令
    关机  shutdown     poweroff重启  reboot          syncsu  pwd:查看当前工作目录的路径su:用来切换用户身份ls:-a查看......