You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/05/18 23:00:43 UTC

svn commit: r945883 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/ tools/javato/ws/src/main/java/org/apache/cxf/tools/jav...

Author: dkulp
Date: Tue May 18 21:00:43 2010
New Revision: 945883

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

........
  r945125 | dkulp | 2010-05-17 09:00:05 -0400 (Mon, 17 May 2010) | 1 line
  
  With JAXB 2.2, support XmlElemnt on the params/return
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=945883&r1=945882&r2=945883&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java Tue May 18 21:00:43 2010
@@ -32,6 +32,7 @@ import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlMimeType;
 import javax.xml.bind.annotation.XmlNsForm;
@@ -314,22 +315,23 @@ public final class WrapperClassGenerator
                                         fieldDescriptor,
                                         null);
         
-        
-        AnnotationVisitor av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
-        av0.visit("name", name);
-        if (factory.isWrapperPartQualified(mpi)) {
-            av0.visit("namespace", mpi.getConcreteName().getNamespaceURI());            
-        }
-        if (factory.isWrapperPartNillable(mpi)) {
-            av0.visit("nillable", Boolean.TRUE);
-        }
-        if (factory.getWrapperPartMinOccurs(mpi) == 1) {
-            av0.visit("required", Boolean.TRUE);
-        }
-        av0.visitEnd();
+
 
         List<Annotation> jaxbAnnos = getJaxbAnnos(mpi);
-        addJAXBAnnotations(fv, jaxbAnnos);
+        if (!addJAXBAnnotations(fv, jaxbAnnos)) {
+            AnnotationVisitor av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
+            av0.visit("name", name);
+            if (factory.isWrapperPartQualified(mpi)) {
+                av0.visit("namespace", mpi.getConcreteName().getNamespaceURI());            
+            }
+            if (factory.isWrapperPartNillable(mpi)) {
+                av0.visit("nillable", Boolean.TRUE);
+            }
+            if (factory.getWrapperPartMinOccurs(mpi) == 1) {
+                av0.visit("required", Boolean.TRUE);
+            }
+            av0.visitEnd();            
+        }
         fv.visitEnd();
 
         String methodName = JAXBUtils.nameToIdentifier(name, JAXBUtils.IdentifierType.GETTER);
@@ -358,8 +360,9 @@ public final class WrapperClassGenerator
 
     }
      
-    private void addJAXBAnnotations(FieldVisitor fv, List<Annotation> jaxbAnnos) {
+    private boolean addJAXBAnnotations(FieldVisitor fv, List<Annotation> jaxbAnnos) {
         AnnotationVisitor av0;
+        boolean addedEl = false;
         for (Annotation ann : jaxbAnnos) {
             if (ann instanceof XmlMimeType) {
                 av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
@@ -381,8 +384,21 @@ public final class WrapperClassGenerator
             } else if (ann instanceof XmlList) {
                 av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
                 av0.visitEnd();
+            } else if (ann instanceof XmlElement) {
+                addedEl = true;   
+                XmlElement el = (XmlElement)ann;
+                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
+                av0.visit("name", el.name());
+                av0.visit("nillable", el.nillable());
+                av0.visit("requried", el.required());
+                av0.visit("namespace", el.namespace());
+                av0.visit("defaultValue", el.defaultValue());
+                av0.visit("type", el.type());
+                av0.visitEnd(); 
+                
             }
         }
+        return addedEl;
     }
     
     

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java?rev=945883&r1=945882&r2=945883&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java Tue May 18 21:00:43 2010
@@ -44,15 +44,7 @@ public class WrapperBeanFieldAnnotator i
             throw new RuntimeException("WrapperBeanFiledAnnotator expect JavaField as input");
         }
         String rawName = jField.getRawName();
-        JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
-        xmlElementAnnotation.addElement(new JAnnotationElement("name", rawName));
-        if (!StringUtils.isEmpty(jField.getTargetNamespace())) {
-            xmlElementAnnotation.addElement(new JAnnotationElement("namespace", 
-                                                                          jField.getTargetNamespace()));
-        }
-
-        jField.addAnnotation(xmlElementAnnotation);
-        
+        boolean hasEl = false;
         for (Annotation ann : jField.getJaxbAnnotaions()) {
             if (ann instanceof XmlMimeType) {
                 JAnnotation mimeAnno = new JAnnotation(XmlMimeType.class);
@@ -69,7 +61,39 @@ public class WrapperBeanFieldAnnotator i
             } else if (ann instanceof XmlList) {
                 JAnnotation jaxbAnn = new JAnnotation(XmlList.class);
                 jField.addAnnotation(jaxbAnn);
+            } else if (ann instanceof XmlElement) {
+                hasEl = true;
+                XmlElement el = (XmlElement)ann;
+                JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
+                xmlElementAnnotation.addElement(new JAnnotationElement("name", el.name()));
+                if (!StringUtils.isEmpty(el.namespace())) {
+                    xmlElementAnnotation.addElement(new JAnnotationElement("namespace", 
+                                                                           el.namespace()));
+                }
+                if (el.nillable()) {
+                    xmlElementAnnotation.addElement(new JAnnotationElement("nillable", 
+                                                                           el.nillable(), true));
+                }
+                if (el.required()) {
+                    xmlElementAnnotation.addElement(new JAnnotationElement("required",
+                                                                           el.required(), true));
+                }
+                if (!StringUtils.isEmpty(el.defaultValue())) {
+                    xmlElementAnnotation.addElement(new JAnnotationElement("defaultValue", 
+                                                                           el.defaultValue()));
+                }
+                jField.addAnnotation(xmlElementAnnotation);
             }
         }
+        if (!hasEl) {
+            JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
+            xmlElementAnnotation.addElement(new JAnnotationElement("name", rawName));
+            if (!StringUtils.isEmpty(jField.getTargetNamespace())) {
+                xmlElementAnnotation.addElement(new JAnnotationElement("namespace", 
+                                                                              jField.getTargetNamespace()));
+            }
+
+            jField.addAnnotation(xmlElementAnnotation);
+        }
     }
 }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java?rev=945883&r1=945882&r2=945883&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java Tue May 18 21:00:43 2010
@@ -26,6 +26,7 @@ import java.util.List;
 
 import javax.jws.Oneway;
 import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlMimeType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -82,7 +83,8 @@ public final class WrapperUtil {
                     if (ann.annotationType() == XmlAttachmentRef.class
                         || ann.annotationType() == XmlMimeType.class
                         || ann.annotationType() == XmlJavaTypeAdapter.class
-                        || ann.annotationType() == XmlList.class) {
+                        || ann.annotationType() == XmlList.class
+                        || ann.annotationType() == XmlElement.class) {
                         jaxbAnnotation.add(ann);
                     }                   
                 }