KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > node > InterleaveEnd


1 package org.jbpm.graph.node;
2
3 import java.util.*;
4 import org.dom4j.Element;
5 import org.jbpm.graph.def.*;
6 import org.jbpm.graph.exe.*;
7 import org.jbpm.jpdl.xml.*;
8
9 /**
10  * a interleaving end node should have 2 leaving transitions.
11  * one with the name 'back' that has the interleaving start node as
12  * destinationNode. and one with the name 'done' that specifies the
13  * destinationNode in case the interleaving is done.
14  * Alternatively, the back and done transitions can be specified
15  * in this interleave handler.
16  */

17 public class InterleaveEnd extends Node implements Parsable {
18   
19   private static final long serialVersionUID = 1L;
20   
21   private Transition back = null;
22   private Transition done = null;
23
24   public InterleaveEnd() {
25   }
26
27   public InterleaveEnd(String JavaDoc name) {
28     super(name);
29   }
30
31   public void read(Element element, JpdlXmlReader jpdlReader) {
32     // TODO
33
}
34
35   public void write(Element element) {
36     // TODO
37
}
38
39   public void execute(ExecutionContext executionContext) {
40     Token token = executionContext.getToken();
41     Node interleaveEndNode = token.getNode();
42     Collection transitionNames = getInterleaveStart().retrieveTransitionNames(token);
43     // if the set is *not* empty
44
if ( ! transitionNames.isEmpty() ) {
45       // go back to the interleave start handler
46
String JavaDoc backTransitionName = "back";
47       if ( back != null ) {
48         backTransitionName = back.getName();
49       }
50       interleaveEndNode.leave(executionContext, backTransitionName);
51     } else {
52       // leave the to the
53
getInterleaveStart().removeTransitionNames(token);
54       String JavaDoc doneTransitionName = "done";
55       if ( done != null ) {
56         doneTransitionName = done.getName();
57       }
58       interleaveEndNode.leave(executionContext, doneTransitionName);
59     }
60   }
61   
62   public InterleaveStart getInterleaveStart() {
63     return (InterleaveStart) getLeavingTransition("back").getTo();
64   }
65
66   public Transition getBack() {
67     return back;
68   }
69   public void setBack(Transition back) {
70     this.back = back;
71   }
72   public Transition getDone() {
73     return done;
74   }
75   public void setDone(Transition done) {
76     this.done = done;
77   }
78 }
79
Popular Tags