1 17 package org.apache.servicemix.beanflow; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 27 public class ExampleStringWorkflow extends Workflow<String > { 29 30 private static final Log log = LogFactory.getLog(ExampleStringWorkflow.class); 31 32 private int loopCount; 33 private long timeout = 1000; 34 private String userEmailAddress; 35 36 public ExampleStringWorkflow() { 37 super("startStep"); 39 } 40 41 44 public void startStep() { 48 addStep("loopStep"); 51 } 52 53 public String loopStep() { 55 if (++loopCount > 3) { 56 return "waitForUserInputStep"; 57 } 58 return "loopStep"; 60 } 61 62 public void waitForUserInputStep() { 63 } 67 68 public String afterEnteredEmailStep() { 69 log.info("User entered email address: " + userEmailAddress); 72 return "forkStep"; 73 } 74 75 public void forkStep() { 76 TimeoutActivity a = new TimeoutActivity(); 78 TimeoutActivity b = new TimeoutActivity(); 79 TimeoutActivity c = new TimeoutActivity(); 80 81 log.info("Forking off processes a, b, c"); 82 fork(a, b, c); 83 84 joinAll("aCompletedStep", timeout, a); 86 joinAll("abcCompletedStep", timeout, a, b, c); 87 } 88 89 public void aCompletedStep() { 90 log.info("child flow A completed!"); 91 } 92 93 public String abcCompletedStep() { 94 log.info("child flows A, B and C completed!"); 95 96 return "stop"; 98 } 99 100 public void userEntered(String emailAddress) { 103 if (emailAddress != null && emailAddress.indexOf("@") > 0) { 104 this.userEmailAddress = emailAddress; 105 106 log.info("Lets re-start the suspended workflow"); 107 addStep("afterEnteredEmailStep"); 108 } 109 } 110 } 111 | Popular Tags |