1 package org.jbpm.bpel.exe.state; 2 3 import org.jbpm.bpel.def.Scope; 4 import org.jbpm.bpel.def.ScopeHandler; 5 import org.jbpm.bpel.exe.ScopeInstance; 6 7 11 public class TerminatingState extends HandlingState { 12 13 private static final long serialVersionUID = 1L; 14 15 public static final TerminatingState TERMINATING_CHILDREN = new TerminatingState("terminatingTerminatingChildren", 6) { 16 17 private static final long serialVersionUID = 1L; 18 19 public void faulted(ScopeInstance scope) { 20 22 } 23 24 public void childrenTerminated(ScopeInstance scope) { 25 ScopeHandler handler = scope.getDefinition().getHandler(Scope.TERMINATION); 26 27 if (handler != null) { 28 scope.setState(TERMINATING_EXPLICITLY); 29 handleExplicitly(scope, handler); 30 } else { 31 scope.setState(TERMINATING_IMPLICITLY); 32 handleImplicitly(scope); 33 } 34 } 35 }; 36 37 public static final TerminatingState TERMINATING_EXPLICITLY = new TerminatingState("terminatingExplicitly", 7) { 38 39 private static final long serialVersionUID = 1L; 40 41 public void faulted(ScopeInstance scope) { 42 scope.setState(TERMINATING_CHILDREN_AT_HANDLER); 43 scope.cancelChildren(); 44 } 45 46 public void completed(ScopeInstance scope) { 47 enterTerminated(scope); 48 } 49 }; 50 51 public static final TerminatingState TERMINATING_IMPLICITLY = new TerminatingState("terminatingImplicitly", 8) { 52 53 private static final long serialVersionUID = 1L; 54 55 public void faulted(ScopeInstance scope) { 56 enterTerminated(scope); 57 } 58 59 public void childrenCompensated(ScopeInstance scope) { 60 enterTerminated(scope); 61 } 62 }; 63 64 public static final TerminatingState TERMINATING_CHILDREN_AT_HANDLER = new TerminatingState("terminatingTerminatingHandler", 9) { 65 66 private static final long serialVersionUID = 1L; 67 68 public void childrenTerminated(ScopeInstance scope) { 69 enterTerminated(scope); 70 } 71 }; 72 73 protected TerminatingState(String name, int code) { 74 super(name, code); 75 } 76 77 public static void enterTerminating(ScopeInstance scope) { 78 scope.setState(TERMINATING_CHILDREN); 79 scope.cancelChildren(); 80 } 81 82 protected void enterTerminated(ScopeInstance scope) { 83 scope.setState(EndedState.TERMINATED); 84 ScopeInstance parent = scope.getParent(); 85 86 if(parent != null) { 87 parent.childTerminated(scope); 88 } 89 } 90 } 91 | Popular Tags |