1 package org.sapia.soto.state.config; 2 3 import org.sapia.soto.Debug; 4 import org.sapia.soto.state.ExecContainer; 5 import org.sapia.soto.state.Executable; 6 import org.sapia.soto.state.Result; 7 import org.sapia.soto.state.State; 8 9 import java.util.List ; 10 11 12 20 public class GlobalWrapper implements State { 21 private ExecContainer _pre = new ExecContainer(); 22 private ExecContainer _post = new ExecContainer(); 23 private State _toExec; 24 25 28 GlobalWrapper(State st) { 29 _toExec = st; 30 } 31 32 35 public String getId() { 36 return _toExec.getId(); 37 } 38 39 42 public void execute(Result st) { 43 _pre.execute(st); 44 45 if (st.isError()) { 46 if (Debug.DEBUG) { 47 Debug.debug("Not executing: error"); 48 } 49 50 return; 51 } 52 53 if (Debug.DEBUG) { 54 Debug.debug("Executing: " + _toExec.getId() + "(" + 55 _toExec.getClass().getName() + ")"); 56 } 57 58 _toExec.execute(st); 59 _post.execute(st); 60 } 61 62 State getState() { 63 return _toExec; 64 } 65 66 void addPre(List pre) { 67 addExecs(_pre, pre); 68 } 69 70 void addPost(List post) { 71 addExecs(_post, post); 72 } 73 74 private static void addExecs(ExecContainer cont, List execs) { 75 for (int i = 0; i < execs.size(); i++) { 76 cont.addExecutable((Executable) execs.get(i)); 77 } 78 } 79 } 80 | Popular Tags |