1 2 package org.state4j.sm; 3 4 import java.util.LinkedList; 5 import java.util.List; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 import org.state4j.exceptions.LogicErrorException; 10 11 12 public class SmChainActionImpl extends SmActionBaseImpl implements SmAction { 13 private static Log logger = LogFactory.getLog(SmChainActionImpl.class); 14 private List<SmAction> smActions; 15 16 public void execute(SmContext cntx) { 17 List<SmAction> list = new LinkedList<SmAction>(this.getSmActions()); 18 try { 19 20 for(int i = 0; i < list.size(); i++) { 21 list.get(i).execute(cntx); 22 } 23 } catch (Exception e) { 24 logger.error("error executing action ", e); 25 throw new LogicErrorException("error executing action" + e.getMessage(), e); 26 } 27 } 28 29 public List<SmAction> getSmActions() { 30 if (!hasSmActions()) { 31 throw new LogicErrorException("Sorry!! cannot get smActions"); 32 } 33 return this.smActions; 34 } 35 36 public boolean hasSmActions() { 37 return smActions != null; 38 } 39 40 public void setSmActions(List<SmAction> smActions) { 41 this.smActions = smActions; 42 } 43 44 }