The engine API is the most common way of interacting with Activiti. The central starting point is the ProcessEngine, which can be created in several ways as described in the configuration section. From the ProcessEngine, you can obtain the various services that contain the workflow/BPM methods. ProcessEngine and the services objects are thread safe. So you can keep a reference to 1 of those for a whole server.
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
RepositoryService repositoryService = processEngine.getRepositoryService();
TaskService taskService = processEngine.getTaskService();
ManagementService managementService = processEngine.getManagementService();
IdentityService identityService = processEngine.getIdentityService();
HistoryService historyService = processEngine.getHistoryService();
FormService formService = processEngine.getFormService();
DynamicBpmnService dynamicBpmnService = processEngine.getDynamicBpmnService();
1. ProcessEngine:流程引擎的抽象,通过它我们可以获得我们需要的一切服务。
2. RepositoryService:Activiti中每一个不同版本的业务流程定义都需要使用一些定义文件,部署文件和支持数据(例如BPMN2.0 XML文件,表单定义文件,流程定义图像文件等),这些文件都存储在Activiti内建的Repository中。RepositoryService提供了对 repository的存取服务。
3. RuntimeService:在Activiti中,每当一个流程定义被启动一次之后,都会生成一个相应的流程对象实例。RuntimeService提供了启动流程、查询流程实例、设置获取流程实例变量等功能。此外它还提供了对流程部署,流程定义和流程实例的存取服务。
4. TaskService: 在Activiti中业务流程定义中的每一个执行节点被称为一个Task,对流程中的数据存取,状态变更等操作均需要在Task中完成。TaskService提供了对用户Task 和Form相关的操作。它提供了运行时任务查询、领取、完成、删除以及变量设置等功能。
5.IdentityService: Activiti中内置了用户以及组管理的功能,必须使用这些用户和组的信息才能获取到相应的Task。IdentityService提供了对Activiti 系统中的用户和组的管理功能。
6. ManagementService: ManagementService提供了对Activiti流程引擎的管理和维护功能,这些功能不在工作流驱动的应用程序中使用,主要用于Activiti系统的日常维护。
7. HistoryService: HistoryService用于获取正在运行或已经完成的流程实例的信息,与RuntimeService中获取的流程信息不同,历史信息包含已经持久化存储的永久信息,并已经被针对查询优化。
ProcessEngines.getDefaultProcessEngine()
will initialize and build a process engine the first time it is called and afterwards always return the same process engine. Proper creation and closing of all process engines can be done withProcessEngines.init()
and ProcessEngines.destroy()
.
The ProcessEngines class will scan for all activiti.cfg.xml
and activiti-context.xml
files. For allactiviti.cfg.xml
files, the process engine will be built in the typical Activiti way:ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(inputStream).buildProcessEngine()
. For all activiti-context.xml
files, the process engine will be built in the Spring way: First the Spring application context is created and then the process engine is obtained from that application context.
All services are stateless. This means that you can easily run Activiti on multiple nodes in a cluster, each going to the same database, without having to worry about which machine actually executed previous calls. Any call to any service is idempotent regardless of where it is executed.
The RepositoryService is probably the first service needed when working with the Activiti engine. This service offers operations for managing and manipulating deployments
and process definitions
. Without going into much detail here, a process definition is a Java counterpart of BPMN 2.0 process. It is a representation of the structure and behaviour of each of the steps of a process. A deployment
is the unit of packaging within the Activiti engine. A deployment can contain multiple BPMN 2.0 xml files and any other resource. The choice of what is included in one deployment is up to the developer. It can range from a single process BPMN 2.0 xml file to a whole package of processes and relevant resources (for example the deployment hr-processescould contain everything related to hr processes). The RepositoryService
allows to deploy
such packages. Deploying a deployment means it is uploaded to the engine, where all processes are inspected and parsed before being stored in the database. From that point on, the deployment is known to the system and any process included in the deployment can now be started.
Furthermore, this service allows to
-
Query on deployments and process definitions known to the engine.
-
Suspend and activate deployments as a whole or specific process definitions. Suspending means no further operations can be done on them, while activation is the opposite operation.
-
Retrieve various resources such as files contained within the deployment or process diagrams that were auto generated by the engine.
-
Retrieve a POJO version of the process definition which can be used to introspect the process using Java rather than xml.
While the RepositoryService
is rather about static information (i.e. data that doesn’t change, or at least not a lot), theRuntimeService is quite the opposite. It deals with starting new process instances of process definitions. As said above, aprocess definition
defines the structure and behaviour of the different steps in a process. A process instance is one execution of such a process definition. For each process definition there typically are many instances running at the same time. The RuntimeService
also is the service which is used to retrieve and store process variables
. This is data which is specific to the given process instance and can be used by various constructs in the process (e.g. an exclusive gateway often uses process variables to determine which path is chosen to continue the process). The Runtimeservice
also allows to query on process instances and executions. Executions are a representation of the 'token'
concept of BPMN 2.0. Basically an execution is a pointer pointing to where the process instance currently is. Lastly, the RuntimeService
is used whenever a process instance is waiting for an external trigger and the process needs to be continued. A process instance can have variouswait states
and this service contains various operations to signal the instance that the external trigger is received and the process instance can be continued.
Tasks that need to be performed by actual human users of the system are core to a BPM engine such as Activiti. Everything around tasks is grouped in the TaskService, such as
-
Querying tasks assigned to users or groups
-
Creating new standalone tasks. These are tasks that are not related to a process instances.
-
Manipulating to which user a task is assigned or which users are in some way involved with the task.
-
Claiming and completing a task. Claiming means that someone decided to be the assignee for the task, meaning that this user will complete the task. Completing means doing the work of the tasks. Typically this is filling in a form of sorts.
The IdentityService is pretty simple. It allows the management (creation, update, deletion, querying, …) of groups and users. It is important to understand that Activiti actually doesn’t do any checking on users at runtime. For example, a task could be assigned to any user, but the engine does not verify if that user is known to the system. This is because the Activiti engine can also be used in conjunction with services such as LDAP, Active Directory, etc.
The FormService is an optional service. Meaning that Activiti can perfectly be used without it, without sacrificing any functionality. This service introduces the concept of a start form and a task form. A start form is a form that is shown to the user before the process instance is started, while a task form is the form that is displayed when a user wants to complete a form. Activiti allows to define these forms in the BPMN 2.0 process definition. This service exposes this data in an easy way to work with. But again, this is optional as forms don’t need to be embedded in the process definition.
The HistoryService exposes all historical data gathered by the Activiti engine. When executing processes, a lot of data can be kept by the engine (this is configurable) such as process instance start times, who did which tasks, how long it took to complete the tasks, which path was followed in each process instance, etc. This service exposes mainly query capabilities to access this data.
The ManagementService is typically not needed when coding custom application using Activiti. It allows to retrieve information about the database tables and table metadata. Furthermore, it exposes query capabilities and management operations for jobs. Jobs are used in Activiti for various things such as timers, asynchronous continuations, delayed suspension/activation, etc. Later on, these topics will be discussed in more detail.
The DynamicBpmnService can be used to change part of the process definition without needing to redeploy it. You can for example change the assignee definition for a user task in a process definition, or change the class name of a service task.
The database names of Activiti all start with ACT_. The second part is a two-character identification of the use case of the table. This use case will also roughly match the service API.
ACT_RE_*: RE stands for repository. Tables with this prefix contain static information such as process definitions and process resources (images, rules, etc.).
ACT_RU_*: RU stands for runtime. These are the runtime tables that contain the runtime data of process instances, user tasks, variables, jobs, etc. Activiti only stores the runtime data during process instance execution, and removes the records when a process instance ends. This keeps the runtime tables small and fast.
ACT_ID_*: ID stands for identity. These tables contain identity information, such as users, groups, etc.
ACT_HI_*: HI stands for history. These are the tables that contain historic data, such as past process instances, variables, tasks, etc.
ACT_GE_*: general data, which is used in various use cases.
相关推荐
Activiti 是一个开源的工作流引擎,它主要用于自动化业务流程。这个压缩包文件包含了与Activiti相关的学习文档和数据表说明,对于理解并掌握Activiti的工作原理和应用具有重要作用。尽管"activiti-explorer.war"文件...
工作流引擎Activiti的介绍和简单的例子
Activiti是一款开源的工作流引擎,它基于模型驱动的架构(MDA),专为现代企业应用程序设计,用于处理业务流程自动化。这个"Activiti工作流示例Activiti Demo"提供了完整的源代码,帮助开发者深入理解并实际操作...
工作流引擎Activiti7是企业级业务流程自动化的重要工具,它是一个开源的、基于Java的BPM(Business Process Management)平台。本资料旨在提供Activiti7的基础知识和进阶技术,帮助用户深入理解和掌握这一强大的流程...
activiti工作流文档,超详细,从0基础开始入门,包括数据库介绍、核心api等介绍,满足日常开发所需
Activiti作为一个工作流引擎,允许开发者通过编程或使用图形化工具定义、执行和管理这些流程。 在Activiti中,流程定义是用BPMN 2.0(Business Process Model and Notation)语言编写的,这是一种国际标准,用于...
Activiti工作流课程Activiti工作流课程Activiti工作流课程Activiti工作流课程Activiti工作流课程Activiti工作流课程
Activiti工作流引擎是一款开源的企业级业务流程管理(BPM)和工作流系统,它为组织提供了一种灵活、可扩展的方式来设计、执行和管理业务流程。在面试中,了解Activiti的核心服务对于理解其工作原理和实际应用至关...
Activiti 是一个开源的工作流和业务流程管理(BPM)引擎,它可以帮助企业构建灵活、可扩展的业务流程应用。在本项目中,我们重点探讨的是Activiti 6.0版本,它集成了Spring Boot框架,使得开发和部署流程应用程序变...
工作流引擎Activiti是开源的工作流引擎,这是一份简单的使用总结,希望对大家有用。
根据提供的文件信息,我们可以深入探讨Activiti工作流框架的相关知识点。 ### Activiti工作流框架概述 Activiti工作流框架是一款由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架。它以其灵活性、易用...
【工作流Activiti5学习总结】 工作流管理系统(Workflow Management System, WfMS)是企业信息化建设中的重要组成部分,它负责协调和管理业务流程。Activiti5是一款开源的工作流引擎,由Alfresco公司开发,它基于...
本项目“工作流activiti实战项目源码”提供了使用Activiti实现工作流的实例,适合开发者进行学习和实践。 在深入理解这个项目之前,我们先来了解一下Activiti的基本概念和功能: 1. **什么是Activiti**:Activiti ...
### Activiti工作流知识点概述 #### 一、工作流概念及其执行过程 1. **工作流定义**: - 工作流是指“业务过程的部分或整体在计算机应用环境下的自动化”。具体而言,它旨在通过预定义的规则来自动处理文档、信息...
Activiti7工作流引擎教学视频 springboot-activiti是一个SpringBoot集成activiti实现在创建、部署流程、复制流程、删除流程以及流程规则配置,实现工单流程工作流流转和业务处理
疯狂工作流讲义PDF,电子版。非常经典。京东销量最高的activiti书籍
本文将深入探讨“myeclipse工作流插件activiti-designer-5.15.0”及其在MyEclipse集成开发环境中的应用。 首先,`Activiti`是一个开源的工作流引擎,它基于模型驱动的架构(MDA),支持BPMN 2.0标准,提供强大的...
在Java工程中使用Activiti工作流技术,我们可以实现复杂的业务流程自动化,从而提高效率和管理水平。首先,我们需要理解工作流的基本概念。工作流(Workflow)是指在计算机环境中自动化执行的业务过程,它涉及文档、...
【标题】"activiti工作流项目"是一个基于Java技术栈实现的工作流管理系统示例,它集成了SpringMVC、Hibernate和Activiti等关键组件。这个项目旨在演示如何在实际应用中利用Activiti来构建动态表单和处理各种流程审批...