All pastes #71084 Raw Edit

Unnamed

public java v1 · immutable
#71084 ·published 2006-06-25 06:40 UTC
rendered paste body
public void processEvent(String event)    {        Document eventDoc = XMLUtils.toDocument(event);        logger.log("processing event:\n" + eventDoc);        try        {            JDOMResult matchesResult = new JDOMResult();            synchronized (this)            {                matchTransformer.setParameter("EVENT", eventDoc                        .getRootElement());                matchTransformer.transform(new JDOMSource(patterns),                        matchesResult);                logger.log(matchesResult.toString());            }            Document matches = matchesResult.getDocument();            logger.log(XMLUtils.toString(matches));            XPath xpath = XPath.newInstance("/matches/match");            @SuppressWarnings("unchecked")            List<Element> matchesList = xpath.selectNodes(matches);            logger.log("list:\n" + XMLUtils.toString(matchesList));            for (Element match : matchesList)            {                Element response = new Element("response");                String replyTo = match.getChildTextTrim("reply-to");                String subject = match.getChildTextTrim("subject");                response.addContent(match.cloneContent());                logger.log("sending answer with subject \"" + subject                        + "\" to " + replyTo);                HttpHelper.doPost(replyTo, XMLUtils.toString(response));            }        }        catch (Exception e)        {            e.printStackTrace();            throw new RuntimeException(e);        }    }