cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1125252 - in /cxf/branches/2.3.x-fixes: rt/core/src/main/java/org/apache/cxf/wsdl11/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ tools/wsdlto/test/src/test/java/org/apache/cxf/to...
Date Fri, 20 May 2011 06:38:39 GMT
Author: ema
Date: Fri May 20 06:38:38 2011
New Revision: 1125252

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

........
  r1124645 | ema | 2011-05-19 17:46:07 +0800 (Thu, 19 May 2011) | 1 line
  
  [CXF-2193]:Allow for WRAPPED style code generation for warpper elements with xsd:extension
of a wrapper-compatible type
........

Added:
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/
      - copied from r1124645, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl
      - copied unchanged from r1124645, cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl
Modified:
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=1125252&r1=1125251&r2=1125252&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Fri May 20 06:38:38 2011
@@ -83,6 +83,7 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
 
 import static org.apache.cxf.helpers.CastUtils.cast;
 
@@ -740,56 +741,77 @@ public class WSDLServiceBuilder {
                                                MessageInfo wrapper, boolean allowRefs) {
         if (type.getParticle() instanceof XmlSchemaSequence) {
             XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
-            XmlSchemaObjectCollection items = seq.getItems();
-            boolean ret = true;
-            for (int x = 0; x < items.getCount(); x++) {
-                XmlSchemaObject o = items.getItem(x);
-                if (!(o instanceof XmlSchemaElement)) {
-                    return false;
-                }
-                XmlSchemaElement el = (XmlSchemaElement)o;
-
-                if (el.getSchemaTypeName() != null) {
-                    MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
-                    mpi.setTypeQName(el.getSchemaTypeName());
-                    mpi.setElement(true);
-                    mpi.setElementQName(el.getQName());
-                    mpi.setConcreteName(el.getQName());
-                    mpi.setXmlSchema(el);
-                } else if (el.getRefName() != null) {
-                    MessagePartInfo mpi = wrapper.addMessagePart(el.getRefName());
-                    mpi.setTypeQName(el.getRefName());
-                    mpi.setElementQName(el.getRefName());
-                    mpi.setElement(true);
-                    mpi.setXmlSchema(el);
-                    mpi.setProperty("isRefElement", true);
-                    // element reference is not permitted for wrapper element
-                    if (!allowRefs) {
-                        ret = false;
-                    }
-                } else {
-                    // anonymous type
-                    MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
-                    mpi.setElementQName(mpi.getName());
-                    mpi.setConcreteName(el.getQName());
-                    mpi.setElement(true);
-                    mpi.setXmlSchema(el);
-                }
-            }
-
-            return ret;
+            return buildMessageParts(seq, namespaceURI, wrapper, allowRefs);
         } else if (type.getParticle() == null) {
             if (type.getContentModel() == null) {
                 return true;
             }
             if (type.getContentModel().getContent() instanceof XmlSchemaComplexContentExtension)
{
-                return false;
+                XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)type
+                    .getContentModel().getContent();
+                QName baseTypeName = extension.getBaseTypeName();
+                ServiceInfo serviceInfo = wrapper.getOperation().getInterface().getService();
+                XmlSchemaType schemaType = serviceInfo.getXmlSchemaCollection().getTypeByQName(baseTypeName);
+                if (!(schemaType instanceof XmlSchemaComplexType)
+                    || !isWrappableSequence((XmlSchemaComplexType)schemaType, namespaceURI,
wrapper,
+                                            allowRefs)) {
+                    return false;
+                }
+                             
+                if (extension.getParticle() instanceof XmlSchemaSequence) {
+                    XmlSchemaSequence seq = (XmlSchemaSequence)extension.getParticle();
+                    return buildMessageParts(seq, namespaceURI, wrapper, allowRefs);
+                }  
+                
             }
             return true;
         }
         return false;
     }
 
+        
+    private static boolean buildMessageParts(XmlSchemaSequence seq, String namespaceURI,
MessageInfo wrapper,
+                                             boolean allowRefs) {     
+        XmlSchemaObjectCollection items = seq.getItems();
+        boolean ret = true;
+        for (int x = 0; x < items.getCount(); x++) {
+            XmlSchemaObject o = items.getItem(x);
+            if (!(o instanceof XmlSchemaElement)) {
+                return false;
+            }
+            XmlSchemaElement el = (XmlSchemaElement)o;
+
+            if (el.getSchemaTypeName() != null) {
+                MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
+                mpi.setTypeQName(el.getSchemaTypeName());
+                mpi.setElement(true);
+                mpi.setElementQName(el.getQName());
+                mpi.setConcreteName(el.getQName());
+                mpi.setXmlSchema(el);
+            } else if (el.getRefName() != null) {
+                MessagePartInfo mpi = wrapper.addMessagePart(el.getRefName());
+                mpi.setTypeQName(el.getRefName());
+                mpi.setElementQName(el.getRefName());
+                mpi.setElement(true);
+                mpi.setXmlSchema(el);
+                mpi.setProperty("isRefElement", true);
+                // element reference is not permitted for wrapper element
+                if (!allowRefs) {
+                    ret = false;
+                }
+            } else {
+                // anonymous type
+                MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
+                mpi.setElementQName(mpi.getName());
+                mpi.setConcreteName(el.getQName());
+                mpi.setElement(true);
+                mpi.setXmlSchema(el);
+            }
+        }
+        return ret;      
+    }
+        
+        
     private void buildMessage(AbstractMessageContainer minfo, Message msg) {
         SchemaCollection schemas = minfo.getOperation().getInterface().getService()
             .getXmlSchemaCollection();

Modified: cxf/branches/2.3.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.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?rev=1125252&r1=1125251&r2=1125252&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
Fri May 20 06:38:38 2011
@@ -49,11 +49,14 @@ import org.apache.cxf.tools.util.NameUti
 import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaContent;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaForm;
 import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
 
 public final class ProcessorUtil {
     private static final String KEYWORDS_PREFIX = "_";
@@ -380,9 +383,41 @@ public final class ProcessorUtil {
         XmlSchemaElement elementByName = schema.getElementByQName(partElement);
         
         XmlSchemaComplexType type = (XmlSchemaComplexType)elementByName.getSchemaType();
-
+        
         XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
        
+        qnames.addAll(createWrappedElements(seq));    
+
+        //If it's extension
+        if (seq == null && type.getContentModel() != null) {
+            
+            XmlSchemaContent xmlSchemaConent = type.getContentModel().getContent();
+            if (xmlSchemaConent instanceof XmlSchemaComplexContentExtension) {
+                XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)type
+                    .getContentModel().getContent();
+                QName baseTypeName = extension.getBaseTypeName();
+                XmlSchemaType schemaType = schema.getTypeByQName(baseTypeName);
+                if (schemaType instanceof XmlSchemaComplexType) {
+                    XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType;
+                    if (complexType.getParticle() instanceof XmlSchemaSequence) {
+                        seq = (XmlSchemaSequence)complexType.getParticle();
+                        qnames.addAll(createWrappedElements(seq));
+                    }
+                }
+
+                if (extension.getParticle() instanceof XmlSchemaSequence) {
+                    XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence)extension.getParticle();
+                    qnames.addAll(createWrappedElements(xmlSchemaSeq));
+                }
+            }
+
+        }
+        return qnames;
+    }
+
+    private static List<WrapperElement> createWrappedElements(XmlSchemaSequence seq)
{
+       
+        List<WrapperElement> qnames = new ArrayList<WrapperElement>();
         if (seq != null) {
 
             XmlSchemaObjectCollection items = seq.getItems();

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=1125252&r1=1125251&r2=1125252&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Fri May 20 06:38:38 2011
@@ -1366,5 +1366,26 @@ public class CodeGenTest extends Abstrac
         fault = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault");
         assertEquals(fault.getName().hashCode(), ObjectStreamClass.lookup(fault).getSerialVersionUID());
     }
+    
+    
+    @Test
+    public void testExtensionWrapper() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL,
+                getLocation("/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl"));
+        processor.setContext(env);
+        processor.execute();
+
+        File infFile = new File(output, "org/apache/cxf/w2j/extension_wrapped/Greeter.java");
+        assertTrue(infFile.exists());
+
+        Class<?> interfaceClass = classLoader.loadClass("org.apache.cxf.w2j.extension_wrapped.Greeter");
+
+        Method method = interfaceClass.getMethod("greetMe", new Class[] {
+            Holder.class, Holder.class, Holder.class, Holder.class, Holder.class
+        });
+        assertTrue("greetMe operation is NOT generated correctly as excepted", method !=
null);
+        RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
+        assertNotNull("@RequestWrapper is expected", reqWrapper);
+    }
 
 }



Mime
View raw message