cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r984414 - in /cxf/trunk/tools/javato/ws/src: main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ test/java/org/apache/cxf/tools/fortest/cxf2934/ test/java/org/apache/cxf/tools/java2ws/
Date Wed, 11 Aug 2010 14:07:35 GMT
Author: ema
Date: Wed Aug 11 14:07:34 2010
New Revision: 984414

URL: http://svn.apache.org/viewvc?rev=984414&view=rev
Log:
[CXF-2934]:Corrected target namespace in generated wrapper bean

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Address.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Employee.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Name.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/WebParamService.java
Modified:
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java?rev=984414&r1=984413&r2=984414&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
Wed Aug 11 14:07:34 2010
@@ -93,15 +93,6 @@ public class RequestWrapper extends Wrap
         return fields;
     }
 
-    private WebParam getWebParamAnnotation(final Annotation[] annotations) {
-        for (Annotation annotation : annotations) {
-            if (annotation instanceof WebParam) {
-                return (WebParam) annotation;
-            }
-        }
-        return null;
-    }
-
     @Override
     public WrapperBeanClass getWrapperBeanClass(final Method method) {
         javax.xml.ws.RequestWrapper reqWrapper = method.getAnnotation(javax.xml.ws.RequestWrapper.class);

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java?rev=984414&r1=984413&r2=984414&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
Wed Aug 11 14:07:34 2010
@@ -21,10 +21,14 @@ package org.apache.cxf.tools.java2wsdl.p
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+
 import org.apache.cxf.common.util.CollectionUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.MessageInfo;
@@ -92,15 +96,23 @@ public final class ResponseWrapper exten
             int idx = hasReturnType ? mpi.getIndex() - 1 : mpi.getIndex();
             if (idx >= 0) {
                 String name = mpi.getName().getLocalPart();
-
                 Type t = paramClasses[idx];
                 String type = getTypeString(t);
-
                 JavaField jf = new JavaField(name, type, "");
                 List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method,
idx - 1);
                 jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
-                fields.add(new JavaField(name, type, ""));
-
+                if (t instanceof ParameterizedType) {
+                    ParameterizedType pt = (ParameterizedType)t;
+                    Class c = (Class)pt.getRawType();
+                    if (Holder.class.isAssignableFrom(c)) {
+                        Annotation[][] paramAnnotations = method.getParameterAnnotations();
+                        WebParam wParam = getWebParamAnnotation(paramAnnotations[idx]);
+                        if (wParam != null && !StringUtils.isEmpty(wParam.targetNamespace()))
{
+                            jf.setTargetNamespace(wParam.targetNamespace());
+                        }
+                    }                   
+                }
+                fields.add(jf);
             }
         }
 
@@ -128,5 +140,4 @@ public final class ResponseWrapper exten
         jClass.setNamespace(resNs);
         return jClass;
     }
-
 }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java?rev=984414&r1=984413&r2=984414&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
Wed Aug 11 14:07:34 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -28,6 +29,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.jws.WebParam;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
@@ -111,7 +113,7 @@ public class Wrapper {
 
         if (StringUtils.isEmpty(c1.getName())) {
             c1.setName(c2.getName());
-        }
+        }       
         return c1;
     }
     
@@ -226,5 +228,14 @@ public class Wrapper {
         type = type.replace('$', '.');
         return type;
     }
+    
+    protected WebParam getWebParamAnnotation(final Annotation[] annotations) {
+        for (Annotation annotation : annotations) {
+            if (annotation instanceof WebParam) {
+                return (WebParam)annotation;
+            }
+        }
+        return null;
+    }
 
 }

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Address.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Address.java?rev=984414&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Address.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Address.java
Wed Aug 11 14:07:34 2010
@@ -0,0 +1,80 @@
+/**
+ * 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.cxf2934;
+
+public class Address {
+    private String street = "";
+    private String city = "";
+    private String state = "";
+    private String zipcode = "";
+    private String country = "";
+
+    public Address(String street, String city, String state, String zipcode, String country)
{
+
+        this.street = street;
+        this.city = city;
+        this.state = state;
+        this.zipcode = zipcode;
+        this.country = country;
+    }
+
+    public Address() {
+    }
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getZipcode() {
+        return zipcode;
+    }
+
+    public void setZipcode(String zipcode) {
+        this.zipcode = zipcode;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+}

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Employee.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Employee.java?rev=984414&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Employee.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Employee.java
Wed Aug 11 14:07:34 2010
@@ -0,0 +1,53 @@
+/**
+ * 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.cxf2934;
+
+public class Employee {
+
+    private Name name;
+    private Address address;
+
+    public Employee(Name name, Address address) {
+        this.name = name;
+
+        this.address = address;
+    }
+
+    public Employee() {
+        name = new Name();
+        address = new Address();
+    }
+
+    public Name getName() {
+        return name;
+    }
+
+    public void setName(Name name) {
+        this.name = name;
+    }
+
+    public Address getAddress() {
+        return address;
+    }
+
+    public void setAddress(Address address) {
+        this.address = address;
+    }
+
+}

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Name.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Name.java?rev=984414&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Name.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/Name.java
Wed Aug 11 14:07:34 2010
@@ -0,0 +1,49 @@
+/**
+ * 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.cxf2934;
+
+public class Name {
+
+    private String firstName = "";
+    private String lastName = "";
+
+    public Name(String firstName, String lastName) {
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public Name() {
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+}

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/WebParamService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/WebParamService.java?rev=984414&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/WebParamService.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf2934/WebParamService.java
Wed Aug 11 14:07:34 2010
@@ -0,0 +1,34 @@
+/**
+ * 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.cxf2934;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+
+public class WebParamService {
+    @WebMethod(operationName = "helloString", action = "urn:HelloString")
+    public String hello(
+                        @WebParam(name = "Name", targetNamespace = "helloString/Name", 
+                                  mode = WebParam.Mode.INOUT) Holder<Name> name,
+                        @WebParam(name = "Employee", mode = WebParam.Mode.OUT) Holder<Employee>
employee) {
+        return "Hello " + name;
+    }
+
+}

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=984414&r1=984413&r2=984414&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Wed Aug 11 14:07:34 2010
@@ -27,7 +27,6 @@ import org.apache.cxf.common.util.Compil
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolTestBase;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -80,6 +79,21 @@ public class JavaToWSTest extends ToolTe
         checkStdErr();
         assertTrue("Failed to generate WSDL file", wsdlFile.exists());
     }
+    
+    @Test
+    public void testCXF2934() throws Exception {
+        String[] args = new String[] {
+            "-wsdl", "-wrapperbean",
+            "-s", output.getPath(), 
+            "-o", output.getPath() + "/tmp.wsdl", 
+            "org.apache.cxf.tools.fortest.cxf2934.WebParamService"
+        };
+        JavaToWS.main(args);
+        File wrapper = outputFile("org/apache/cxf/tools/fortest/cxf2934/jaxws/HelloResponse.java");
+        String str = FileUtils.getStringFromFile(wrapper);
+        assertTrue("namespace value in annoataion @XmlElement is not correct"
+                   , str.indexOf("helloString/Name") > -1);
+    }
 
     private void checkStdErr() {
         String err = getStdErr();



Mime
View raw message