cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r533323 - in /incubator/cxf/trunk: rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/ tools/javato/src/test/java/org/apache/cxf/tools/fortest/withanno...
Date Sat, 28 Apr 2007 09:46:21 GMT
Author: mmao
Date: Sat Apr 28 02:46:20 2007
New Revision: 533323

URL: http://svn.apache.org/viewvc?view=rev&rev=533323
Log:
CXF-610 Java2Wsdl can not handle String[] in generating wrapper beans

Added:
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArray.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArrayImpl.java
Modified:
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/db.wsdl

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=533323&r1=533322&r2=533323
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Sat Apr 28 02:46:20 2007
@@ -593,6 +593,14 @@
         
         
     }
+
+    private boolean isArrayType(MessagePartInfo part) {
+        Type type = (Type) part.getProperty(GENERIC_TYPE);
+        if (type instanceof Class) {
+            return ((Class<?>)type).isArray();
+        }
+        return false;
+    }
     
     private void createWrappedMessageSchema(AbstractMessageContainer wrappedMessage,
                                             AbstractMessageContainer unwrappedMessage,
@@ -614,10 +622,17 @@
             el = new XmlSchemaElement();
             el.setName(mpi.getName().getLocalPart());
             el.setQName(mpi.getName());
-            el.setMinOccurs(1);
-            el.setMaxOccurs(1);
-            el.setNillable(true);
-            
+
+
+            if (isArrayType(mpi)) {
+                el.setMinOccurs(0);
+                el.setMaxOccurs(Long.MAX_VALUE);
+            } else {
+                el.setMinOccurs(1);
+                el.setMaxOccurs(1);
+                el.setNillable(true);
+            }
+
             if (mpi.isElement()) {
                 el.setRefName(mpi.getElementQName());
             } else {
@@ -636,7 +651,7 @@
         op.setInput(inMsg.getName().getLocalPart(), inMsg);
         for (int j = 0; j < paramClasses.length; j++) {
             if (isInParam(method, j)) {
-                final QName q = getInParameterName(op, method, j);                
+                final QName q = getInParameterName(op, method, j);
                 final QName q2 = getInPartName(op, method, j);
                 MessagePartInfo part = inMsg.addMessagePart(q2);
                 initializeParameter(part, paramClasses[j], method.getGenericParameterTypes()[j]);
@@ -756,9 +771,12 @@
             ParameterizedType paramType = (ParameterizedType)type;
             rawClass = getHolderClass(paramType);
         }
+        if (rawClass.isArray()) {
+            rawClass = rawClass.getComponentType();
+        }
+
         part.setProperty(GENERIC_TYPE, type);
         part.setTypeClass(rawClass);
-        
     }
 
     protected Class getHolderClass(ParameterizedType paramType) {

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java?view=diff&rev=533323&r1=533322&r2=533323
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
Sat Apr 28 02:46:20 2007
@@ -63,7 +63,7 @@
             dir = new File("./");
         }
         generateWrapperBeanClasses(getServiceModel(), dir);
-        return sourcedir;
+        return dir;
     }
     
     public void setCompileToDir(File f) {

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArray.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArray.java?view=auto&rev=533323
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArray.java
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArray.java
Sat Apr 28 02:46:20 2007
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.fortest.withannotation.doc;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(name = "Hello")
+public interface GreeterStringArray {
+    @WebMethod
+    @RequestWrapper
+    @ResponseWrapper
+    String[] sayHi(String[] array);
+}

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArrayImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArrayImpl.java?view=auto&rev=533323
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArrayImpl.java
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterStringArrayImpl.java
Sat Apr 28 02:46:20 2007
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.fortest.withannotation.doc;
+
+import javax.jws.WebService;
+
+@WebService(name = "Hello")
+public class GreeterStringArrayImpl {
+    public String[] sayHi(String[] array) {
+        return new String[0];
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=533323&r1=533322&r2=533323
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Sat Apr 28 02:46:20 2007
@@ -287,4 +287,20 @@
         assertTrue(requestWrapperClass.exists());
         assertTrue(responseWrapperClass.exists());
     }
+
+    @Test
+    public void testGenWrapperWithStringArray() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME,
+                "org.apache.cxf.tools.fortest.withannotation.doc.GreeterStringArray");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_greeter_string_array.wsdl");
+        
+        processor.setEnvironment(env);
+        processor.process();
+
+        String pkgBase = "org/apache/cxf/tools/fortest/withannotation/doc/jaxws";
+        File requestWrapperClass = new File(output, pkgBase + "/SayHi.java");
+        File responseWrapperClass = new File(output, pkgBase + "/SayHiResponse.java");
+        assertTrue(requestWrapperClass.exists());
+        assertTrue(responseWrapperClass.exists());        
+    }
 }

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/db.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/db.wsdl?view=diff&rev=533323&r1=533322&r2=533323
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/db.wsdl
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/db.wsdl
Sat Apr 28 02:46:20 2007
@@ -43,7 +43,7 @@
 <xs:element name="operation0Response">
 <xs:complexType>
 <xs:sequence>
-<xs:element name="return" nillable="true" type="tns:operation0ResponseTypeArray"/>
+<xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="tns:operation0ResponseType"/>
 </xs:sequence>
 </xs:complexType>
 </xs:element>
@@ -114,4 +114,4 @@
       <soap:address location="http://localhost:9090/hello"/>
     </wsdl:port>
   </wsdl:service>
-</wsdl:definitions>
+</wsdl:definitions>
\ No newline at end of file



Mime
View raw message