Activiti analyses - Cobub
Activiti analyses

Activiti analyses

7 years ago 2 7664

The Activiti framework is one of the workflow frameworks that have developed rapidly in recent years with its open source features.Another workflow framework, JBPM5, is currently a very popular workflow framework.While these two frameworks are two different companies, the two frameworks have a lot to do with it.Tom Baeyens, the director of the Activiti workflow framework, has previously worked for jBoss, currently the publisher of JBPM5, as the chief architect of the previous JBPM4 workflow engine.But it was speculated that Tom Baeyens left jBoss to work for Alfresco because of internal contradictions within jBoss and a serious disagreement over the future version of the workflow engine.However, for months, Tom Baeyens has launched Activiti, an open-source workflow system based on the JBPM4 workflow engine.

The Activiti framework and the JBPM5 framework are both BPM (bus-process management) systems (compliant with the BPM specification), both of which are the BPMN2 Process modeling and execution environment.Both are open source projects – follow the ASL protocol (Apache software license).Both are from JBoss (Activiti5 is a derivative of jBPM4, and jBPM5 is based on Drools Flow).They were all mature, from scratch, and they started about two and a half years ago.Both have life-cycle management of human tasks.The only difference between Activiti5 and jBPM5 is that jBPM5 describes the human task and management life cycle based on the webservice-humantask standard.If you are interested in understanding the standards and their merits, please refer to the ws-ht specification.Both use a different style of Oryx process editor to model BPMN2.JBPM5 USES the open source project branch maintained by Intalio.Activiti5 USES a branch of Signavio maintenance.

As a workflow framework, activiti is widely used in many software development companies.So if you want to use the activiti open source workflow system to implement your own business system, the first step is to familiarize yourself with the BPMN 2.0 specification, which is not necessary.The BPMN 2.0 specification is implemented as a standard for the establishment of some basic models that may be encountered in the workflow business system.

The current mainstream Java development IDE is eclipse and intellij idea.Both development tools have the development of Activiti, with an interface – style process editor.Through the business process. The process editor will to parse and generate a business process. BPMN files, it is essentially a. XML file, the file of declarative illustrates the implementation of each process and business types, subsequent through Activiti can process engine to parse the XML file, and perform the corresponding operation and process of the jump function.

Here is the Github community address of Activiti, which can be downloaded for consultation.So what is the workflow engine that the Activiti workflow system is based on?The Activiti workflow provides a set of business system based on Java API interface, the process engine actually it is an instance of class class, only through this object can be obtained to all about the content of workflow business process and operation of all processes.Figure 1.1 is the workflow engine object and the objects it can derive:

The activiti. CFG. XML file as the core configuration files, the profile of integration in the Spring IOC container, can produce ProcessEngineConfiguration object, the object is the process engine configuration object, ProcessEngine object for the process engine object, the object is the core of workflow business system, all operations are derived by the object object implementation.Please refer to the Activiti5 API documentation for the operation of the object.

The current Activiti5 workflow business system involves 23 tables, as shown in figure 1.2. Of course, these tables are not required, and some tables that are not used are naturally unnecessary. Currently Activiti5’s workflow business system supports mainstream databases such as MySql, Oracle, and DB2, and the default database is H2. Related database configuration reference documentation.

The Activiti workflow business system integrates very well with Spring, which is a good feature for developers who are familiar with the Spring framework. But not with Activiti framework encapsulates the business functions, just realized the basic operation, can make the users better achieve certain function, but due to the Activiti and there is no effective encapsulation of rejected so if developers want to use the rejected function, it needs to himself through Activiti API manual packaging an interface.
So how do we use the Activiti workflow framework? Next, let’s briefly talk about the use of activiti. To use the activiti framework, take a look at activiti’s basic programming framework:

The first step is to develop the tools, which we have previously said can be used to integrate eclipse or intellij idea that integrates the acitiviti interface process editor functionality. So here we are using eclipse development tools. As shown in the figure below:

Step 2: you need to introduce the corresponding activiti jar package, which can be downloaded manually, or you can use the maven project management tool to manage the package. So here we use the maven project management tool:

Step 3: as we said earlier, the activiti workflow business system requires 23 tables, so the creation of the table is also essential, as we’ve said before. You can create it through activiti’s workflow engine object. We’re going to create it this way.

After completing the three steps above, then it’s easy to implement a leave business process. First, draw the flow diagram, set the process start node start and end node end, set the task userTask. As shown in the figure below:

It is important to note that the flow chart of every userTask need to set up the next person to deal with assignee, can use the process variables dynamic set processing, also can be directly fixed process, here we fixed processing first. As shown in the figure below:

Finished off after a business process, let’s take a look at what the BPMN files is a type of document, we use the TXT text editor to open, found that is similar to an XML file that is only suffix for. BPMN. As shown in the figure below:

The next step is to actually write the code. We said that in front of the activiti framework of workflow and Spring almost perfect fusion, but here we only involve the activiti analyses, so this article just USES the native API interface to realize the simple process for leave.
First, use the workflow engine configuration object to load the activiti.cfg.xml file, as mentioned earlier, activiti.cfg.xml is the configuration file for the workflow, and the contents of activiti are posted here, and the database used is mysql database.

You can use the process engine object ProcessEngineConfiguration loading configuration files, through the configuration object for ProcessEngine object, but we are not in the form of a configuration file to create this object, then all of the content can be used to complete all the contents of the object derives from function. Actually, the code that created the table just now can do this.
Use the ProcessEngine object to load the leave process configuration file to create the process definition template, which is the deployment process. Next, create a process instance object through the process definition template, fill in the leave form, and save the leave sheet, which is to create a leave process.

This code creates the definition of the leave process.

Among them, the engine for the ProcessEngine instance objects, processDefinitionId Id for the process definition, the value is generated when creating a process definition, run. StartProcessIntanceById to create a process instance object by process definition Id, this process instance object is corresponding to the leave process at a time.
In by creating a process for leave, and then submit the leave process (for example: the department manager, etc.) to the superior department, the department manager, ask for leave to show that the process is completed, 10002 a unique identifier for the task. Each task in the corresponding flowchart corresponds to a taskId.

Ask for leave in this article, the process of the examples are not covered by the operation of the database, that is to say, all the contents of the database is completed by activiti framework for us, we only need to implement the corresponding business processes. This greatly simplifies the relevant content of the workflow, but if you want to use the activiti workflow framework, you must have a thorough and detailed understanding of the API documentation. If you want to learn more about activiti’s database operations. Please refer to relevant information.