cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r678895 - in /cxf/branches/2.0.x-fixes: ./ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/in...
Date Tue, 22 Jul 2008 20:49:45 GMT
Author: dkulp
Date: Tue Jul 22 13:49:45 2008
New Revision: 678895

URL: http://svn.apache.org/viewvc?rev=678895&view=rev
Log:
Merged revisions 678891 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r678891 | dkulp | 2008-07-22 16:42:43 -0400 (Tue, 22 Jul 2008) | 3 lines
  
  [CXF-1620] Support for jaxb:extensionBindingPrefix attributes (and thus the xjc:simple things
and such)
........

Added:
    cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/jaxb_custom_extensors.wsdl
      - copied unchanged from r678891, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/jaxb_custom_extensors.wsdl
    cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/jaxb_custom_extensors.xjb
      - copied unchanged from r678891, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/jaxb_custom_extensors.xjb
Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 22 13:49:45 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=678895&r1=678894&r2=678895&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Tue Jul 22 13:49:45 2008
@@ -33,8 +33,10 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -234,6 +236,9 @@
         for (Node childNode = jaxwsBindingNode.getFirstChild();
             childNode != null;
             childNode = childNode.getNextSibling()) {
+            
+            copyJaxbAttributes(childNode, (Element)schemaNode);
+            
             if (!isJaxbBindings(childNode)) {
                 continue;
             }
@@ -246,8 +251,18 @@
                     copyAllJaxbDeclarations(node, childEl);
                 }
             } else {
-                final Node jaxbNode = childEl;
-                Node cloneNode = ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(), jaxbNode,
true);
+                Element cloneNode = (Element)ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(),

+                                                                     childEl, true);
+                
+                NamedNodeMap atts = cloneNode.getAttributes();
+                for (int x = 0; x < atts.getLength(); x++) {
+                    Attr attr = (Attr)atts.item(x);
+                    if (ToolConstants.NS_JAXB_BINDINGS.equals(attr.getNamespaceURI())) {
+                        cloneNode.removeAttributeNode(attr);
+                        atts = cloneNode.getAttributes();
+                        x = -1;
+                    }
+                }
                 appinfoNode.appendChild(cloneNode);
                 childNode = childNode.getNextSibling();
             }
@@ -260,6 +275,38 @@
         }
     }
 
+    private void copyJaxbAttributes(Node childNode, Element schemaNode) {
+        if (childNode instanceof Element) {
+            Element el = (Element)childNode;
+            NamedNodeMap atts = el.getAttributes();
+            for (int x = 0; x < atts.getLength(); x++) {
+                Attr attr = (Attr)atts.item(x);
+                if (ToolConstants.NS_JAXB_BINDINGS.equals(attr.getNamespaceURI())) {
+                    schemaNode.setAttributeNS(attr.getNamespaceURI(),
+                                              attr.getName(),
+                                              attr.getValue());
+                    if ("extensionBindingPrefixes".equals(attr.getLocalName())) {
+                        String pfxs = attr.getValue();
+                        while (pfxs.length() > 0) {
+                            String pfx = pfxs;
+                            int idx = pfx.indexOf(',');
+                            if (idx != -1) {
+                                pfxs = pfxs.substring(idx + 1);
+                                pfx = pfx.substring(0, idx);
+                            } else {
+                                pfxs = "";
+                            }
+                            String ns = el.lookupNamespaceURI(pfx);
+                            schemaNode.setAttribute("xmlns:" + pfx,
+                                                    ns);
+                        }
+                    }
+                }
+            }
+        }
+        
+    }
+
     protected void internalizeBinding(Element bindings, Element targetNode, String expression)
{
         if (bindings.getAttributeNode("wsdlLocation") != null) {
             expression = "/";

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?rev=678895&r1=678894&r2=678895&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
Tue Jul 22 13:49:45 2008
@@ -31,6 +31,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -318,11 +319,13 @@
             clone = document.createEntityReference(node.getNodeName());
             break;
         case Node.ELEMENT_NODE:
-            clone = document.createElement(node.getNodeName());
+            clone = document.createElementNS(node.getNamespaceURI(), node.getNodeName());
             NamedNodeMap attributes = node.getAttributes();
             for (int i = 0; i < attributes.getLength(); i++) {
-                ((Element)clone).setAttribute(attributes.item(i).getNodeName(), attributes.item(i)
-                    .getNodeValue());
+                Attr attr = (Attr)attributes.item(i);
+                ((Element)clone).setAttributeNS(attr.getNamespaceURI(),
+                                                attr.getNodeName(),
+                                                attr.getNodeValue());
             }
             break;
        

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=678895&r1=678894&r2=678895&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Jul 22 13:49:45 2008
@@ -937,4 +937,21 @@
         assertEquals("int", webFault.name());
     }
     
+    @Test
+    public void testCXF1620() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.wsdl"));   
+        env.put(ToolConstants.CFG_BINDING,
+                getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.xjb"));
+
+        processor.setContext(env);
+        processor.execute();
+        Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo");
+        
+        assertEquals(3, clz.getDeclaredFields().length);
+        
+        clz = classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo2");
+        assertEquals(1, clz.getDeclaredFields().length);
+    }
+    
 }



Mime
View raw message