KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > FlowReader


1 package org.jbpm.bpel.xml;
2
3 import java.util.Iterator JavaDoc;
4
5 import org.w3c.dom.Element JavaDoc;
6
7 import org.jbpm.bpel.def.Activity;
8 import org.jbpm.bpel.def.Flow;
9 import org.jbpm.bpel.def.Link;
10 import org.jbpm.bpel.xml.util.NodeUtil;
11
12 /**
13  * Encapsulates the logic to create and connect process elements that make up
14  * the <i>flow</i> structure.
15  * @author Juan Cantú
16  * @version $Revision: 1.6 $ $Date: 2005/06/23 02:22:46 $
17  */

18 public class FlowReader extends ActivityReader {
19
20   public Activity createActivity() {
21     return new Flow();
22   }
23   
24   public void readActivity(Activity activity, Element JavaDoc flowElem) {
25     Flow flow = (Flow) activity;
26     
27     //load links
28
Element JavaDoc linksElem = NodeUtil.getElement(flowElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_LINKS);
29     if(linksElem != null) {
30       Iterator JavaDoc linkElemIt = NodeUtil.getElements(linksElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_LINK);
31       while (linkElemIt.hasNext()) {
32         Element JavaDoc linkElem = (Element JavaDoc) linkElemIt.next();
33         flow.addLink(new Link(linkElem.getAttribute(BpelConstants.ATTR_NAME)));
34       }
35     }
36
37     /* read children activities */
38     Iterator JavaDoc activityElemIt = bpelReader.getActivityElements(flowElem);
39     while ( activityElemIt.hasNext() ) {
40       Element JavaDoc activityElem = (Element JavaDoc) activityElemIt.next();
41       bpelReader.readActivity(activityElem, flow);
42     }
43   }
44 }
45
Popular Tags