OFBIZ Workflow Source Code (4) - WfProcess Interface

zhaozj2021-02-17  63

WfProcess interface

WfProcess is an executor of a workflow request, and all workflow objects that do work have implemented this interface, which allows work to be completed asynchronously and is monitored and controlled at the same time. When WfProcess is generated, it enters the open.not_running.not_started state when it successfully completes the processing, it enters the Closed.completed status. use

WFExecutionObject provides a change_state () method, we can change the other state of WfProcess. WfProcess is a WFEXECUTIONOBJECT, as shown in the following code:

Public String ExecutionObjectType () {

Return "WfProcess"; // Type WfProcess

}

Process environment and results

Generally speaking, when a process is generated with a WfProcessMgr plant, its environment has been set. The WFProcess environment contains three information: process related data, resources to be used, resulting in the results. When the process is started, the process environment can be modified, which depends on different WFM implementations. Process results are evolved by the process environment, which also rely on the activities of the process, which may also return a null value. The code example is, for example:

Public Synchronized Void ReceiveResults (WFActivity Activity, Map Results) throws wfexception, invaliddata {

Map context = processContext ();

Context.putall (Results);

SetSerializedData (context);

}

Process Requester

When the process is generated by WfProcessmgr, it is associated with a WFREQUESTER, which may be an activity or an external customer. A process will always have a requestor, and OFBIZ allows a process to reassign a requestor.

By calling the requester's Receive_Event () method, the flow can notify the requester such as information such as a state change.

Process Steps

A WfProcess has zero to multiple WFActivity, WFActivity represents the steps to perform in WfProcess.

WFActivity is assigned to WFResource, or transformed into a requestor to generate a new process as a subflow.

The code example is, for example:

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, and can be SUSPENDED, Resumed, Terminated and Aborted before it is completed. Of course, most methods are implemented by implementing the WFExecutionObject interface.

Result () is used to obtain the current process result data, when the state mode is changed, it transmits a state change event to the requester, inform the requester status.

转载请注明原文地址:https://www.9cbs.com/read-28862.html

New Post(0)