Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9C74E11709 for ; Tue, 29 Jul 2014 10:44:35 +0000 (UTC) Received: (qmail 43103 invoked by uid 500); 29 Jul 2014 10:44:35 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 43055 invoked by uid 500); 29 Jul 2014 10:44:35 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 43044 invoked by uid 99); 29 Jul 2014 10:44:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2014 10:44:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2014 10:44:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0E18A2388A2C; Tue, 29 Jul 2014 10:44:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1614304 - /chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java Date: Tue, 29 Jul 2014 10:44:13 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140729104414.0E18A2388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmui Date: Tue Jul 29 10:44:13 2014 New Revision: 1614304 URL: http://svn.apache.org/r1614304 Log: added a strong dependency to Woodstox to avoid class loading issues on application servers 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=1614304&r1=1614303&r2=1614304&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 Jul 29 10:44:13 2014 @@ -40,34 +40,65 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import com.ctc.wstx.stax.WstxInputFactory; +import com.ctc.wstx.stax.WstxOutputFactory; + public final class XMLUtils { private static final Logger LOG = LoggerFactory.getLogger(XMLUtils.class); - private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance(); + private static final XMLInputFactory XML_INPUT_FACTORY; static { + XMLInputFactory factory; + try { - XML_INPUT_FACTORY.setProperty("reuse-instance", Boolean.FALSE); - LOG.warn("You are using an unsupported StAX parser."); - } catch (IllegalArgumentException ex) { - // expected for Woodstox + // Woodstox is the only supported and tested StAX implementation + factory = new WstxInputFactory(); + } catch (Exception e) { + // other StAX implementations may work, too + factory = XMLInputFactory.newInstance(); + + try { + // for the SJSXP parser + factory.setProperty("reuse-instance", Boolean.FALSE); + } catch (IllegalArgumentException ex) { + // ignore + } + + LOG.warn("Unsupported StAX parser: " + factory.getClass().getName()); } - XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); - XML_INPUT_FACTORY.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); - XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); + factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); + factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); + factory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); + + XML_INPUT_FACTORY = factory; } - private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance(); + private static final XMLOutputFactory XML_OUTPUT_FACTORY; static { + XMLOutputFactory factory; + try { - XML_OUTPUT_FACTORY.setProperty("reuse-instance", Boolean.FALSE); - LOG.warn("You are using an unsupported StAX parser."); - } catch (IllegalArgumentException ex) { - // expected for Woodstox + // Woodstox is the only supported and tested StAX implementation + factory = new WstxOutputFactory(); + } catch (Exception e) { + // other StAX implementations may work, too + factory = XMLOutputFactory.newInstance(); + + try { + // for the SJSXP parser + factory.setProperty("reuse-instance", Boolean.FALSE); + } catch (IllegalArgumentException ex) { + // ignore + } + + LOG.warn("Unsupported StAX parser: " + factory.getClass().getName()); } - XML_OUTPUT_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE); + factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE); + + XML_OUTPUT_FACTORY = factory; } private XMLUtils() {