Migrate to yang-data-codec-xml 82/57582/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 20 May 2017 11:26:08 +0000 (13:26 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 20 May 2017 11:26:08 +0000 (13:26 +0200)
The codecs in yang-data-impl are going away, use their new place.
Also optimize serialization by sharing XMLOutputFactory, as it is
thread-safe after having been configured.

Change-Id: If6d3b348fa8568e4e84199d4c23ec910c9fc6343
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeXMLOutput.java

index ccb42d9..2f9381b 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-impl</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-data-codec-xml</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
index dc8c77b..49a0f47 100644 (file)
@@ -18,7 +18,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,15 +29,20 @@ import org.slf4j.LoggerFactory;
  */
 public final class NormalizedNodeXMLOutput {
     private static final Logger LOG = LoggerFactory.getLogger(NormalizedNodeXMLOutput.class);
+    private static final XMLOutputFactory XOF;
+
+    static {
+        final XMLOutputFactory f = XMLOutputFactory.newFactory();
+        f.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
+        XOF = f;
+    }
 
     private NormalizedNodeXMLOutput() {
     }
 
     public static void toStream(OutputStream outStream, NormalizedNode<?, ?> node)
             throws XMLStreamException, IOException {
-        XMLOutputFactory xmlFactory = XMLOutputFactory.newFactory();
-        xmlFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
-        XMLStreamWriter xmlWriter = xmlFactory.createXMLStreamWriter(outStream);
+        XMLStreamWriter xmlWriter = XOF.createXMLStreamWriter(outStream);
 
         IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter);
         try (NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.