cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1054745 - in /cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ systests/wsdl_maven/codegen/ tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/ ...
Date Mon, 03 Jan 2011 20:52:46 GMT
Author: dkulp
Date: Mon Jan  3 20:52:45 2011
New Revision: 1054745

URL: http://svn.apache.org/viewvc?rev=1054745&view=rev
Log:
[CXF-3129] Add @Generated annotation to generated code
Patch from Nithya Sivasubramaniam applied (with mods)

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
    cxf/trunk/systests/wsdl_maven/codegen/pom.xml
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/server.vm
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
    cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Mon Jan  3
20:52:45 2011
@@ -92,6 +92,7 @@ public final class ToolConstants {
     public static final String CFG_ALLOW_ELEMENT_REFS = "allowElementReferences";
     public static final String CFG_RESERVE_NAME = "reserveClass";
     public static final String CFG_USE_FQCN_FAULT_SERIAL_VERSION_UID = "useFQCNForFaultSerialVersionUID";
+    public static final String CFG_MARK_GENERATED = "mark-generated";
 
 
     //Internal Flag to generate

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
Mon Jan  3 20:52:45 2011
@@ -141,6 +141,11 @@ public class Option {
     Boolean useFQCNForFaultSerialVersionUID;
 
     /**
+     * Uses @Generated annotation in all generated java classes if the flag is set to true.
+     */
+    Boolean markGenerated;
+
+    /**
      * The WSDL service name to use for the generated code
      */
     String serviceName;
@@ -318,6 +323,14 @@ public class Option {
         this.useFQCNForFaultSerialVersionUID = useFQCNForFaultSerialVersionUID;
     }
 
+    public Boolean isMarkGenerated() {
+        return markGenerated;
+    }
+
+    public void setMarkGenerated(Boolean markGenerated) {
+        this.markGenerated = markGenerated;
+    }
+
     public Boolean getDefaultExcludesNamespace() {
         return defaultExcludesNamespace;
     }
@@ -386,6 +399,7 @@ public class Option {
         destination.setServiceName(getServiceName());
         destination.setValidateWsdl(isValidateWsdl());
         destination.setUseFQCNForFaultSerialVersionUID(isUseFQCNForFaultSerialVersionUID());
+        destination.setMarkGenerated(isMarkGenerated());
         destination.setAllowElementRefs(isAllowElementRefs());
         if (isSetWsdlLocation()) {
             destination.setWsdlLocation(getWsdlLocation());
@@ -406,6 +420,7 @@ public class Option {
         validateWsdl = setIfNull(validateWsdl, defaultOptions.validateWsdl);
         useFQCNForFaultSerialVersionUID = setIfNull(useFQCNForFaultSerialVersionUID,
             defaultOptions.useFQCNForFaultSerialVersionUID);
+        markGenerated = setIfNull(markGenerated, defaultOptions.markGenerated);
         autoNameResolution = setIfNull(autoNameResolution, defaultOptions.autoNameResolution);
         noAddressBinding = setIfNull(noAddressBinding, defaultOptions.noAddressBinding);
         allowElementRefs = setIfNull(allowElementRefs, defaultOptions.allowElementRefs);

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
Mon Jan  3 20:52:45 2011
@@ -151,6 +151,7 @@ public class WsdlOption extends Option {
         addIfTrue(list, isAllowElementRefs(), "-allowElementRefs");
         addIfTrue(list, isValidateWsdl(), "-validate");
         addIfTrue(list, isUseFQCNForFaultSerialVersionUID(), "-useFQCNForFaultSerialVersionUID");
+        addIfTrue(list, isMarkGenerated() != null && isMarkGenerated(), "-mark-generated");
         addIfNotNull(list, getDefaultExcludesNamespace(), "-dex");
         addIfNotNull(list, getDefaultNamespacePackageMapping(), "-dns");
         addIfNotNull(list, getServiceName(), "-sn");

Modified: cxf/trunk/systests/wsdl_maven/codegen/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/wsdl_maven/codegen/pom.xml?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/systests/wsdl_maven/codegen/pom.xml (original)
+++ cxf/trunk/systests/wsdl_maven/codegen/pom.xml Mon Jan  3 20:52:45 2011
@@ -49,6 +49,11 @@
                         <goals>
                             <goal>wsdl2java</goal>
                         </goals>
+                        <configuration>
+                            <defaultOptions>
+                                <markGenerated>true</markGenerated>
+                            </defaultOptions>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
Mon Jan  3 20:52:45 2011
@@ -25,6 +25,8 @@ import java.util.Calendar;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.xml.bind.DatatypeConverter;
+
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.tools.common.FrontEndGenerator;
@@ -101,10 +103,13 @@ public abstract class AbstractGenerator 
     }
 
     protected void setCommonAttributes() {
-        setAttributes("currentdate", Calendar.getInstance().getTime());
+        // Set generated date in ISO-8601 format, as is required for the date attribute for
@Generated
+        // annotation.
+        setAttributes("currentdate", DatatypeConverter.printDateTime(Calendar.getInstance()));
         setAttributes("version", Version.getCurrentVersion());
         setAttributes("fullversion", Version.getCompleteVersionString());
         setAttributes("name", Version.getName());
+        setAttributes("mark-generated", env.optionSet(ToolConstants.CFG_MARK_GENERATED));
     }
 
     protected void clearAttributes() {

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Mon Jan  3 20:52:45 2011
@@ -359,7 +359,17 @@ public class JAXBDataBinding implements 
                 throw new ToolException(msg, e);
             }
         }
-
+        
+        if (context.optionSet(ToolConstants.CFG_MARK_GENERATED)) {
+            // Add the @Generated annotation in the Java files generated. This is done by
passing
+            // '-mark-generated' attribute to jaxb xjc.
+            try {
+                opts.parseArgument(new String[] {"-mark-generated" }, 0);
+            } catch (BadCommandLineException e) {
+                LOG.log(Level.SEVERE, e.getMessage());
+                throw new ToolException(e);
+            }
+        }
         addSchemas(opts, schemaCompiler, schemas);
         addBindingFiles(opts, jaxbBindings, schemas);
 
@@ -378,6 +388,7 @@ public class JAXBDataBinding implements 
             schemaCompiler.setDefaultPackageName(context.getPackageName());
         }
 
+        
         rawJaxbModelGenCode = schemaCompiler.bind();
 
         addedEnumClassToCollector(schemas, allocator);

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
Mon Jan  3 20:52:45 2011
@@ -314,6 +314,13 @@ Examples:
                 <switch>useFQCNForFaultSerialVersionUID</switch>
             </option>
 
+            <option id="mark-generated" maxOccurs="1">
+                <annotation>
+                    Adds @Generated annotation in all java files that are generated.
+                </annotation>
+                <switch>mark-generated</switch>
+            </option>
+
         </optionGroup>
         <optionGroup id="common_options">
             <option id="help" maxOccurs="1">

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
Mon Jan  3 20:52:45 2011
@@ -25,6 +25,9 @@ package $intf.PackageName;
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 import javax.xml.namespace.QName;
 #if ($service.PackageName != $intf.PackageName) 
 import ${service.PackageName}.${service.Name};
@@ -39,14 +42,25 @@ import ${import};
  * Generated source version: $version
  * 
  */
-
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public final class ${clientClassName} {
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     private static final QName SERVICE_NAME = new QName("$service.Namespace", "$service.ServiceName");
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     private ${clientClassName}() {
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public static void main(String args[]) throws Exception {
         URL wsdlURL = ${service.Name}.WSDL_LOCATION;
         if (args.length > 0) { 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
Mon Jan  3 20:52:45 2011
@@ -17,6 +17,9 @@
 
 package $expClass.PackageName;
 
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 import javax.xml.ws.WebFault;
 
 
@@ -30,34 +33,61 @@ import javax.xml.ws.WebFault;
 #foreach ($field in $expClass.Fields)
 @WebFault(name = "$field.Name", targetNamespace = "$field.TargetNamespace")
 #end
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public class $expClass.Name extends Exception {
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public static final long serialVersionUID = ${suid}L;
 #foreach ($field in $expClass.Fields)
     
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     $field.Modifier $field.ClassName $paraName;
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${expClass.Name}() {
         super();
     }
     
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${expClass.Name}(String message) {
         super(message);
     }
     
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${expClass.Name}(String message, Throwable cause) {
         super(message, cause);
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${expClass.Name}(String message, $field.ClassName $paraName) {
         super(message);
         this.$paraName = $paraName;
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${expClass.Name}(String message, $field.ClassName $paraName, Throwable cause)
{
         super(message, cause);
         this.$paraName = $paraName;
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public $field.ClassName getFaultInfo() {
         return this.$paraName;
     }

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
Mon Jan  3 20:52:45 2011
@@ -23,6 +23,9 @@
 package $intf.PackageName;
 
 import java.util.logging.Logger;
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 #foreach ($import in $intf.Imports)
 import ${import};
 #end
@@ -49,14 +52,23 @@ import ${import};
 #end
                       endpointInterface = "$intf.PackageName.$intf.Name")
                       
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public class ${implName} implements $intf.Name {
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     private static final Logger LOG = Logger.getLogger(${intf.Name}Impl.class.getName());
 
 #foreach ($method in $intf.Methods)
     /* (non-Javadoc)
      * @see $intf.PackageName.$intf.Name#${method.Name}(#foreach ($parameter in $method.Parameters)$parameter.ClassName
 $parameter.Name #if ($velocityCount != $method.getParameters().size()),#end)#end*
      */
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public $method.return.ClassName ${method.Name}(#if($method.ParameterListWithoutAnnotation.size()
== 0))#end#if($method.ParameterListWithoutAnnotation.size() != 0)#foreach($param in ${method.ParameterListWithoutAnnotation})$param#end)#end#if($method.Exceptions.size()
> 0) throws #foreach($exception in $method.Exceptions)$exception.ClassName #if($velocityCount
!= $method.Exceptions.size()),#end #end #end { 
 #if ($method.Async)
        return null;

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/sei.vm
Mon Jan  3 20:52:45 2011
@@ -21,6 +21,9 @@
 #end
 package $intf.PackageName;
 
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 #foreach ($import in $intf.Imports)
 import ${import};
 #end
@@ -40,6 +43,9 @@ import ${import};
 #foreach ($annotation in $intf.Annotations)
 $annotation
 #end
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public interface $intf.Name {
 #foreach ($method in $intf.Methods)
 
@@ -51,6 +57,9 @@ public interface $intf.Name {
 #foreach ($annotation in $method.Annotations)
     $annotation
 #end
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public $method.returnValue ${method.Name}(#if($method.ParameterList.size() == 0))#end
 #if($method.ParameterList.size() != 0)
 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/server.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/server.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/server.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/server.vm
Mon Jan  3 20:52:45 2011
@@ -17,6 +17,9 @@
 
 package $intf.PackageName;
 
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 import javax.xml.ws.Endpoint;
 
 /**
@@ -26,8 +29,14 @@ import javax.xml.ws.Endpoint;
  * 
  */
  
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public class ${serverClassName}{
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     protected ${serverClassName}() throws Exception {
         System.out.println("Starting Server");
         Object implementor = new ${impl}();
@@ -35,6 +44,9 @@ public class ${serverClassName}{
         Endpoint.publish(address, implementor);
     }
     
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public static void main(String args[]) throws Exception { 
         new ${serverClassName}();
         System.out.println("Server ready..."); 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm
Mon Jan  3 20:52:45 2011
@@ -23,6 +23,9 @@ package $service.PackageName;
 
 import java.net.MalformedURLException;
 import java.net.URL;
+#if ($mark-generated == "true")
+import javax.annotation.Generated;
+#end
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebEndpoint;
 import javax.xml.ws.WebServiceClient;
@@ -52,11 +55,24 @@ import ${import};
 #foreach ($annotation in $service.Annotations)
 $annotation
 #end
+#if ($mark-generated == "true")
+@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate", comments
= "$fullversion")
+#end
 public class ${service.Name} extends ${serviceSuperclass} {
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public final static URL WSDL_LOCATION;
+
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public final static QName SERVICE = new QName("$service.Namespace", "$service.ServiceName");
 #foreach ($port in ${service.Ports})
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public final static QName $port.Name = new QName("$service.Namespace", "$port.PortName");
 #end
     static {
@@ -74,26 +90,45 @@ public class ${service.Name} extends ${s
 #end
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}(URL wsdlLocation) {
         super(wsdlLocation, SERVICE);
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}(URL wsdlLocation, QName serviceName) {
         super(wsdlLocation, serviceName);
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}() {
         super(WSDL_LOCATION, SERVICE);
     }
     
 #if ($jaxws22)     
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}(WebServiceFeature ... features) {
         super(WSDL_LOCATION, SERVICE, features);
     }
+
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}(URL wsdlLocation, WebServiceFeature ... features) {
         super(wsdlLocation, SERVICE, features);
     }
 
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${service.Name}(URL wsdlLocation, QName serviceName, WebServiceFeature ... features)
{
         super(wsdlLocation, serviceName, features);
     }
@@ -106,6 +141,9 @@ public class ${service.Name} extends ${s
      *     returns ${port.InterfaceClass}
      */
     @WebEndpoint(name = "${port.PortName}")
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${port.InterfaceClass} get${port.Name}() {
         return super.getPort($port.Name, ${port.InterfaceClass}.class);
     }
@@ -118,6 +156,9 @@ public class ${service.Name} extends ${s
      *     returns ${port.InterfaceClass}
      */
     @WebEndpoint(name = "${port.PortName}")
+#if ($mark-generated == "true")
+    @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
+#end
     public ${port.InterfaceClass} get${port.Name}(WebServiceFeature... features) {
         return super.getPort($port.Name, ${port.InterfaceClass}.class, features);
     }

Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java?rev=1054745&r1=1054744&r2=1054745&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
(original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
Mon Jan  3 20:52:45 2011
@@ -19,7 +19,9 @@
 package org.apache.cxf.tools.wsdlto.jaxws;
 
 import java.io.File;
+import java.io.FileInputStream;
 
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.wsdlto.AbstractCodeGenTest;
 import org.junit.Test;
@@ -115,4 +117,48 @@ public class CodeGenOptionTest extends A
         processor.setContext(env);
         processor.execute();
     }
+
+    /**
+     * Tests that, when 'mark-generated' option is set, @Generated annotations are inserted
in all generated
+     * java classes.
+     */
+    @Test
+    public void testMarkGeneratedOption() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_MARK_GENERATED, "true");
+        env.put(ToolConstants.CFG_COMPILE, null);
+        env.put(ToolConstants.CFG_CLASSDIR, null);
+        processor.setContext(env);
+        processor.execute();
+
+        File dir = new File(output, "org");
+        assertTrue("org directory is not found", dir.exists());
+        dir = new File(dir, "apache");
+        assertTrue("apache directory is not found", dir.exists());
+        dir = new File(dir, "cxf");
+        assertTrue("cxf directory is not found", dir.exists());
+        dir = new File(dir, "w2j");
+        assertTrue("w2j directory is not found", dir.exists());
+        dir = new File(dir, "hello_world_soap_http");
+        assertTrue("hello_world_soap_http directory is not found", dir.exists());
+        File types = new File(dir, "types");
+        assertTrue("types directory is not found", dir.exists());
+
+        String str = IOUtils.readStringFromStream(new FileInputStream(new File(dir, "Greeter.java")));
+        assertEquals(7, countGeneratedAnnotations(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHi.java")));
+        assertEquals(1, countGeneratedAnnotations(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHiResponse.java")));
+        assertEquals(4, countGeneratedAnnotations(str));
+    }
+
+    private int countGeneratedAnnotations(String str) {
+        int count = 0;
+        int idx = str.indexOf("@Generated");
+        while (idx != -1) {
+            count++;
+            idx = str.indexOf("@Generated", idx + 1);
+        }
+        return count;
+    }
 }



Mime
View raw message