1 18 package org.apache.activemq.systest; 19 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 23 import java.util.Iterator ; 24 import java.util.LinkedList ; 25 26 30 public abstract class ScenarioSupport implements Scenario { 31 private static final Log log = LogFactory.getLog(ScenarioSupport.class); 32 33 private LinkedList agents = new LinkedList (); 34 35 38 42 public void start(Agent agent) throws Exception { 43 agent.start(); 44 agents.addFirst(agent); 45 } 46 47 50 public void stop() throws Exception { 51 AgentStopper stopper = new AgentStopper(); 52 stop(stopper); 53 stopper.throwFirstException(); 54 } 55 56 public void stop(AgentStopper stopper) { 57 for (Iterator iter = agents.iterator(); iter.hasNext();) { 58 Agent agent = (Agent) iter.next(); 59 log.info("Stopping agent: " + agent); 60 stopper.stop(agent); 61 } 62 } 63 64 65 } 66 | Popular Tags |