- // we currently only deal with single agents
- Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
- NodeIterator nit = realizedFlowNode.getNodes();
- if (nit.hasNext()) {
- // FIXME find a better way to determine which agent to use
- // currently we check the agent of the first registered flow
- Node firstRealizedFlow = nit.nextNode();
- // we assume there is an nt:address
- String firstFlowPath = firstRealizedFlow
- .getNode(SlcNames.SLC_ADDRESS)
- .getProperty(Property.JCR_PATH).getString();
- Node flowNode = processNode.getSession().getNode(firstFlowPath);
- String agentFactoryPath = SlcJcrUtils
- .flowAgentFactoryPath(firstFlowPath);
- if (!agentFactories.containsKey(agentFactoryPath))
- throw new SlcException("No agent factory registered under "
- + agentFactoryPath);
- SlcAgentFactory agentFactory = agentFactories
- .get(agentFactoryPath);
- Node agentNode = ((Node) flowNode
- .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
- String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
- .getString();
-
- // process
- SlcAgent slcAgent = agentFactory.getAgent(agentUuid);
- slcAgent.process(process);
- }
+ SlcAgent slcAgent = findAgent(processNode);
+ if (slcAgent == null)
+ throw new SlcException("Cannot find agent for " + processNode);
+ slcAgent.kill(process);