You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/05/26 21:06:40 UTC

svn commit: r1128043 - in /cxf/branches/2.3.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/wsdl11/ tools/common/src/main/java/org/apache/cxf/tools/common/model/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/proc...

Author: dkulp
Date: Thu May 26 19:06:39 2011
New Revision: 1128043

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

........
  r1128036 | dkulp | 2011-05-26 14:59:17 -0400 (Thu, 26 May 2011) | 1 line
  
  [CXF-2465, CXF-3182] Output wsdl:documentation information into javadoc
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/branches/2.3.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaPort.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/FaultProcessor.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/MethodMapper.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
    cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world.wsdl

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

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=1128043&r1=1128042&r2=1128043&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 Thu May 26 19:06:39 2011
@@ -45,6 +45,7 @@ import javax.wsdl.Part;
 import javax.wsdl.Port;
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
+import javax.wsdl.WSDLElement;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap12.SOAP12Binding;
@@ -52,6 +53,8 @@ import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
 
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactory;
@@ -140,6 +143,13 @@ public class WSDLServiceBuilder {
             info.setExtensionAttributes(attrs);
         }
     }
+    
+    private void copyDocumentation(AbstractPropertiesHolder info, WSDLElement el) {
+        if (el.getDocumentationElement() != null) {
+            String doc = XMLUtils.getFullTextChildrenFromElement(el.getDocumentationElement());
+            info.setDocumentation(doc);
+        }
+    }
 
     public List<ServiceInfo> buildServices(Definition d) {
         DescriptionInfo description = new DescriptionInfo();
@@ -323,7 +333,7 @@ public class WSDLServiceBuilder {
                     service.setProperty(WSDL_SERVICE, serv);
                 }
                 getSchemas(def, service);
-
+                copyDocumentation(service, serv);
                 service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
                 service.setTargetNamespace(def.getTargetNamespace());
                 service.setName(serv.getQName());
@@ -452,7 +462,7 @@ public class WSDLServiceBuilder {
         if (ei == null) {
             ei = new EndpointInfo(service, ns);
         }
-
+        copyDocumentation(ei, port);
         ei.setName(new QName(service.getName().getNamespaceURI(), port.getName()));
         ei.setBinding(bi);
         copyExtensors(ei, port.getExtensibilityElements());
@@ -553,6 +563,7 @@ public class WSDLServiceBuilder {
             inf.setDescription(si.getDescription());
             d.getDescribed().add(inf);
         }
+        copyDocumentation(inf, p);
         this.copyExtensors(inf, p.getExtensibilityElements());
         this.copyExtensionAttributes(inf, p);
         if (recordOriginal) {
@@ -569,6 +580,7 @@ public class WSDLServiceBuilder {
         if (recordOriginal) {
             opInfo.setProperty(WSDL_OPERATION, op);
         }
+        copyDocumentation(opInfo, op);
         List<String> porderList = CastUtils.cast((List)op.getParameterOrdering());
         opInfo.setParameterOrdering(porderList);
         this.copyExtensors(opInfo, op.getExtensibilityElements());
@@ -600,6 +612,7 @@ public class WSDLServiceBuilder {
             Map.Entry<String, Fault> entry = cast(rawentry, String.class, Fault.class);
             FaultInfo finfo = opInfo.addFault(new QName(inf.getName().getNamespaceURI(), entry.getKey()),
                                               entry.getValue().getMessage().getQName());
+            copyDocumentation(finfo, entry.getValue());
             buildMessage(finfo, entry.getValue().getMessage());
             copyExtensors(finfo, entry.getValue().getExtensibilityElements());
             copyExtensionAttributes(finfo, entry.getValue());

Modified: cxf/branches/2.3.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaPort.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaPort.java?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaPort.java (original)
+++ cxf/branches/2.3.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaPort.java Thu May 26 19:06:39 2011
@@ -39,11 +39,18 @@ public class JavaPort {
     private String namespace;
     private String portName;
     private String methodName;
+    private String javadoc;
     
     public JavaPort(String pname) {
         this.name = pname;
     }
 
+    public void setJavaDoc(String d) {
+        javadoc = d;
+    }
+    public String getJavaDoc() {
+        return javadoc == null ? "" : javadoc;
+    }
     public void setTransURI(String uri) {
         this.transURI = uri;
     }

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/FaultProcessor.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/FaultProcessor.java?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/FaultProcessor.java (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/FaultProcessor.java Thu May 26 19:06:39 2011
@@ -144,5 +144,6 @@ public class FaultProcessor extends Abst
             expClass.addField(fField);
         }
         model.addExceptionClass(packageName + "." + name, expClass);
+        expClass.setClassJavaDoc(faultMessage.getDocumentation());
     }
 }

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.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/PortTypeProcessor.java?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/PortTypeProcessor.java Thu May 26 19:06:39 2011
@@ -28,6 +28,7 @@ import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -85,6 +86,9 @@ public class PortTypeProcessor extends A
 
                 intf.setClassJavaDoc(infBinding.getJaxwsClass().getComments());
             }
+            if (StringUtils.isEmpty(intf.getClassJavaDoc())) {
+                intf.setClassJavaDoc(interfaceInfo.getDocumentation());
+            }
 
             ClassCollector collector = context.get(ClassCollector.class);
             if (context.optionSet(ToolConstants.CFG_AUTORESOLVE)) {

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.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/ServiceProcessor.java?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java Thu May 26 19:06:39 2011
@@ -36,6 +36,7 @@ import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -242,6 +243,9 @@ public class ServiceProcessor extends Ab
         }
         
         sclz.setClassJavaDoc(jaxwsBinding.getClassJavaDoc());
+        if (StringUtils.isEmpty(sclz.getClassJavaDoc())) {
+            sclz.setClassJavaDoc(service.getDocumentation());
+        }
         model.addServiceClass(sclz.getName(), sclz);
     }
 
@@ -281,6 +285,7 @@ public class ServiceProcessor extends Ab
         for (BindingOperationInfo bop : operations) {
             processOperation(model, bop, binding);
         }
+        jport.setJavaDoc(port.getDocumentation());
         return jport;
     }
     private void processBindings(JavaModel model) {

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/MethodMapper.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/mapper/MethodMapper.java?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/MethodMapper.java (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/MethodMapper.java Thu May 26 19:06:39 2011
@@ -47,9 +47,10 @@ public final class MethodMapper {
         if (opBinding != null
             && opBinding.getMethodJavaDoc() != null) {
             method.setJavaDoc(opBinding.getMethodJavaDoc());
+        } else {
+            method.setJavaDoc(operation.getDocumentation());
         }
 
-
         if (operation.isOneWay()) {
             method.setStyle(OperationType.ONE_WAY);
         } else {

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
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/template/fault.vm?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm Thu May 26 19:06:39 2011
@@ -24,10 +24,13 @@ import javax.xml.ws.WebFault;
 
 
 /**
+#if ($expClass.classJavaDoc != "")
+ * $expClass.classJavaDoc
+ *
+#end   
  * This class was generated by $fullversion
  * $currentdate
  * Generated source version: $version
- * 
  */
 
 #foreach ($field in $expClass.Fields)

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
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/template/sei.vm?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm Thu May 26 19:06:39 2011
@@ -29,17 +29,15 @@ import ${import};
 #end
 
 /**
+#if ($intf.classJavaDoc != "")
+ * $intf.classJavaDoc
+ *
+#end
  * This class was generated by $fullversion
  * $currentdate
  * Generated source version: $version
  * 
  */
- 
-#if ($intf.classJavaDoc != "")
-/**
- * $intf.classJavaDoc
- */
-#end
 #foreach ($annotation in $intf.Annotations)
 $annotation
 #end

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
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/template/service.vm?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm Thu May 26 19:06:39 2011
@@ -35,18 +35,15 @@ import ${import};
 #end
 
 /**
+#if ($service.classJavaDoc != "")
+ * $service.classJavaDoc
+ *
+#end
  * This class was generated by $fullversion
  * $currentdate
  * Generated source version: $version
  * 
  */
-
-#if ($service.classJavaDoc != "")
-/**
- * $service.classJavaDoc
- */
-#end
-
 @WebServiceClient(name = "${service.ServiceName}", 
 #if ($wsdlLocation != "")
                   wsdlLocation = "$wsdlLocation",
@@ -152,7 +149,10 @@ public class ${service.Name} extends ${s
 #set($portClassName = ${port.fullClassName})
 #end
     /**
-     * 
+#if ($port.javaDoc != "")
+     * $port.javaDoc
+#end
+     *
      * @return
      *     returns ${port.InterfaceClass}
      */
@@ -165,6 +165,9 @@ public class ${service.Name} extends ${s
     }
 
     /**
+#if ($port.javaDoc != "")
+     * $port.javaDoc
+#end
      * 
      * @param features
      *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.

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=1128043&r1=1128042&r2=1128043&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 Thu May 26 19:06:39 2011
@@ -26,6 +26,7 @@ import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.Arrays;
+import java.util.List;
 
 import javax.jws.HandlerChain;
 import javax.jws.Oneway;
@@ -1387,5 +1388,40 @@ public class CodeGenTest extends Abstrac
         RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
         assertNotNull("@RequestWrapper is expected", reqWrapper);
     }
+    @Test
+    public void testJavaDoc() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        processor.setContext(env);
+        processor.execute();
+
+        List<String> results1 = FileUtils.readLines(new File(output.getCanonicalPath(),
+            "org/apache/cxf/w2j/hello_world_soap_http/Greeter.java"));
+
+        System.out.println(results1);
+        assertTrue(results1.contains(" * porttype documentation"));
+        assertTrue(results1.contains("     * porttype op documentation"));
+
+        List<String> results2 = FileUtils.readLines(new File(output.getCanonicalPath(),
+            "org/apache/cxf/w2j/hello_world_soap_http/SOAPServiceTest1.java"));
+
+        boolean match1 = false;
+        boolean match2 = false;
+        boolean match3 = false;
+        for (String str : results2) {
+            if (str.contains("service documentation")) {
+                match1 = true;
+            }
+            if (str.contains("port1 documentation")) {
+                match2 = true;
+            }
+            if (str.contains("port2 documentation")) {
+                match3 = true;
+            }
+        }
+        assertTrue(results2.toString(), match1);
+        assertTrue(results2.toString(), match2);
+        assertTrue(results2.toString(), match3);
+
+    }
 
 }

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world.wsdl?rev=1128043&r1=1128042&r2=1128043&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world.wsdl (original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world.wsdl Thu May 26 19:06:39 2011
@@ -167,7 +167,9 @@
         <wsdl:part name="out" element="x1:BareDocumentResponse"/>
     </wsdl:message> 
     <wsdl:portType name="Greeter">
+        <wsdl:documentation>porttype documentation</wsdl:documentation>
         <wsdl:operation name="sayHi">
+            <wsdl:documentation>porttype op documentation</wsdl:documentation>
             <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
             <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
         </wsdl:operation>
@@ -260,10 +262,13 @@
         </wsdl:port>
     </wsdl:service>
     <wsdl:service name="SOAPService_Test1">
+        <wsdl:documentation>service documentation</wsdl:documentation>
         <wsdl:port name="SoapPort_Test1" binding="tns:Greeter_SOAPBinding">
+            <wsdl:documentation>port1 documentation</wsdl:documentation>
             <soap:address location="http://localhost:9100"/>
         </wsdl:port>
         <wsdl:port name="SoapPort_Test2" binding="tns:Greeter_SOAPBinding">
+            <wsdl:documentation>port2 documentation</wsdl:documentation>
             <soap:address location="http://localhost:9101"/>
         </wsdl:port>
     </wsdl:service>