01 package org.jbpm.gop;
02
03 import java.util.*;
04
05 /** a node in the process graph */
06 public class Node {
07
08 String name;
09 /** maps events to transitions */
10 Map<String,Transition> transitions = new HashMap<String,Transition>();
11 /** maps events to actions */
12 Map<String,List<Action>> actions = new HashMap<String,List<Action>>();
13
14 public Node(String name) {
15 this.name = name;
16 }
17
18 /** create a new transition to the destination node and
19 * associate it with the given event */
20 public void addTransition(String event, Node destination) {
21 transitions.put(event, new Transition(destination));
22 }
23
24 /** add the action to the given event */
25 public void addAction(String event, Action action) {
26 if (actions.containsKey(event)) {
27 actions.get(event).add(action);
28 } else {
29 List<Action> eventActions = new ArrayList<Action>();
30 eventActions.add(action);
31 actions.put(event, eventActions);
32 }
33 }
34
35 /** to be overriden by Node implementations. The default doesn't
36 * propagate the execution so it behaves as a wait state. */
37 public void execute(Execution execution) {
38 System.out.println("arrived in wait state "+this);
39 }
40
41 public String toString() { return "node '"+name+"'"; }
42 }
|