cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r533289 - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/model/ javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/ javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ja...
Date Sat, 28 Apr 2007 03:51:33 GMT
Author: mmao
Date: Fri Apr 27 20:51:31 2007
New Revision: 533289

URL: http://svn.apache.org/viewvc?view=rev&rev=533289
Log:
CXF-611 Java2Wsdl support generate wrapper beans in different package

Added:
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterNoWrapperBean.java
Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.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/internal/jaxws/WrapperTest.java

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java?view=diff&rev=533289&r1=533288&r2=533289
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
Fri Apr 27 20:51:31 2007
@@ -213,4 +213,14 @@
         sb.append(getName());
         return sb.toString();
     }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        for (String anno : annotations) {
+            sb.append(anno);
+            sb.append("\n");
+        }
+        sb.append(getFullClassName());
+        return sb.toString();
+    }
 }

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=533289&r1=533288&r2=533289
==============================================================================
--- 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
Fri Apr 27 20:51:31 2007
@@ -97,13 +97,11 @@
             if (op.getUnwrappedOperation() != null) {
                 if (op.hasInput()) {
                     QName wrapperBeanName = op.getInput().getMessageParts().get(0).getElementQName();
-                    
                     RequestWrapper requestWrapper = new RequestWrapper();
                     requestWrapper.setName(wrapperBeanName);
                     requestWrapper.setMethod((Method) op.getProperty(Method.class.getName()));
                     JavaClass jClass = requestWrapper.getJavaClass();
-
-                    if (requestWrapper.isWrapperAbsent()) {
+                    if (requestWrapper.isWrapperAbsent() || requestWrapper.isToDifferentPackage())
{
                         nsPkgMapping.put(wrapperBeanName.getNamespaceURI(), jClass.getPackageName());
                     }
 
@@ -118,7 +116,7 @@
                     responseWrapper.setMethod((Method) op.getProperty(Method.class.getName()));
                     JavaClass jClass = responseWrapper.getJavaClass();
 
-                    if (responseWrapper.isWrapperAbsent()) {
+                    if (responseWrapper.isWrapperAbsent() || responseWrapper.isToDifferentPackage())
{
                         nsPkgMapping.put(wrapperBeanName.getNamespaceURI(), jClass.getPackageName());
                     }
 
@@ -132,7 +130,6 @@
         if (wrapperClasses.isEmpty()) {
             return;
         }
-
         
         Map<String, Element> schemas = new HashMap<String, Element>();
         for (SchemaInfo s : serviceInfo.getSchemas()) {

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java?view=diff&rev=533289&r1=533288&r2=533289
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
Fri Apr 27 20:51:31 2007
@@ -26,6 +26,7 @@
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.model.JavaClass;
 import org.apache.cxf.tools.util.AnnotationUtil;
@@ -37,6 +38,7 @@
     private QName name;
     private JavaClass javaClass;
     private Method mehtod;
+    private boolean isSamePackage;
 
     public void setMethod(Method m) {
         this.mehtod = m;
@@ -55,7 +57,6 @@
         if (wrapperBeanName == null) {
             return jClass;
         }
-
         String ns = wrapperBeanName.getNamespaceURI();
         jClass.setNamespace(ns);
         jClass.setPackageName(URIParserUtil.getPackageName(ns));
@@ -64,15 +65,18 @@
     }
 
     private JavaClass merge(final JavaClass c1, final JavaClass c2) {
-        if (c1.getNamespace() == null) {
+        if (StringUtils.isEmpty(c1.getNamespace())) {
             c1.setNamespace(c2.getNamespace());
         }
 
-        if (c1.getPackageName() == null) {
+        if (StringUtils.isEmpty(c1.getPackageName())) {
             c1.setPackageName(c2.getPackageName());
+        } else {
+            this.isSamePackage = c1.getPackageName().equals(c2.getPackageName());
         }
 
-        if (c1.getName() == null) {
+
+        if (StringUtils.isEmpty(c1.getName())) {
             c1.setName(c2.getName());
         }
         return c1;
@@ -108,6 +112,10 @@
         } catch (ToolException e) {
             return true;
         }
+    }
+
+    public boolean isToDifferentPackage() {
+        return !isSamePackage;
     }
 
     public Class getWrapperClass() {

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterNoWrapperBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterNoWrapperBean.java?view=auto&rev=533289
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterNoWrapperBean.java
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/GreeterNoWrapperBean.java
Fri Apr 27 20:51:31 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 GreeterNoWrapperBean {
+    @WebMethod
+    @RequestWrapper(className = "org.apache.cxf.SayHi")
+    @ResponseWrapper(className = "org.apache.cxf.SayHiResponse")
+    String sayHi();
+}

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=533289&r1=533288&r2=533289
==============================================================================
--- 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
Fri Apr 27 20:51:31 2007
@@ -272,5 +272,19 @@
         assertTrue(responseWrapperClass.exists());
     }
 
+    @Test
+    public void testGenWrapperInAnotherPackage() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME,
+                "org.apache.cxf.tools.fortest.withannotation.doc.GreeterNoWrapperBean");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_greeter_no_wrapper.wsdl");
         
+        processor.setEnvironment(env);
+        processor.process();
+
+        String pkgBase = "org/apache/cxf";
+        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/internal/jaxws/WrapperTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java?view=diff&rev=533289&r1=533288&r2=533289
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java
Fri Apr 27 20:51:31 2007
@@ -75,6 +75,7 @@
         Wrapper wrapper = new RequestWrapper();
         wrapper.setMethod(method);
         assertTrue(wrapper.isWrapperAbsent());
+        assertTrue(wrapper.isToDifferentPackage());
         assertFalse(wrapper.isWrapperBeanClassNotExist());
         assertEquals(pkgName + ".jaxws", wrapper.getJavaClass().getPackageName());
         assertEquals("GetPrice", wrapper.getJavaClass().getName());
@@ -86,6 +87,7 @@
         wrapper = new RequestWrapper();
         wrapper.setMethod(method);
         assertFalse(wrapper.isWrapperAbsent());
+        assertTrue(wrapper.isToDifferentPackage());
         assertFalse(wrapper.isWrapperBeanClassNotExist());
         assertEquals(pkgName + ".jaxws", wrapper.getJavaClass().getPackageName());
         assertEquals("GetPrice", wrapper.getJavaClass().getName());
@@ -97,6 +99,7 @@
         wrapper = new RequestWrapper();
         wrapper.setMethod(method);
         assertFalse(wrapper.isWrapperAbsent());
+        assertTrue(wrapper.isToDifferentPackage());
         assertFalse(wrapper.isWrapperBeanClassNotExist());
         assertEquals(pkgName, wrapper.getJavaClass().getPackageName());
         assertEquals("SayHi", wrapper.getJavaClass().getName());



Mime
View raw message