package com.c2kernel.lifecycle.instance; import java.util.StringTokenizer; import com.c2kernel.graph.model.DirectedEdge; import com.c2kernel.lookup.AgentPath; import com.c2kernel.scripting.ScriptingEngineException; import com.c2kernel.utils.Logger; /** * @version $Revision: 1.22 $ $Date: 2005/05/10 15:14:54 $ * @author $Author: abranson $ */ public class OrSplit extends Split { /** * @see java.lang.Object#Object() */ public OrSplit() { super(); } public void runNext(AgentPath agent) throws ScriptingEngineException { String nexts = this .evaluateScript((String) getProperties().get("RoutingScriptName"), (String) getProperties().get("RoutingScriptVersion")) .toString(); StringTokenizer tok = new StringTokenizer(nexts, ","); Logger.msg(7, tok.countTokens() + " nexts to activate:" + nexts); int active = 0; try { DirectedEdge[] outEdges = getOutEdges(); AdvancementCalculator adv = new AdvancementCalculator(); adv.calculate((CompositeActivity)getParent()); while (tok.hasMoreTokens()) { String thisNext = tok.nextToken(); Logger.msg(7, "Finding next " + thisNext); for (int i = 0; i < outEdges.length; i++) { Next nextEdge = (Next) outEdges[i]; if (thisNext != null && thisNext.equals(nextEdge.getProperties().get("Alias"))) { WfVertex term = nextEdge.getTerminusVertex(); term.run(agent); Logger.msg(7, "Running " + nextEdge.getProperties().get("Alias")); active++; } } } // if no active nexts throw exception } catch (Exception e) { Logger.error(e); } if (active == 0) throw new ScriptingEngineException("No nexts were activated!"); } }