KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > def > ScopeHandler


1 package org.jbpm.bpel.def;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.ArrayList JavaDoc;
5 import java.util.List JavaDoc;
6
7 import org.jbpm.graph.def.Node;
8 import org.jbpm.graph.exe.ExecutionContext;
9
10 /**
11  * @author Juan Cantú
12  * @version $Revision: 1.3 $ $Date: 2005/06/03 00:13:42 $
13  */

14 public class ScopeHandler extends CompositeActivity implements Serializable JavaDoc {
15
16   private static final long serialVersionUID = 1L;
17   
18   public ScopeHandler() {
19   }
20   
21   private Activity activity;
22   private transient List JavaDoc nodes = null;
23   
24   public Activity getActivity() {
25     return activity;
26   }
27   
28   public void setActivity(Activity activity) {
29     this.activity = activity;
30   }
31
32   public void execute(ExecutionContext context) {
33     activity.enter(context);
34   }
35   
36   // children management /////////////////////////////////////////////////////////////////////////////
37

38   // javadoc description in NodeCollection
39
public Node addNode(Node node) {
40     activity = (Activity) node;
41     activity.compositeActivity = this;
42     return activity;
43   }
44
45   // javadoc description in NodeCollection
46
public Node removeNode(Node node) {
47     if(activity.equals(node)) {
48       activity.compositeActivity = null;
49       activity = null;
50     }
51     
52     return node;
53   }
54   
55   // javadoc description in NodeCollection
56
public void reorderNode(int oldIndex, int newIndex) {
57     //nothing to do
58
}
59   
60   // javadoc description in NodeCollection
61
public List JavaDoc getNodes() {
62     if(nodes == null && activity!=null) {
63       nodes = new ArrayList JavaDoc();
64       nodes.add(activity);
65     }
66     else if(!nodes.contains(activity)) {
67       nodes.set(0, activity);
68     }
69     
70     return nodes;
71   }
72 }
Popular Tags