Wfrequester interface and implementation
The wfrequester interface is an interface that has a direct relationship with the execution and results of workflow flows. It represents a request for the work to be done.
Knowledge Point: wfrequesterExtends mer OF THE INTERFACEIs wfprocess,A wfrequesterInterface can correspond to several wfprocess
Sample Code:
Protected map export MERs = NULL;
This. Merge MERs = new hashmap (); // constructs the map of proces and requester.
Schedulmers. Put (process, requester); // registerprocess () registers process for requester
The following method is related to the Timer:
/**
* @ See org. OFBiz. Core. workflow. wfrequester # howmanyperformer ()
* Obtain the size of the timer.
*/
Public int howmanypolicmer () throws wfexception {
Return radimers. Size ();
}
/**
* @ See org. OFBiz. Core. workflow. wfrequester # getiteratorperformer ()
* Get the timer iterator
*/
Public iterator getiteratorperformer () throws wfexception {
Return radimers. keyset (). iterator ();
}
/**
* @ See org. OFBiz. Core. workflow. wfrequester # getsequenceperformer (INT)
* Get the sort Mer In the list form
*/
Public list getsequenceperformer (INT maxnumber) throws wfexception {
If (maxnumber> 0)
Return new arraylist (sort MERs. keyset (). sublist (0, (maxnumber-1 ));
Return new arraylist (sort MERs. keyset ());
}
Knowledge Point: wfrequesterThe interface is often used to start the process.Object Interface
As a process starter, it usually does three things:
1) Setting up the context
2) start the process
3) Get the status and results
Knowledge Point: wfrequesterInterface and wfprocessGenerally, there are two application scenarios:
1) workflow process evolution: in this case, wfactiworkflow is refined into wfrequester, so that it has a executor wfprocess. When wfprocess executes a request, it executes an activity.
2) wfrequester connects wfprocess to other applications.
Knowledge Point: wfprocessGenerally, void receiveevent (wfeventaudit event) is used)Method) Notification to request
When an activity is completed, interrupted, or aborted, the requester must be notified.
Sample Code:
/**
* @ See org. OFBiz. Core. workflow. wfrequester # receiveevent ()
*/
Public synchronized void receiveevent (wfeventaudit event) throws wfexception, invalidperformer {
// Shocould the source of the audit come from the process? If so use this.
Wfprocess process = NULL;
Try {
Process = (wfprocess) event. Source (); // The event is from process
} Catch (sourcenotavailable SNA ){
Throw new invalidpolicmer ("cocould not get the specified mer", SNA );
} Catch (classcastexception CCE ){
Throw new invalidperformer ("not a valid process object", CCE );
}
// If the event source is not the process associated with the requester, an exception is thrown.
If (process = NULL)
Throw new invalidperformer ("No timer mer specified ");
If (! Extends MERs. containskey (process ))
Throw new invalidperformer ("timer mer not assigned to this requester ");
Genericrequester Req = NULL;
// If the event source is a process associated with requester, the status and result are obtained.
If (sort MERs. containskey (process ))
Req = (genericrequester) reducers. Get (process );
If (req! = NULL)
Req. receiveresult (process. Result ());
}