Activiti Getting Started--Introduction to environment building and core API

Source: Internet
Author: User

Related articles:

"The most authoritative Activiti Framework study guide in History"

Getting started with Activiti-easy interpretation of the database

In this chapter, we mainly explain the construction of the Activiti framework environment, and the ability to create 23 database tables using the Activiti API to formally begin the Activiti journey.

In the previous chapter, introduced the Activitie core Database 23 table features " Database structure Introduction ", here we are going to integrate Activiti into our project.

The integration Activiti steps are as follows:

1, download ACTIVTI Framework package from official website;

2, framework integration The first step is the guide package, these jar packages can be found under the official package;

Because Activiti uses the IOC mechanism of the spring framework, it is not sufficient to use the packages of the Lib directory under the root directory alone.

However, it can be obtained from the sample project under the Wars directory in the official package. Unzip the Activiti-rest project and import all the packages in the Web-inf\lib directory in the Activiti-rest project. Added to the project.

If we are using a MySQL database, the MySQL database link driver Activiti is not available in the official package and needs to be imported by us. Manually import "Mysql-connector-java.jar" and add it to the project.

3, the new test class, create Activiti Core object Prcessengine (Process engine), the database table is automatically created, the test code is as follows:

In Activiti, tables are automatically created when you create a core process engine object. If the program executes correctly, the database will automatically build the library according to the configuration, and then create 23 tables.

Environmental testing Improvements

The custom process in Actiiti5 is bound to operate into the database, and it can be cumbersome to write a large piece of code as above, so we could write the database connection configuration to the configuration file.

In Activiti5 's official example there is no ready-made configuration file, so first find activiti-rest\web-inf\classes below:

Activiti-context.xml: A configuration file similar to the spring structure, which is renamed as Activiti.cfg.xml after emptying the content, and is used for the configuration of the process engine.

According to the above code configuration Processengineconfiguration object, the main definition of the database connection configuration and build table policy, the configuration file code is as follows:

The Java code is as follows:

The Createprocessengineconfigurationfromresource parameter value is the name of the profile activiti.cfg.xml that we added, execute Java code, and the database will automatically build the table after the process engine object creation runs successfully.

Introduction to Core APIs

After the environment is built, you can then use the core API to do something meaningful. Let's start with a brief introduction to the core API.

Lprocessengine

Description

1. The most core class in Activiti can be understood as the butler of Service Activiti, and other classes are made by him.

2. Mode of production:

There are two ways to create a processengine (process engine), which is much simpler here. View Source will find: Call Processengines's Getdefaultproceeengine method will automatically load classpath under the name of the Activiti.cfg.xml file.

3. Can produce Repositoryservice

4. Can produce Runtimeservice

5. Can produce Taskservice

The role of each service:

Repositoryservice

Manage process definition

Runtimeservice

execution management, including initiating, advancing, deleting process instances

Taskservice

Task management

Historyservice

Calendar History management (management of finished data)

Identityservice

Organization Management

Formservice

Tasks Form Management

ManagerService

Timer task Service

Lrepositoryservice

is the Activiti warehouse service class. The so-called warehouse refers to two files in the process definition document: BPMN files and flowchart slices.

1. Mode of production

2. Deploymentbuilder can be generated to define parameters related to the process deployment

3. Delete the process definition

Lruntimeservice

Is Activiti's Process Execution service class. You can get a lot of information about process execution from this service class.

Ltaskservice

is the task service class for Activiti. The process tasks can be manipulated through this service class.

Lprocessdefinition

The process definition class. An object that describes the rules of a process. Resource files can be obtained from here.

Lexecution

Activiti uses this object to describe each activity node that the process executes. In the case of no concurrency, the same processinstance.

Lprocessinstance

Represents a single instance of execution that is initiated by a process rule. For example, the system will create a separate process instance for him when he starts to leave. A process instance includes all the running nodes. We can use this object to understand the progress of the current process instance and other information.

Source code for ProcessInstance:

From the source code can be seen processinstance is execution. But in practical sense there are differences:

In a single-line process, such as the loan process, processinstance and execution are consistent.

This example has a feature: wire money (remittance) and archive (archive) are executed concurrently. At this time, the total line represents processinstance, and each activity in the sub-line represents execution.

Activiti Getting Started--Introduction to environment building and core API

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.