Assistant Engineer
Assistant Engineer
  • UID626
  • Fans0
  • Follows1
  • Posts53

[Activiti: Learning for practice] Core API of workflow

More Posted time:Oct 8, 2016 16:50 PM
Everything’s hard in the beginning. We need to repeat the steps for learning Java. So this time, I decided to start with Activiti "JDK".
1)     The most core class in Activiti and all the other classes are based on it.
2)     Production method:    
We have seen two ways of creating ProcessEngine previously. Here it is much simpler. The activiti.cfg.xml file under classpath will be automatically loaded when you call the getDefaultProceeEngine method of ProcessEngines.
1)     RepositoryService can be generated.
2)     RuntimeService can be generated.
3)     TaskService can be generated.
Roles of various services:

A repository service class of Activiti. The so-called repository refers to two files of the process definition documents: bpmn file and process images.
1)     Production method
2)     DeploymentBuilder can be produced, used to define parameters of process deployment.
3)     Delete process definitions.

A process execution service class of Activiti. You can learn information about the process execution from this service class.

A task service class of Activiti. You can learn the task information from this class.

A class for querying history information of Activiti. After a process is executed, this object provides us with the history information query.

A process definition class. You can get the resource files from here.

It represents the execution instance of the process definition. For example, if Fan Bingbing (a famous movie star in China) wants to take one day off, she must initiate an application of process instance. A process instance includes all the worker nodes. We can use this object to learn the progress of the current process instance. The process instance represents the maximum process branch from the process start to end, that is, one process only has one process instance.

Activiti uses this object to describe every node of the process execution. Without concurrency, the execution object is the ProcessInstance. One time of execution of the process according to the process definition rules represents the execution object.
 As shown in the figure below, it is the source code of ProcessInstance:

From the source code, we can see ProcessInstance is the execution object. But in reality, the two have differences:

In a single thread, such as the loan process in the figure above, the ProcessInstance and Execution are consistent.

The example has one feature: wiremoney (money transfer) and archive (archiving) are executed concurrently. At this time, the master line represents ProcessInstance, while every activity in the branch line represents the execution object.
To sum up:
* In a process, there can be multiple execution objects, but only one process instance.
* When the process can only be executed once according to the rule, the process instance is the execution object.