1 17 package org.apache.servicemix.eip.support; 18 19 import javax.jbi.messaging.MessageExchange; 20 import javax.jbi.messaging.NormalizedMessage; 21 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 import org.apache.servicemix.expression.JAXPBooleanXPathExpression; 25 import org.apache.servicemix.jbi.util.MessageUtil; 26 27 32 public class XPathPredicate extends JAXPBooleanXPathExpression implements Predicate { 33 34 private static final Log log = LogFactory.getLog(XPathPredicate.class); 35 36 public XPathPredicate() { 37 } 38 39 public XPathPredicate(String xpath) throws Exception { 40 super(xpath); 41 } 42 43 46 public boolean matches(MessageExchange exchange) { 47 try { 48 NormalizedMessage in = MessageUtil.copyIn(exchange); 49 Boolean match = (Boolean ) evaluate(exchange, in); 50 return Boolean.TRUE.equals(match); 51 } catch (Exception e) { 52 log.warn("Could not evaluate xpath expression", e); 53 return false; 54 } 55 } 56 57 } 58 | Popular Tags |