In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what the commonly used service components in Activiti are, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Activiti's series of operations for workflow are encapsulated in his service components, so to learn activiti, the first thing to do is to learn to understand his common service components.
A basic introduction to common service components of 1.ativiti:
RepositoryService: provides a series of API for managing process definition and process deployment.
RuntimeService: manage and control process instances while the process is running.
TaskService: manage process tasks, such as task reminders, task completion, and creation of task sharing tasks.
IdentityService: provides an API for managing process role data, including user groups, users, and their relationships.
ManagementService: provides services for managing and maintaining the process engine.
HistoryService: operate on the historical data of the process, including querying and deleting the historical data.
FormService: form Service, used to read form data related to processes and tasks.
DynamicBpmnService: with this service, partial modifications to the process model can be implemented without redeploying the process model.
two。 How to understand the relationship between service components
How to understand the relationship between service components must be understood from the perspective of the use of workflow.
Take the reimbursement process as an example:
The workflow does not appear out of thin air, and the system generates the workflow without foundation when the employee puts forward the reimbursement request. Instead, the administrator is required to specify each link and condition of the reimbursement workflow. So how can administrators use activiti to define a new workflow? RepositoryService provides us with a series of methods related to this, allowing us to define workflows and deploy them to the server. RepositoryService can be understood as creating a class in the object-oriented mind of java.
When there is a process definition, how do employees apply for a reimbursement process, because each employee situation is different, they need to have a separate process to solve their own problems (similar to objects in java). RuntimeService provides us with the corresponding method to create a process instance according to a process definition, and can perform a series of operations on the process instance.
There is also a concept of task. Task can be understood as an approval task (node) in our flowchart. As long as a process instance is created and not finished, it is on one of the nodes. We can also use RuntimeService to get the task that our process is currently in. On the other hand, TaskService can complete and manage various operations on task.
In addition, activiti also provides us with a series of methods to uniformly manage the process, all users and user groups participating in the process through IdentityService, and allows the approval users or user groups in the system to be set for task through the methods in taskService.
HistoryService is because we sometimes need to query process instances that have gone through the whole process, and he provides us with a series of ways to manipulate historical data.
ManagementService and DynamicBpmnService are rarely used for the time being, which will be supplemented later. / / todo
3. How to create a service component
In an ordinary java project, we need to declare the workflow engine ProcessEngine first, and then obtain various service components according to the workflow engine.
ProcessEngine engine= ProcessEngines.getDefaultProcessEngine (); / Workflow defines related services RepositoryService rs=engine.getRepositoryService (); / / Workflow instance related services RuntimeService runtimeService=engine.getRuntimeService (); / / Task-related services TaskService taskService=engine.getTaskService (); / / Store process templates in the database rs.createDeployment (). AddClasspathResource ("first.bpmn"). Deploy () / / create a process instance ProcessInstance processInstance=runtimeService.startProcessInstanceByKey ("myProcess_1"); / / ordinary employees complete the leave task task is the current node Task task=taskService.createTaskQuery () .processInstanceId (processInstance.getId ()) .singleResult (); System.out.println ("current process node:" + task.getName ()); taskService.complete (task.getId ()
In the spring project, we can obtain our service components directly through the @ Autowired annotation, as follows
@ Autowired private RuntimeService runtimeService; @ Autowired private RepositoryService repositoryService; @ Autowired private TaskService taskService; @ Autowired private IdentityService identityService; @ Autowired private HistoryService historyService; so much about what service components are commonly used in Activiti. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.