Activiti entry, activiti

Source: Internet
Author: User

Activiti entry, activiti

Related Articles:

The most authoritative Activiti framework learning in history

Activiti entry-easily interpreting Databases

This chapter describes how to set up the Activiti framework environment. You can use the Activiti API to create 23 database tables and start the Activiti journey.

In the previous chapter, we introduced the features of 23 tables in the Activitie core database [database structure overview]. Here we will integrate Activiti into our project.

To integrate Activiti, follow these steps:

1. Download The Activti framework package from the official website;

2. The first step of framework integration is to export packages. These jar packages can be found in the official package;

Activiti uses the IOC mechanism of the Spring framework, so using the lib directory package in the root directory alone is not enough.

However, you can obtain it from the example project under the wars directory in the official package. Unzip the activiti-rest project and import all packages under the WEB-INF \ lib directory in the activiti-rest project. Add to project.

If we are using a Mysql database, the Link driver of the Mysql database is not provided in the Activiti official package. We need to import it ourselves. Manually import"Mysql-connector-java.jar", Added to the project.

3. Create a test class, create the Activiti core object PrcessEngine (process engine), and automatically create a database table. The test code is as follows:

 

In Activiti, the table is automatically created when the core process engine object is created. If the program runs normally, the database automatically creates the database according to the configuration, and then creates 23 tables.

Environment Test Improvement

In Actiiti5, the custom process will definitely operate on the database. It will be very troublesome to write a large segment of code as above, so we can write the database connection configuration into the configuration file.

There is no ready-made configuration file in official examples of Activiti5, so first find activiti-rest \ WEB-INF \ classes:

Activiti-context.xml: a configuration file similar to the spring structure, which is renamed activiti. cfg. xml after the content is cleared, used for the configuration of the Process Engine.

Configure the ProcessEngineConfiguration object according to the code above, and mainly define the database connection configuration and table creation policy. The configuration file code is as follows:

 

The Java code is as follows:

 

The createProcessEngineConfigurationFromResource parameter value is the name of activiti. cfg. xml in the configuration file we added, and the java code is executed. After the process engine object is created successfully and runs, the database automatically creates a table.

Core APIs

After the environment is successfully set up, you can use the core API to do something meaningful. Here is a brief introduction to core APIs.

LProcessEngine

Note:

1. The core class in Activiti can be understood as the big manager of Activiti, and other classes are all from him.

2. Generation Method:

We have seen two ways to create ProcessEngine, which is much simpler here. You can view the source code and find that the activiti. cfg. xml file under classpath is automatically loaded when you call the getdefadefaproceeengine method of ProcessEngines.

3. RepositoryService can be generated

4. RuntimeService can be generated

5. TaskService can be generated

Functions of each Service:

RepositoryService

Management Process Definition

RuntimeService

Execution Management, including starting, advancing, and deleting process instances

TaskService

Task Management

HistoryService

History Management (Management of executed data)

IdentityService

Organization Management

FormService

Task form Management

ManagerService

Timer Task Service

LRepositoryService

Is the repository service class of Activiti. The so-called repository refers to two files in the process definition document: bpmn files and process images.

1. Generation Method

2. DeploymentBuilder can be generated to define parameters related to process deployment.

3. Delete the Process Definition

 

LRuntimeService

Is the process execution service class of Activiti. You can obtain a lot of information about process execution from this service class.

LTaskService

Is the Task Service class of Activiti. You can operate process tasks in this service class.

LProcessDefinition

Process Definition class. The object that describes the process rule. You can obtain resource files from here.

LExecution

Activiti uses this object to describe every activity node in the process execution. In the case of no concurrency, it is the same as ProcessInstance.

LProcessInstance

Indicates an execution instance started according to the process rules. For example, if Xiaoqiang asks for leave, the system will create a separate process instance for him. A process instance includes all running nodes. We can use this object to learn the progress and other information of the current process instance.

Source code for ProcessInstance:

 

From the source code, ProcessInstance is Execution. But in the practical sense, there are some differences:

ProcessInstance and Execution are consistent in a single-line process, such as a loan process.

In this example, wire money and archive are executed concurrently. At this time, the total line represents ProcessInstance, and each activity in the sub-line represents Execution.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.