cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] git commit: [CXF-5596]:Schema element generated from exception class doesn't honor @XmlElement annotation
Date Thu, 06 Mar 2014 10:37:42 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 4faeb62fd -> 3d3956033


[CXF-5596]:Schema element generated from exception class doesn't honor @XmlElement annotation


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3d395603
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3d395603
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3d395603

Branch: refs/heads/2.7.x-fixes
Commit: 3d39560337c6ae0ae514e11cc1f242d8f3de4b4f
Parents: 6976633
Author: jimma <ema@redhat.com>
Authored: Thu Mar 6 17:55:52 2014 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Thu Mar 6 18:37:18 2014 +0800

----------------------------------------------------------------------
 .../apache/cxf/jaxb/JAXBSchemaInitializer.java  | 27 ++++++++++++++------
 .../org/apache/cxf/frontend/WSDLGetUtils.java   |  3 ++-
 .../processor/JavaToProcessorTest.java          |  2 +-
 3 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3d395603/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
index 946d526..e0296df 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
@@ -40,6 +40,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlAccessOrder;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorOrder;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -552,7 +553,8 @@ class JAXBSchemaInitializer extends ServiceModelVisitor {
             } else {
                 JAXBBeanInfo beanInfo = getBeanInfo(type);
                 if (beanInfo != null) {
-                    addElement(schema, seq, beanInfo, new QName(namespace, f.getName()),
isArray(type));
+                    XmlElement xmlElementAnno = f.getAnnotation(XmlElement.class);
+                    addElement(schema, seq, beanInfo, new QName(namespace, f.getName()),
isArray(type), xmlElementAnno);
                 }
             }
         }
@@ -574,7 +576,8 @@ class JAXBSchemaInitializer extends ServiceModelVisitor {
                     int idx = m.getName().startsWith("get") ? 3 : 2;
                     String name = m.getName().substring(idx);
                     name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
-                    addElement(schema, seq, beanInfo, new QName(namespace, name), isArray(type));
+                    XmlElement  xmlElementAnno =  m.getAnnotation(XmlElement.class);
+                    addElement(schema, seq, beanInfo, new QName(namespace, name), isArray(type),
xmlElementAnno);
                 }
             }
         }
@@ -723,16 +726,20 @@ class JAXBSchemaInitializer extends ServiceModelVisitor {
 
     protected void addElement(XmlSchema schema,
                               XmlSchemaSequence seq, JAXBBeanInfo beanInfo,
-                              QName name, boolean isArray) {
+                              QName name, boolean isArray, XmlElement xmlElementAnno) {
         XmlSchemaElement el = new XmlSchemaElement(schema, false);
-
         if (isArray) {
             el.setMinOccurs(0);
             el.setMaxOccurs(Long.MAX_VALUE);
         } else {
-            el.setMinOccurs(1);
-            el.setMaxOccurs(1);
-            el.setNillable(true);
+            if (xmlElementAnno == null) {
+                el.setMinOccurs(0);
+                el.setNillable(false);
+            } else {
+                el.setNillable(xmlElementAnno.nillable());
+                int minOccurs = xmlElementAnno.required() ? 1 : 0;
+                el.setMinOccurs(minOccurs);
+            }
         }
 
         if (beanInfo.isElement()) {
@@ -742,7 +749,11 @@ class JAXBSchemaInitializer extends ServiceModelVisitor {
             el.setNillable(false);
             el.getRef().setTargetQName(el2.getQName());
         } else {
-            el.setName(name.getLocalPart());
+            if (xmlElementAnno != null && !StringUtils.isEmpty(xmlElementAnno.name()))
{
+                el.setName(xmlElementAnno.name());
+            } else {
+                el.setName(name.getLocalPart());
+            }
             Iterator<QName> itr = beanInfo.getTypeNames().iterator();
             if (!itr.hasNext()) {
                 return;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d395603/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
index ef9f9f6..11fed9b 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
@@ -57,6 +57,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
 import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.util.UrlUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
@@ -68,7 +69,7 @@ import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.cxf.wsdl11.ResourceManagerWSDLLocator;
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
-import org.springframework.util.StringUtils;
+
 
 /**
  * 

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d395603/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
index d52ec15..7751893 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
@@ -907,7 +907,7 @@ public class JavaToProcessorTest extends ProcessorTestBase {
         
         String at = ((Element)nd).getAttribute("type");
         assertTrue(at.contains("myClass2"));
-        assertEquals("true", ((Element)nd).getAttribute("nillable"));
+        assertEquals("0", ((Element)nd).getAttribute("minOccurs"));
     }
     
     


Mime
View raw message