OFBiz workflow source code learning (4)-wfprocess Interface

Source: Internet
Author: User

Wfprocess Interface

Wfprocess is the executor of a workflow request. All workflow objects that execute the work implement this interface, which allows the work to be completed asynchronously and monitored and controlled at the same time. When wfprocess is generated, it enters the open. not_running.not_started state. When it completes processing successfully, it enters the closed. Completed state. Exploitation

The change_state () method provided by wfexecutionobject can change other States of wfprocess. Wfprocess is a type of wfexecutionobject, as shown in the following code:

Public String executionobjecttype (){

Return "wfprocess"; // type: wfprocess

}

 

Process environment and Result

Generally, when the wfprocessmgr factory is used to generate a process, its environment has been set up. The wfprocess environment contains three types of information: process-related data, resources to be used, and results generated by the process. After the process starts, whether the process environment can be modified depends on the implementation of different WFM. The process result evolved from the process environment. It also depends on activities contained in the process. It may return a null value. The sample code is as follows:

Public synchronized void receiveresults (wfacti1_activity, map results) throws wfexception, invaliddata {

Map context = processcontext ();

Context. putall (results );

Setserializeddata (context );

}

 

Process requester

When a process is generated by wfprocessmgr, it is associated with a wfrequester, which may be an activity or an external customer. A process always has a requestor. OFBiz allows a process to be reassigned to a requestor.

By calling the receive_event () method of the requester, the process can notify the requester of its status changes and other information.

 

Process steps

One wfprocess has zero to multiple wfactixes, and wfactixes represent the steps to be executed in one wfprocess.

Wfactisource is assigned to wfresource, or is converted into a requester to generate a new process as a sub-process.

The sample code is as follows:

Public list getsequencestep (INT maxnumber) throws wfexception {

If (maxnumber> 0)

Return new arraylist (activesteps (). sublist (0, maxnumber-1 ));

Return activesteps ();

}

 

Process Monitoring

The START () method can start the process. Before it is completed, it can also be suincluded, resumed, terminated, and aborted. Of course, most methods are implemented by implementing the wfexecutionobject interface.

Result () is used to obtain the result data of the current process. When the status of the process changes, it sends a status change event to the requester to notify the requester of the status change.

 

 

 

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.