1 package org.jbpm.bpel.exe.state; 2 3 import java.io.Serializable ; 4 5 import org.jbpm.bpel.exe.ScopeInstance; 6 7 11 public abstract class ScopeState implements Serializable { 12 13 private static final int STATE_COUNT = 19; 14 private static final ScopeState[] states = new ScopeState[STATE_COUNT]; 15 16 private String name; 17 private int code; 18 19 23 protected ScopeState(String name, int code) { 24 if ((code < 0) && (code <= STATE_COUNT)) throw new AssertionError ("code out of bounds"); 25 if(states[code] != null) throw new AssertionError ("code already in use"); 26 this.code = code; 27 this.name = name; 28 states[code] = this; 29 } 30 31 35 public void terminate(ScopeInstance scope) { 36 throw newStateException("cancel"); 37 } 38 39 43 public void compensate(ScopeInstance scope) { 44 throw newStateException("compensate"); 45 } 46 47 51 public void completed(ScopeInstance scope) { 52 throw newStateException("completed"); 53 } 54 55 59 public void faulted(ScopeInstance scope) { 60 throw newStateException("faulted"); 61 } 62 63 67 public void childrenTerminated(ScopeInstance scope) { 68 throw newStateException("childTerminated"); 69 } 70 71 77 protected IllegalStateException newStateException(String transition) { 78 return new IllegalStateException (toString() + " - transition=" + transition); 79 } 80 81 82 public String toString() { 83 return "[" + name + "]"; 84 } 85 86 90 public int toInt() { 91 return code; 92 } 93 94 public static Object fromInt(int code) { 95 return states[code]; 96 } 97 } 98 | Popular Tags |