cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r691271 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/
Date Tue, 02 Sep 2008 15:10:47 GMT
Author: dkulp
Date: Tue Sep  2 08:10:46 2008
New Revision: 691271

URL: http://svn.apache.org/viewvc?rev=691271&view=rev
Log:
element.setAttributeNS(...) is very slow with Xerces.  Don't use it on critical path.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=691271&r1=691270&r2=691271&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Tue Sep
 2 08:10:46 2008
@@ -751,13 +751,15 @@
     }
 
     private static void declare(Element node, String uri, String prefix) {
+        String qualname;
         if (prefix != null && prefix.length() > 0) {
-            node.setAttributeNS(XML_NS, "xmlns:" + prefix, uri);
+            qualname = "xmlns:" + prefix;
         } else {
-            if (uri != null /* && uri.length() > 0 */) {
-                node.setAttributeNS(XML_NS, "xmlns", uri);
-            }
+            qualname = "xmlns";
         }
+        Attr attr = node.getOwnerDocument().createAttributeNS(XML_NS, qualname);
+        attr.setValue(uri);
+        node.setAttributeNodeNS(attr);
     }
 
     /**

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=691271&r1=691270&r2=691271&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
Tue Sep  2 08:10:46 2008
@@ -150,12 +150,16 @@
         if (prefix.length() == 0) {
             writeDefaultNamespace(namespace);
         } else {
-            currentNode.setAttributeNS(XML_NS, "xmlns:" + prefix, namespace);
+            Attr attr = document.createAttributeNS(XML_NS, "xmlns:" + prefix);
+            attr.setValue(namespace);
+            currentNode.setAttributeNodeNS(attr);
         }
     }
 
     public void writeDefaultNamespace(String namespace) throws XMLStreamException {
-        currentNode.setAttributeNS(XML_NS, "xmlns", namespace);
+        Attr attr = document.createAttributeNS(XML_NS, "xmlns");
+        attr.setValue(namespace);
+        currentNode.setAttributeNodeNS(attr);
     }
 
     public void writeComment(String value) throws XMLStreamException {

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?rev=691271&r1=691270&r2=691271&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Tue
Sep  2 08:10:46 2008
@@ -327,9 +327,10 @@
             //attributes cannot be in empty namespace...
             if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX) == null) {
                 pfx = JAXWSAConstants.WSA_PREFIX;
-                lastAdded.setAttributeNS("http://www.w3.org/2000/xmlns/",
-                                         "xmlns:wsa",
-                                         namespaceURI);
+                Attr attr = lastAdded.getOwnerDocument()
+                    .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa");
+                attr.setValue(namespaceURI);
+                lastAdded.setAttributeNodeNS(attr);
             } else if (lastAdded.lookupNamespaceURI(JAXWSAConstants.WSA_PREFIX).equals(namespaceURI))
{
                 pfx = JAXWSAConstants.WSA_PREFIX;
             } else {
@@ -338,9 +339,10 @@
                     cnt++;
                 }
                 pfx = JAXWSAConstants.WSA_PREFIX + cnt;
-                lastAdded.setAttributeNS("http://www.w3.org/2000/xmlns/",
-                                         "xmlns:wsa" + cnt,
-                                         namespaceURI);
+                Attr attr = lastAdded.getOwnerDocument()
+                    .createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:wsa" + cnt);
+                attr.setValue(namespaceURI);
+                lastAdded.setAttributeNodeNS(attr);
             }
         }
         Attr isRefParamAttr = 

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java?rev=691271&r1=691270&r2=691271&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java Tue
Sep  2 08:10:46 2008
@@ -37,6 +37,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -182,9 +183,12 @@
                     version.getHeader().getLocalPart());
             // add WSRM namespace declaration to header, instead of
             // repeating in each individual child node
-            hdr.setAttributeNS("http://www.w3.org/2000/xmlns/",
-                                  "xmlns:" + RMConstants.getNamespacePrefix(),
-                                 RMConstants.getNamespace());
+            
+            Attr attr = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", 
+                                   "xmlns:" + RMConstants.getNamespacePrefix());
+            attr.setValue(RMConstants.getNamespace());
+            hdr.setAttributeNodeNS(attr);
+
             Marshaller marshaller = getJAXBContext().createMarshaller();
             marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
            
@@ -262,9 +266,11 @@
                            marshaller);
             Node node = hdr.getFirstChild();
             if (node instanceof Element) {
-                ((Element)node).setAttributeNS("http://www.w3.org/2000/xmlns/",
-                        "xmlns:" + RMConstants.getNamespacePrefix(),
-                       RMConstants.getNamespace());
+                
+                Attr attr = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", 
+                                                  "xmlns:" + RMConstants.getNamespacePrefix());
+                attr.setValue(RMConstants.getNamespace());
+                ((Element)node).setAttributeNodeNS(attr);
             }
             
             header.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()),
node));



Mime
View raw message