OFBiz workflow source code learning (1)-wfrequester Interface

Source: Internet
Author: User
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 ());

}

 

 

 

 

 

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.