You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2015/01/06 21:16:50 UTC

svn commit: r1649928 - /chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java

Author: fmui
Date: Tue Jan  6 20:16:50 2015
New Revision: 1649928

URL: http://svn.apache.org/r1649928
Log:
XMLUtilis improvements

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java?rev=1649928&r1=1649927&r2=1649928&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java Tue Jan  6 20:16:50 2015
@@ -55,9 +55,11 @@ public final class XMLUtils {
 
         try {
             // Woodstox is the only supported and tested StAX implementation
-            factory = new WstxInputFactory();
-            factory.setProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
-                    new InvalidCharHandler.ReplacingHandler(' '));
+            WstxInputFactory wstxFactory = (WstxInputFactory) ClassLoaderUtil.loadClass(
+                    "com.ctc.wstx.stax.WstxInputFactory").newInstance();
+            wstxFactory.configureForSpeed();
+
+            factory = wstxFactory;
         } catch (Exception e) {
             // other StAX implementations may work, too
             factory = XMLInputFactory.newInstance();
@@ -69,7 +71,8 @@ public final class XMLUtils {
                 // ignore
             }
 
-            LOG.warn("Unsupported StAX parser: " + factory.getClass().getName());
+            LOG.warn("Unsupported StAX parser: " + factory.getClass().getName() + " (Exception: " + e.toString() + ")",
+                    e);
         }
 
         factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
@@ -85,7 +88,13 @@ public final class XMLUtils {
 
         try {
             // Woodstox is the only supported and tested StAX implementation
-            factory = new WstxOutputFactory();
+            WstxOutputFactory wstxFactory = (WstxOutputFactory) ClassLoaderUtil.loadClass(
+                    "com.ctc.wstx.stax.WstxOutputFactory").newInstance();
+            wstxFactory.configureForSpeed();
+            wstxFactory.setProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
+                    new InvalidCharHandler.ReplacingHandler(' '));
+
+            factory = wstxFactory;
         } catch (Exception e) {
             // other StAX implementations may work, too
             factory = XMLOutputFactory.newInstance();
@@ -97,7 +106,8 @@ public final class XMLUtils {
                 // ignore
             }
 
-            LOG.warn("Unsupported StAX parser: " + factory.getClass().getName());
+            LOG.warn("Unsupported StAX parser: " + factory.getClass().getName() + " (Exception: " + e.toString() + ")",
+                    e);
         }
 
         factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);