X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fxml%2FXMLNetconfUtil.java;h=6569dba714437f1f254e481e0913085b11e9552a;hp=eaaf320b023c454f5638a0f2138d262c312d0d1d;hb=a69a67c76a04a89d870e9f12df7919cbeb0d5001;hpb=3a71a222b896b9d07e638af62300180799bdac67 diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XMLNetconfUtil.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XMLNetconfUtil.java index eaaf320b02..6569dba714 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XMLNetconfUtil.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XMLNetconfUtil.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.netconf.util.xml; +import javax.xml.namespace.NamespaceContext; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; @@ -15,14 +16,17 @@ import javax.xml.xpath.XPathFactory; import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; public final class XMLNetconfUtil { + private static final XPathFactory FACTORY = XPathFactory.newInstance(); + private static final NamespaceContext NS_CONTEXT = new HardcodedNamespaceResolver("netconf", + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); - private XMLNetconfUtil() {} + private XMLNetconfUtil() { + throw new UnsupportedOperationException("Utility class"); + } - public static XPathExpression compileXPath(String xPath) { - final XPathFactory xPathfactory = XPathFactory.newInstance(); - final XPath xpath = xPathfactory.newXPath(); - xpath.setNamespaceContext(new HardcodedNamespaceResolver("netconf", - XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)); + public static XPathExpression compileXPath(final String xPath) { + final XPath xpath = FACTORY.newXPath(); + xpath.setNamespaceContext(NS_CONTEXT); try { return xpath.compile(xPath); } catch (final XPathExpressionException e) {