Author: veithen
Date: Wed Feb 22 20:08:57 2012
New Revision: 1292487

URL: http://svn.apache.org/viewvc?rev=1292487&view=rev
Log:
Enhanced maven-java2wsdl-plugin so that one can generate and compile the helper 
classes in the same project where the service is compiled.

Added:
    
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/AbstractGenerateWsdlMojo.java
      - copied, changed from r1291010, 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
    
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/DeployMojo.java
      - copied, changed from r1291010, 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
Modified:
    axis/axis1/java/trunk/integration/pom.xml
    axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/pom.xml
    
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java

Modified: axis/axis1/java/trunk/integration/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/integration/pom.xml?rev=1292487&r1=1292486&r2=1292487&view=diff
==============================================================================
--- axis/axis1/java/trunk/integration/pom.xml (original)
+++ axis/axis1/java/trunk/integration/pom.xml Wed Feb 22 20:08:57 2012
@@ -62,6 +62,7 @@
                         <goals>
                             <goal>generate-wsdl</goal>
                         </goals>
+                        <phase>process-classes</phase>
                         <configuration>
                             
<output>${project.build.directory}/work/test/wsdl/anytype/AnyService.wsdl</output>
                             <className>test.wsdl.anytype.AnyService</className>
@@ -78,7 +79,7 @@
                     <execution>
                         <id>arrays3</id>
                         <goals>
-                            <goal>generate-wsdl</goal>
+                            <goal>deploy</goal>
                         </goals>
                         <configuration>
                             
<output>${project.build.directory}/work/test/wsdl/arrays3/generated/arrays3.wsdl</output>
@@ -87,7 +88,6 @@
                             
<location>http://localhost:8080/axis/services/arrays3</location>
                             <style>WRAPPED</style>
                             <use>literal</use>
-                            <deploy>true</deploy>
                             <mappings>
                                 <mapping>
                                     <package>test.wsdl.arrays3</package>
@@ -983,6 +983,13 @@
                                         <include>**/deploy.wsdd</include>
                                     </includes>
                                 </wsdd>
+                                <!-- TODO: we need to fix the deploy goal (and 
also wsdl2java) so that we can specify the output location for the WSDD files 
-->
+                                <wsdd>
+                                    
<directory>${project.build.directory}/generated-sources/deploy</directory>
+                                    <includes>
+                                        <include>**/deploy.wsdd</include>
+                                    </includes>
+                                </wsdd>
                             </wsdds>
                             <jwsDirs>
                                 <jwsDir>../axis-war/src/main/webapp</jwsDir>

Modified: axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/pom.xml?rev=1292487&r1=1292486&r2=1292487&view=diff
==============================================================================
--- axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/pom.xml (original)
+++ axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/pom.xml Wed Feb 22 
20:08:57 2012
@@ -53,6 +53,16 @@
             <groupId>com.github.veithen.ulog</groupId>
             <artifactId>ulog</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-compiler-manager</artifactId>
+            <version>1.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-compiler-javac</artifactId>
+            <version>1.8.1</version>
+        </dependency>
     </dependencies>
     <reporting>
         <plugins>

Copied: 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/AbstractGenerateWsdlMojo.java
 (from r1291010, 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java)
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/AbstractGenerateWsdlMojo.java?p2=axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/AbstractGenerateWsdlMojo.java&p1=axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java&r1=1291010&r2=1292487&rev=1292487&view=diff
==============================================================================
--- 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
 (original)
+++ 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/AbstractGenerateWsdlMojo.java
 Wed Feb 22 20:08:57 2012
@@ -22,9 +22,7 @@ import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.axis.maven.shared.nsmap.Mapping;
 import org.apache.axis.maven.shared.nsmap.MappingUtil;
@@ -38,14 +36,7 @@ import org.apache.maven.project.MavenPro
 
 import com.github.veithen.ulog.PlexusLoggerInjector;
 
-/**
- * 
- * 
- * @goal generate-wsdl
- * @phase process-classes
- * @requiresDependencyResolution compile
- */
-public class GenerateWsdlMojo extends AbstractMojo {
+public abstract class AbstractGenerateWsdlMojo extends AbstractMojo {
     /**
      * @component
      */
@@ -121,14 +112,11 @@ public class GenerateWsdlMojo extends Ab
      */
     private File output;
     
-    /**
-     * Sets the deploy flag
-     * 
-     * @parameter default-value="false"
-     */
-    private boolean deploy;
-    
-    public void execute() throws MojoExecutionException, MojoFailureException {
+    protected MavenProject getProject() {
+        return project;
+    }
+
+    public final void execute() throws MojoExecutionException, 
MojoFailureException {
         List classpath;
         try {
             classpath = project.getCompileClasspathElements();
@@ -166,68 +154,15 @@ public class GenerateWsdlMojo extends Ab
             output.getParentFile().mkdirs();
             try {
                 emitter.emit(output.getAbsolutePath(), Emitter.MODE_ALL);
-                if (deploy) {
-                    generateServerSide(emitter, /*(outputImpl != null) ? 
outputImpl :*/ output.getAbsolutePath());
-                }
             } catch (Exception ex) {
                 throw new MojoFailureException("java2wsdl failed", ex);
             }
+            postProcess(emitter, output);
         } finally {
             // TODO: apparently this is a no-op
             ClassUtils.setDefaultClassLoader(null);
         }
     }
 
-    // Copy & paste from Java2WsdlAntTask
-    /**
-     * Generate the server side artifacts from the generated WSDL
-     * 
-     * @param j2w the Java2WSDL emitter
-     * @param wsdlFileName the generated WSDL file
-     * @throws Exception
-     */
-    protected void generateServerSide(Emitter j2w, String wsdlFileName) throws 
Exception {
-        org.apache.axis.wsdl.toJava.Emitter w2j = new 
org.apache.axis.wsdl.toJava.Emitter();
-        File wsdlFile = new File(wsdlFileName);
-        w2j.setServiceDesc(j2w.getServiceDesc());
-        w2j.setQName2ClassMap(j2w.getQName2ClassMap());
-        w2j.setOutputDir(wsdlFile.getParent());
-        w2j.setServerSide(true);   
-        w2j.setDeploy(true);
-        w2j.setHelperWanted(true);
-
-        // setup namespace-to-package mapping
-        String ns = j2w.getIntfNamespace();
-        String clsName = j2w.getCls().getName();
-        int idx = clsName.lastIndexOf(".");
-        String pkg = null;
-        if (idx > 0) {
-            pkg = clsName.substring(0, idx);            
-            w2j.getNamespaceMap().put(ns, pkg);
-        }
-        
-        Map nsmap = j2w.getNamespaceMap();
-        if (nsmap != null) {
-            for (Iterator i = nsmap.keySet().iterator(); i.hasNext(); ) {
-                pkg = (String) i.next();
-                ns = (String) nsmap.get(pkg);
-                w2j.getNamespaceMap().put(ns, pkg);
-            }
-        }
-        
-        // set 'deploy' mode
-        w2j.setDeploy(true);
-        
-        if (j2w.getImplCls() != null) {
-            w2j.setImplementationClassName(j2w.getImplCls().getName());
-        } else {
-            if (!j2w.getCls().isInterface()) {
-                w2j.setImplementationClassName(j2w.getCls().getName());
-            } else {
-                throw new Exception("implementation class is not specified.");
-            }
-        }
-        
-        w2j.run(wsdlFileName);
-    }
+    protected abstract void postProcess(Emitter emitter, File wsdlFile) throws 
MojoExecutionException, MojoFailureException;
 }

Copied: 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/DeployMojo.java
 (from r1291010, 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java)
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/DeployMojo.java?p2=axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/DeployMojo.java&p1=axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java&r1=1291010&r2=1292487&rev=1292487&view=diff
==============================================================================
--- 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
 (original)
+++ 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/DeployMojo.java
 Wed Feb 22 20:08:57 2012
@@ -19,179 +19,56 @@
 package org.apache.axis.maven.java2wsdl;
 
 import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
+import java.util.Collections;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.axis.maven.shared.nsmap.Mapping;
-import org.apache.axis.maven.shared.nsmap.MappingUtil;
-import org.apache.axis.utils.ClassUtils;
 import org.apache.axis.wsdl.fromJava.Emitter;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-import com.github.veithen.ulog.PlexusLoggerInjector;
+import org.codehaus.plexus.compiler.Compiler;
+import org.codehaus.plexus.compiler.CompilerConfiguration;
+import org.codehaus.plexus.compiler.CompilerException;
+import org.codehaus.plexus.compiler.manager.CompilerManager;
+import org.codehaus.plexus.compiler.manager.NoSuchCompilerException;
 
 /**
+ * Generate deployment artifacts (WSDD files and helper classes) for a code 
first Web service. The
+ * goal will also compile the generated classes so that it can be used on a 
service that is built in
+ * the same project.
  * 
- * 
- * @goal generate-wsdl
+ * @goal deploy
  * @phase process-classes
  * @requiresDependencyResolution compile
  */
-public class GenerateWsdlMojo extends AbstractMojo {
+public class DeployMojo extends AbstractGenerateWsdlMojo {
     /**
      * @component
      */
-    // This is necessary to set up logging such that all messages logged by 
the Axis
-    // libraries through commons logging are redirected to Plexus logs.
-    PlexusLoggerInjector loggerInjector;
+    private CompilerManager compilerManager;
     
     /**
-     * The maven project.
-     *
-     * @parameter expression="${project}"
+     * @parameter expression="${project.build.outputDirectory}"
      * @required
      * @readonly
      */
-    private MavenProject project;
-
-    /**
-     * The name of the class to generate a WSDL for. The class must be on the 
classpath.
-     * 
-     * @parameter
-     * @required
-     */
-    private String className;
-
-    /**
-     * The target namespace for the interface.
-     * 
-     * @parameter
-     * @required
-     */
-    private String namespace;
+    private File outputDirectory;
     
     /**
-     * Mappings of packages to namespaces.
+     * The directory where the source code of the generated Java artifacts 
(helper classes) is
+     * placed.
      * 
-     * @parameter
-     */
-    private Mapping[] mappings;
-    
-    /**
-     * The style of the WSDL document: RPC, DOCUMENT or WRAPPED.
-     * If RPC, a rpc/encoded wsdl is generated. If DOCUMENT, a
-     * document/literal wsdl is generated. If WRAPPED, a
-     * document/literal wsdl is generated using the wrapped approach.
-     *
-     * @parameter
-     */
-    private String style;
-
-    /**
-     * Set the use option
-     * 
-     * @parameter
-     */
-    private String use;
-    
-    /**
-     * The url of the location of the service. The name after the last slash or
-     * backslash is the name of the service port (unless overridden by the -s
-     * option). The service port address location attribute is assigned the
-     * specified value.
-     * 
-     * @parameter
+     * @parameter 
default-value="${project.build.directory}/generated-sources/deploy"
      * @required
      */
-    private String location;
+    private File sourceOutputDirectory;
     
-    /**
-     * The name of the output WSDL file.
-     * 
-     * @parameter
-     * @required
-     */
-    private File output;
-    
-    /**
-     * Sets the deploy flag
-     * 
-     * @parameter default-value="false"
-     */
-    private boolean deploy;
-    
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        List classpath;
-        try {
-            classpath = project.getCompileClasspathElements();
-        } catch (DependencyResolutionRequiredException ex) {
-            throw new MojoExecutionException("Unexpected exception", ex);
-        }
-        URL[] urls = new URL[classpath.size()];
-        for (int i=0; i<classpath.size(); i++) {
-            try {
-                urls[i] = new File((String)classpath.get(i)).toURL();
-            } catch (MalformedURLException ex) {
-                throw new MojoExecutionException("Unexpected exception", ex);
-            }
-        }
-        // TODO: this will likely make the plugin non thread safe
-        ClassUtils.setDefaultClassLoader(new URLClassLoader(urls));
-        try {
-            Emitter emitter = new Emitter();
-            if (mappings != null && mappings.length > 0) {
-                
emitter.setNamespaceMap(MappingUtil.getPackageToNamespaceMap(mappings));
-            }
-            try {
-                emitter.setCls(className);
-            } catch (ClassNotFoundException ex) {
-                throw new MojoFailureException("Class " + className + " not 
found");
-            }
-            if (style != null) {
-                emitter.setStyle(style);
-            }
-            if (use != null) {
-                emitter.setUse(use);
-            }
-            emitter.setIntfNamespace(namespace);
-            emitter.setLocationUrl(location);
-            output.getParentFile().mkdirs();
-            try {
-                emitter.emit(output.getAbsolutePath(), Emitter.MODE_ALL);
-                if (deploy) {
-                    generateServerSide(emitter, /*(outputImpl != null) ? 
outputImpl :*/ output.getAbsolutePath());
-                }
-            } catch (Exception ex) {
-                throw new MojoFailureException("java2wsdl failed", ex);
-            }
-        } finally {
-            // TODO: apparently this is a no-op
-            ClassUtils.setDefaultClassLoader(null);
-        }
-    }
-
-    // Copy & paste from Java2WsdlAntTask
-    /**
-     * Generate the server side artifacts from the generated WSDL
-     * 
-     * @param j2w the Java2WSDL emitter
-     * @param wsdlFileName the generated WSDL file
-     * @throws Exception
-     */
-    protected void generateServerSide(Emitter j2w, String wsdlFileName) throws 
Exception {
+    protected void postProcess(Emitter j2w, File wsdlFile) throws 
MojoExecutionException, MojoFailureException {
+        // Generate the server side artifacts from the generated WSDL
         org.apache.axis.wsdl.toJava.Emitter w2j = new 
org.apache.axis.wsdl.toJava.Emitter();
-        File wsdlFile = new File(wsdlFileName);
         w2j.setServiceDesc(j2w.getServiceDesc());
         w2j.setQName2ClassMap(j2w.getQName2ClassMap());
-        w2j.setOutputDir(wsdlFile.getParent());
+        w2j.setOutputDir(sourceOutputDirectory.getAbsolutePath());
         w2j.setServerSide(true);   
         w2j.setDeploy(true);
         w2j.setHelperWanted(true);
@@ -224,10 +101,37 @@ public class GenerateWsdlMojo extends Ab
             if (!j2w.getCls().isInterface()) {
                 w2j.setImplementationClassName(j2w.getCls().getName());
             } else {
-                throw new Exception("implementation class is not specified.");
+                throw new MojoFailureException("implementation class is not 
specified.");
             }
         }
         
-        w2j.run(wsdlFileName);
+        try {
+            w2j.run(wsdlFile.getAbsolutePath());
+        } catch (Exception ex) {
+            throw new MojoFailureException("Failed to generate deployment 
code", ex);
+        }
+        
+        // We add the directory with the generated sources to the compile 
source roots even
+        // if we compile the code ourselves. That is important when using 
eclipse:eclipse.
+        getProject().addCompileSourceRoot(sourceOutputDirectory.getPath());
+        
+        CompilerConfiguration compilerConfiguration = new 
CompilerConfiguration();
+        
compilerConfiguration.setOutputLocation(outputDirectory.getAbsolutePath());
+        
compilerConfiguration.setSourceLocations(Collections.singletonList(sourceOutputDirectory.getAbsolutePath()));
+        compilerConfiguration.setSourceVersion("1.4");
+        compilerConfiguration.setTargetVersion("1.4");
+        
+        Compiler compiler;
+        try {
+            compiler = compilerManager.getCompiler("javac");
+        } catch (NoSuchCompilerException ex) {
+            throw new MojoExecutionException("No such compiler '" + 
ex.getCompilerId() + "'.");
+        }
+        
+        try {
+            compiler.compile(compilerConfiguration);
+        } catch (CompilerException ex) {
+            throw new MojoExecutionException("Compilation failed.", ex);
+        }
     }
 }

Modified: 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java?rev=1292487&r1=1292486&r2=1292487&view=diff
==============================================================================
--- 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
 (original)
+++ 
axis/axis1/java/trunk/maven/maven-java2wsdl-plugin/src/main/java/org/apache/axis/maven/java2wsdl/GenerateWsdlMojo.java
 Wed Feb 22 20:08:57 2012
@@ -19,215 +19,18 @@
 package org.apache.axis.maven.java2wsdl;
 
 import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 
-import org.apache.axis.maven.shared.nsmap.Mapping;
-import org.apache.axis.maven.shared.nsmap.MappingUtil;
-import org.apache.axis.utils.ClassUtils;
 import org.apache.axis.wsdl.fromJava.Emitter;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-import com.github.veithen.ulog.PlexusLoggerInjector;
 
 /**
  * 
  * 
  * @goal generate-wsdl
- * @phase process-classes
  * @requiresDependencyResolution compile
  */
-public class GenerateWsdlMojo extends AbstractMojo {
-    /**
-     * @component
-     */
-    // This is necessary to set up logging such that all messages logged by 
the Axis
-    // libraries through commons logging are redirected to Plexus logs.
-    PlexusLoggerInjector loggerInjector;
-    
-    /**
-     * The maven project.
-     *
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
-    private MavenProject project;
-
-    /**
-     * The name of the class to generate a WSDL for. The class must be on the 
classpath.
-     * 
-     * @parameter
-     * @required
-     */
-    private String className;
-
-    /**
-     * The target namespace for the interface.
-     * 
-     * @parameter
-     * @required
-     */
-    private String namespace;
-    
-    /**
-     * Mappings of packages to namespaces.
-     * 
-     * @parameter
-     */
-    private Mapping[] mappings;
-    
-    /**
-     * The style of the WSDL document: RPC, DOCUMENT or WRAPPED.
-     * If RPC, a rpc/encoded wsdl is generated. If DOCUMENT, a
-     * document/literal wsdl is generated. If WRAPPED, a
-     * document/literal wsdl is generated using the wrapped approach.
-     *
-     * @parameter
-     */
-    private String style;
-
-    /**
-     * Set the use option
-     * 
-     * @parameter
-     */
-    private String use;
-    
-    /**
-     * The url of the location of the service. The name after the last slash or
-     * backslash is the name of the service port (unless overridden by the -s
-     * option). The service port address location attribute is assigned the
-     * specified value.
-     * 
-     * @parameter
-     * @required
-     */
-    private String location;
-    
-    /**
-     * The name of the output WSDL file.
-     * 
-     * @parameter
-     * @required
-     */
-    private File output;
-    
-    /**
-     * Sets the deploy flag
-     * 
-     * @parameter default-value="false"
-     */
-    private boolean deploy;
-    
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        List classpath;
-        try {
-            classpath = project.getCompileClasspathElements();
-        } catch (DependencyResolutionRequiredException ex) {
-            throw new MojoExecutionException("Unexpected exception", ex);
-        }
-        URL[] urls = new URL[classpath.size()];
-        for (int i=0; i<classpath.size(); i++) {
-            try {
-                urls[i] = new File((String)classpath.get(i)).toURL();
-            } catch (MalformedURLException ex) {
-                throw new MojoExecutionException("Unexpected exception", ex);
-            }
-        }
-        // TODO: this will likely make the plugin non thread safe
-        ClassUtils.setDefaultClassLoader(new URLClassLoader(urls));
-        try {
-            Emitter emitter = new Emitter();
-            if (mappings != null && mappings.length > 0) {
-                
emitter.setNamespaceMap(MappingUtil.getPackageToNamespaceMap(mappings));
-            }
-            try {
-                emitter.setCls(className);
-            } catch (ClassNotFoundException ex) {
-                throw new MojoFailureException("Class " + className + " not 
found");
-            }
-            if (style != null) {
-                emitter.setStyle(style);
-            }
-            if (use != null) {
-                emitter.setUse(use);
-            }
-            emitter.setIntfNamespace(namespace);
-            emitter.setLocationUrl(location);
-            output.getParentFile().mkdirs();
-            try {
-                emitter.emit(output.getAbsolutePath(), Emitter.MODE_ALL);
-                if (deploy) {
-                    generateServerSide(emitter, /*(outputImpl != null) ? 
outputImpl :*/ output.getAbsolutePath());
-                }
-            } catch (Exception ex) {
-                throw new MojoFailureException("java2wsdl failed", ex);
-            }
-        } finally {
-            // TODO: apparently this is a no-op
-            ClassUtils.setDefaultClassLoader(null);
-        }
-    }
-
-    // Copy & paste from Java2WsdlAntTask
-    /**
-     * Generate the server side artifacts from the generated WSDL
-     * 
-     * @param j2w the Java2WSDL emitter
-     * @param wsdlFileName the generated WSDL file
-     * @throws Exception
-     */
-    protected void generateServerSide(Emitter j2w, String wsdlFileName) throws 
Exception {
-        org.apache.axis.wsdl.toJava.Emitter w2j = new 
org.apache.axis.wsdl.toJava.Emitter();
-        File wsdlFile = new File(wsdlFileName);
-        w2j.setServiceDesc(j2w.getServiceDesc());
-        w2j.setQName2ClassMap(j2w.getQName2ClassMap());
-        w2j.setOutputDir(wsdlFile.getParent());
-        w2j.setServerSide(true);   
-        w2j.setDeploy(true);
-        w2j.setHelperWanted(true);
-
-        // setup namespace-to-package mapping
-        String ns = j2w.getIntfNamespace();
-        String clsName = j2w.getCls().getName();
-        int idx = clsName.lastIndexOf(".");
-        String pkg = null;
-        if (idx > 0) {
-            pkg = clsName.substring(0, idx);            
-            w2j.getNamespaceMap().put(ns, pkg);
-        }
-        
-        Map nsmap = j2w.getNamespaceMap();
-        if (nsmap != null) {
-            for (Iterator i = nsmap.keySet().iterator(); i.hasNext(); ) {
-                pkg = (String) i.next();
-                ns = (String) nsmap.get(pkg);
-                w2j.getNamespaceMap().put(ns, pkg);
-            }
-        }
-        
-        // set 'deploy' mode
-        w2j.setDeploy(true);
-        
-        if (j2w.getImplCls() != null) {
-            w2j.setImplementationClassName(j2w.getImplCls().getName());
-        } else {
-            if (!j2w.getCls().isInterface()) {
-                w2j.setImplementationClassName(j2w.getCls().getName());
-            } else {
-                throw new Exception("implementation class is not specified.");
-            }
-        }
-        
-        w2j.run(wsdlFileName);
+public class GenerateWsdlMojo extends AbstractGenerateWsdlMojo {
+    protected void postProcess(Emitter emitter, File wsdlFile) throws 
MojoExecutionException, MojoFailureException {
     }
 }


Reply via email to