cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r945125 - in /cxf/trunk: 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/java2wsdl/processor/i...
Date Mon, 17 May 2010 13:00:05 GMT
Author: dkulp
Date: Mon May 17 13:00:05 2010
New Revision: 945125

URL: http://svn.apache.org/viewvc?rev=945125&view=rev
Log:
With JAXB 2.2, support XmlElemnt on the params/return

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=945125&r1=945124&r2=945125&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
Mon May 17 13:00:05 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/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java?rev=945125&r1=945124&r2=945125&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanFieldAnnotator.java
Mon May 17 13:00:05 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/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java?rev=945125&r1=945124&r2=945125&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
Mon May 17 13:00:05 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);
                     }                   
                 }



Mime
View raw message