OFBIZ Workflow Source Code (1) --- WFRequester Interface

zhaozj2021-02-17  55

WFREQUESTER interface and implementation

The WFREQUESTER interface is an interface between the execution and results of the workflow process and the direct relationship, which represents the request to do.

Knowledge points: Performer's performer is wfprocess, and a WFRequester interface can correspond to several WfProcess.

Code example:

protected mapp performers = NULL;

this.performers = new hashmap (); // Constructing the MAP of Procester with Requester

Performers.put (Process, Requester); // registerprocess () Registering Process for REQESTER

The following method is related to Performer:

/ **

* @ See Org.Ofbiz.core.Workflow.WFrequester # HowManyperformer ()

* Get the size of Performer

* /

Public int howmanyperformer () throws wfexception {

Return Performers.size ();

}

/ **

* @see org.Ofbiz.core.workflow.wfrequester # getItemPerformer ()

* Get the Iterator of Performer

* /

Public iterator getiteratorPerformer () throws wfexception {

Return performers.keyset (). Itrator ();

}

/ **

* @see org.Ofbiz.core.workflow.wfrequester # getsequenceperperformer (int)

* Get the Performer in the form of list

* /

Public List GetSequencePerformer (int maxNumber) throws wfexception {

IF (MAXNUMBER> 0)

Return New ArrayList (Performers.Keyset ()). Sublist (0, (MaxNumber - 1));

Return New ArrayList (Performers.Keyset ());

}

Knowledge point: WFREQUESTER interface is often used as an interface to start Process

As a process of the starter it usually do three things:

1) Setting up the context

2) START The Process

3) Get The Status and Results

Knowledge points: WFRequester interface and WFProcess associations, generally have two applications:

1) Evolution of the workflow process: In this case, WFActivity is refined to WFREQUESTER, so it has an executor WfProcess. WfProcess executes a request is to perform an activity.

2) WFREQUESTER connects WFPRoCESS to other applications.

Knowledge points: WfProcess generally notifies Request in the Void ReceiveEvent (WFEventAudit Event) method

When an event occurs, interrupt, abort, etc., the process must notify Requester.

Code example:

/ **

* @ See Org.Ofbiz.core.workflow.wfrequester # receiveEvent ()

* /

Public Synchronized Void ReceEvent (WFEventaudit Event) Throws WFException, InvalidPerformer {// SHOULD The Source of The Audit Come from the process? if so use this.

WfProcess Process = NULL;

Try {

Process = (wfprocess) Event.source (); // Event Source from Process

} catch (SourceNotavailable SNA) {

Throw New Invalider ("Could Not Get The Performer", SNA);

} catch (classcastexception cce) {

Throw New Invalider ("NOT A Valid Process Object", CCE);

}

// If the event source is not associated with the Requester, the exception is thrown.

IF (Process == Null)

Throw New Invalider ("No Performer Specified");

IF (! Performers.Containskey (Process))

Throw New Invalider ("Performer Not Assigned to this Requester");

GenericRequester Req = NULL;

/ / If the event source is associated with the requester, get status and results

IF (Performers.Containskey (Process))

Req = (genericRequester) Performers.get (Process);

IF (Req! = NULL)

Req.ReceiveResult (process.Result ());

}

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

New Post(0)