cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1499610 - in /cxf/trunk: api/src/main/java/org/apache/cxf/helpers/ rt/core/src/main/java/org/apache/cxf/databinding/source/ rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/ rt/transports/http-jetty/src/main/java/org/apache...
Date Thu, 04 Jul 2013 00:58:38 GMT
Author: dkulp
Date: Thu Jul  4 00:58:37 2013
New Revision: 1499610

URL: http://svn.apache.org/r1499610
Log:
Remove more transformerfactory usage

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/NodeDataReader.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/blueprint/NettyServerEngineFactoryParser.java
    cxf/trunk/testutils/src/main/java/org/apache/cxf/test/XPathAssert.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java Thu Jul  4 00:58:37 2013
@@ -21,7 +21,6 @@ package org.apache.cxf.helpers;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.ArrayList;
@@ -33,12 +32,6 @@ import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Attr;
@@ -487,14 +480,6 @@ public final class DOMUtils {
         return db.parse(is2);
     }
 
-    public static void writeXml(Node n, OutputStream os) throws TransformerException {
-        TransformerFactory tf = TransformerFactory.newInstance();
-        // identity
-        Transformer t = tf.newTransformer();
-        t.setOutputProperty(OutputKeys.INDENT, "yes");
-        t.transform(new DOMSource(n), new StreamResult(os));
-    }
-
     public static Document createDocument() {
         try {
             return XMLUtils.newDocument();

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/NodeDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/NodeDataReader.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/NodeDataReader.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/NodeDataReader.java
Thu Jul  4 00:58:37 2013
@@ -24,8 +24,8 @@ import java.util.Collection;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
@@ -36,7 +36,7 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataReader;
-import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
@@ -57,15 +57,15 @@ public class NodeDataReader implements D
             return new StaxSource(reader);
         } else if (StreamSource.class.isAssignableFrom(type)) {
             try {
-                CachedOutputStream out = new CachedOutputStream();                
-                DOMUtils.writeXml(input, out);
+                CachedOutputStream out = new CachedOutputStream();
+                XMLUtils.writeTo(input, out);
                 InputStream is = out.getInputStream();
                 out.close();
                 
                 return new StreamSource(is);
             } catch (IOException e) {
                 throw new Fault("COULD_NOT_READ_XML_STREAM", LOG, e);
-            } catch (TransformerException e) {
+            } catch (XMLStreamException e) {
                 throw new Fault("COULD_NOT_READ_XML_STREAM_CAUSED_BY", LOG, e,
                                 e.getClass().getCanonicalName(), e.getMessage());
             } 

Modified: cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
(original)
+++ cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
Thu Jul  4 00:58:37 2013
@@ -100,7 +100,7 @@ public class SamlEnvelopedOutInterceptor
             // TODO: this is not critical now - but figure out if we can avoid copying
             // DOMs
             CachedOutputStream bos = new CachedOutputStream();
-            DOMUtils.writeXml(newDoc, bos);
+            XMLUtils.writeTo(newDoc, bos);
             return DOMUtils.readXml(bos.getInputStream());
         } else {
             return newDoc;

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/blueprint/JettyServerEngineFactoryParser.java
Thu Jul  4 00:58:37 2013
@@ -18,20 +18,16 @@
  */
 package org.apache.cxf.transport.http_jetty.blueprint;
 
-import java.io.StringWriter;
 import java.util.StringTokenizer;
 import java.util.UUID;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+
 import org.w3c.dom.Element;
 
 import org.apache.aries.blueprint.ParserContext;
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.apache.cxf.helpers.XMLUtils;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 
@@ -68,19 +64,9 @@ public class JettyServerEngineFactoryPar
         ef.setRuntimeClass(JettyHTTPServerEngineFactoryHolder.class);
 
         try {
-
-            TransformerFactory transfac = TransformerFactory.newInstance();
-            Transformer trans = transfac.newTransformer();
-            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "YES");
-            //trans.setOutputProperty(OutputKeys.INDENT, "yes");
-
             // Print the DOM node
 
-            StringWriter sw = new StringWriter();
-            StreamResult result = new StreamResult(sw);
-            DOMSource source = new DOMSource(element);
-            trans.transform(source, result);
-            String xmlString = sw.toString();
+            String xmlString = XMLUtils.toString(element);
             ef.addProperty("parsedElement", createValue(context, xmlString));
             ef.setInitMethod("init");
             ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);

Modified: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/blueprint/NettyServerEngineFactoryParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/blueprint/NettyServerEngineFactoryParser.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/blueprint/NettyServerEngineFactoryParser.java
(original)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/blueprint/NettyServerEngineFactoryParser.java
Thu Jul  4 00:58:37 2013
@@ -18,20 +18,16 @@
  */
 package org.apache.cxf.transport.http.netty.server.blueprint;
 
-import java.io.StringWriter;
 import java.util.StringTokenizer;
 import java.util.UUID;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+
 import org.w3c.dom.Element;
 
 import org.apache.aries.blueprint.ParserContext;
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.apache.cxf.helpers.XMLUtils;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 
@@ -64,19 +60,8 @@ public class NettyServerEngineFactoryPar
         ef.setRuntimeClass(NettyHttpServerEngineFactoryHolder.class);
 
         try {
-
-            TransformerFactory transfac = TransformerFactory.newInstance();
-            Transformer trans = transfac.newTransformer();
-            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "YES");
-            //trans.setOutputProperty(OutputKeys.INDENT, "yes");
-
             // Print the DOM node
-
-            StringWriter sw = new StringWriter();
-            StreamResult result = new StreamResult(sw);
-            DOMSource source = new DOMSource(element);
-            trans.transform(source, result);
-            String xmlString = sw.toString();
+            String xmlString = XMLUtils.toString(element);
             ef.addProperty("parsedElement", createValue(context, xmlString));
             ef.setInitMethod("init");
             ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);

Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/test/XPathAssert.java
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/test/XPathAssert.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/java/org/apache/cxf/test/XPathAssert.java (original)
+++ cxf/trunk/testutils/src/main/java/org/apache/cxf/test/XPathAssert.java Thu Jul  4 00:58:37
2013
@@ -19,13 +19,11 @@
 
 package org.apache.cxf.test;
 
-import java.io.ByteArrayOutputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
 import javax.xml.namespace.NamespaceContext;
-import javax.xml.transform.TransformerException;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathFactory;
@@ -36,6 +34,7 @@ import org.w3c.dom.NodeList;
 import junit.framework.AssertionFailedError;
 
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.XMLUtils;
 
 import org.junit.Assert;
 
@@ -92,13 +91,7 @@ public final class XPathAssert {
     }
 
     private static String writeNodeToString(Node node) {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        try {
-            DOMUtils.writeXml(node, bos);
-        } catch (TransformerException e) {
-            throw new RuntimeException(e);
-        }
-        return bos.toString();
+        return XMLUtils.toString(node);
     }
 
     /**

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java Thu Jul
 4 00:58:37 2013
@@ -131,7 +131,7 @@ public final class JAXBUtils {
         try {
             tmpFile = FileUtils.createTempFile("customzied", ".xsd");
             fout = new FileOutputStream(tmpFile);
-            DOMUtils.writeXml(rootElement, fout);
+            XMLUtils.writeTo(rootElement, fout);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1499610&r1=1499609&r2=1499610&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Thu Jul  4 00:58:37 2013
@@ -827,7 +827,7 @@ public class WSDLToJavaContainer extends
                 updateImports(xsdEle, sourceMap);
             }
             updateWSDLImports(defEle, importWSDLMap);
-            DOMUtils.writeXml(defEle, wsdloutput);
+            XMLUtils.writeTo(defEle, wsdloutput);
             wsdloutput.close();
             
                     
@@ -844,7 +844,7 @@ public class WSDLToJavaContainer extends
                     updateImports(xsdEle, sourceMap);
                 }
                 updateWSDLImports(importEle, importWSDLMap);
-                DOMUtils.writeXml(importEle, wsdlOs);
+                XMLUtils.writeTo(importEle, wsdlOs);
                 wsdlOs.close();
 
             }               



Mime
View raw message