View Javadoc
1   package org.codehaus.mojo.axistools.wsdl2java;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.axis.wsdl.toJava.Emitter;
23  import org.apache.maven.artifact.Artifact;
24  import org.codehaus.mojo.axistools.axis.AbstractAxisPlugin;
25  import org.codehaus.mojo.axistools.axis.AxisPluginException;
26  import org.codehaus.mojo.axistools.axis.Mapping;
27  import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
28  import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
29  import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
30  import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
31  import org.codehaus.plexus.util.FileUtils;
32  import org.codehaus.plexus.util.IOUtil;
33  import org.codehaus.plexus.util.PathTool;
34  import org.codehaus.plexus.util.StringUtils;
35  
36  import java.io.File;
37  import java.io.FileOutputStream;
38  import java.io.IOException;
39  import java.io.InputStream;
40  import java.io.OutputStream;
41  import java.net.JarURLConnection;
42  import java.net.MalformedURLException;
43  import java.net.URL;
44  import java.net.URLConnection;
45  import java.util.ArrayList;
46  import java.util.HashMap;
47  import java.util.HashSet;
48  import java.util.Iterator;
49  import java.util.List;
50  import java.util.Set;
51  import java.util.StringTokenizer;
52  import java.util.jar.JarEntry;
53  
54  /**
55   * @author: jesse
56   * @version: $Id$
57   */
58  public class DefaultWSDL2JavaPlugin
59      extends AbstractAxisPlugin
60      implements WSDL2JavaPlugin
61  {
62      /**
63       * list of urls to process
64       *
65       * @parameter expression=""
66       */
67      private ArrayList urls;
68  
69      /**
70       * List of wsdl files from {@link #sourceDirectory} to process
71       *
72       * @parameter expression=""
73       */
74      private ArrayList wsdlFiles;
75  
76      /**
77       * list of source dependencies in the format groupId:artifactId:version:file
78       *
79       * @parameter expression=""
80       */
81      private ArrayList sourceDependencies;
82  
83      /**
84       * Cache directory for WSDLs from URLs
85       *
86       * @parameter expression="${project.build.directory}/axistools/wsdl2java/urlDownloads"
87       */
88      private File urlDownloadDirectory;
89  
90      /**
91       * Cache directory for WSDLs from sourceDependencies
92       *
93       * @parameter expression="${project.build.directory}/axistools/wsdl2java/sourceDependencies"
94       */
95      private File sourceDependencyDirectory;
96  
97      /**
98       * use the Emitter for generating the java files as opposed to the commandline wsdl2java tool
99       *
100      * @parameter expression="false"
101      */
102     private boolean useEmitter;
103 
104     /**
105      * mappings are only used when useEmitter is set to true
106      *
107      * @parameter expression=""
108      */
109     private ArrayList mappings;
110 
111     /**
112      * @parameter expression="${serverSide}"
113      */
114     private boolean serverSide;
115 
116     /**
117      * package to create the java files under
118      *
119      * @parameter expression="${packageSpace}"
120      */
121     private String packageSpace;
122 
123     /**
124      * @parameter expression="${verbose}"
125      */
126     private boolean verbose;
127 
128     /**
129      * generate the test cases
130      *
131      * @parameter expression="${testCases}"
132      */
133     private boolean testCases;
134 
135     /**
136      * Copy the generated test cases to a generated-sources test directory to
137      * be compiled and run as normal Surefire unit tests.
138      *
139      * @parameter expression="false"
140      */
141     private boolean runTestCasesAsUnitTests;
142 
143     /**
144      * @parameter expression="${allElements}"
145      */
146     private boolean allElements;
147 
148     /**
149      * @parameter expression="false"
150      */
151     private boolean debug;
152 
153     /**
154      * @parameter expression="${timeout}"
155      */
156     private Integer timeout;
157 
158     /**
159      * @parameter expression="false"
160      */
161     private boolean noImports;
162 
163     /**
164      * @parameter expression="false"
165      */
166     private boolean noWrapped;
167 
168     /**
169      * @parameter expression="true"
170      */
171     private boolean wrapArrays;
172 
173     /**
174      * @parameter expression="false"
175      */
176     private boolean skeletonDeploy;
177 
178     /**
179      * @parameter expression="${namespaceToPackage}"
180      */
181     private String namespaceToPackage;
182 
183     /**
184      * @parameter expression="${fileNamespaceToPackage}"
185      */
186     private File fileNamespaceToPackage;
187 
188     /**
189      * @parameter expression="${deployScope}"
190      */
191     private String deployScope;
192 
193     /**
194      * @parameter expression="${typeMappingVersion}"
195      */
196     private String typeMappingVersion;
197 
198     /**
199      * @parameter expression="${factory}"
200      */
201     private String factory;
202 
203     /**
204      * @parameter expression=""
205      */
206     private ArrayList nsIncludes;
207 
208     /**
209      * @parameter expression=""
210      */
211     private ArrayList nsExcludes;
212 
213     /**
214      * @parameter expression="false"
215      */
216     private boolean helperGen;
217 
218     /**
219      * @parameter expression="${username}"
220      */
221     private String username;
222 
223     /**
224      * @parameter expression="${password}"
225      */
226     private String password;
227 
228     /**
229      * @parameter expression="${implementationClassName}"
230      */
231     private String implementationClassName;
232 
233     /**
234      * load.wsdl would further subpackage into load.*
235      *
236      * @parameter expression="${subPackageByFileName}"
237      */
238     private boolean subPackageByFileName;
239 
240     /**
241      * location to place generated test source
242      *
243      * @parameter expression="${project.build.directory}/generated-test-sources/wsdl"
244      */
245     private File testSourceDirectory;
246 
247     public void execute()
248         throws AxisPluginException
249     {
250         if ( !outputDirectory.exists() )
251         {
252             outputDirectory.mkdirs();
253         }
254 
255         getLog().info( "about to add compile source root" );
256 
257         if ( project != null )
258         {
259             project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
260         }
261 
262         // Get WSDL files
263 
264         if ( urls != null )
265         {
266             for ( Iterator i = urls.iterator(); i.hasNext(); )
267             {
268                 downloadWSDLFromUrl( (String) i.next() );
269             }
270         }
271 
272         if ( sourceDependencies != null )
273         {
274             for ( Iterator i = sourceDependencies.iterator(); i.hasNext(); )
275             {
276                 extractWSDLFromSourceDependency( (String) i.next() );
277             }
278         }
279 
280         Set wsdlSet = computeStaleWSDLs();
281 
282         if ( wsdlSet.isEmpty() )
283         {
284             getLog().info( "Nothing to generate. All WSDL files are up to date." );
285         }
286         else if ( wsdlFiles == null ) 
287         {
288             for ( Iterator i = wsdlSet.iterator(); i.hasNext(); )
289             {
290                 File wsdl = (File) i.next();
291 
292                 processWsdl( wsdl );
293             }
294         }
295         else
296         {
297             // MAXISTOOLS-47: It is important to search this way to be able to
298             // respect the order of the WSDL files as specified in the POM, even
299             // though it might be a bit slower (searching all files instead of
300             // only the stale files)
301             for ( Iterator i = wsdlFiles.iterator(); i.hasNext(); )
302             {
303                 String wsdlFileName = (String) i.next();
304                 File wsdl = getFile( wsdlSet, wsdlFileName );
305 
306                 // If this file is not among the stale files, skip it 
307                 if ( wsdl == null )
308                 {
309                     getLog().info( "Skipping up to date wsdl: " + wsdlFileName + "." );
310                     continue;
311                 }
312 
313                 processWsdl( wsdl );
314             }
315         }
316 
317         if ( runTestCasesAsUnitTests )
318         {
319             migrateTestSource();
320         }
321     }
322 
323     private void processWsdl( File wsdl )
324         throws AxisPluginException
325     {
326         getLog().info( "Processing wsdl: " + wsdl.toString() );
327 
328         if ( !useEmitter )
329         {
330             WSDL2JavaWrapper wsdlWrapper = new WSDL2JavaWrapper();
331             wsdlWrapper.execute( generateWSDLArgumentList( wsdl.getAbsoluteFile() ) );
332         }
333         else
334         {
335             runEmitter( wsdl );
336         }
337 
338         try
339         {
340             FileUtils.copyFileToDirectory( wsdl, timestampDirectory );
341         }
342         catch ( IOException e )
343         {
344             throw new AxisPluginException( "Error while copying the WSDL to timestamp directory.", e );
345         }
346     }
347 
348     /**
349      * Find a file with a given name among a set of files.
350      * 
351      * @param fileSet A set of files
352      * @param fileName The name of a file
353      * @return The file if it is found, otherwise <code>null</code>
354      */
355     private File getFile( Set /*<File>*/ fileSet, String fileName )
356     {
357         for ( Iterator iterator = fileSet.iterator(); iterator.hasNext(); )
358         {
359             File file = (File) iterator.next();
360             if ( file.getName().equals( fileName ) )
361             {
362                 return file;
363             }
364         }
365         return null;
366     }
367 
368     /**
369      * Downloads a missing or stale WSDL from the given URL to the directory
370      * {@link #urlDownloadDirectory}.
371      * <ul>
372      * <li>if the syntax of a URL is invalid
373      * <li>if the URL cannot be opened to check the modification timestamp
374      * <li>if the URL cannot be downloaded
375      * </ul>
376      *
377      * @param urlStr the WSDL URL
378      */
379     private void downloadWSDLFromUrl( String urlStr )
380         throws AxisPluginException
381     {
382         URLConnection urlConnection;
383         try
384         {
385             URL url = new URL( urlStr );
386             urlConnection = url.openConnection();
387         }
388         catch ( Exception e )
389         {
390             throw new AxisPluginException( "unable to open connection for download of WSDL file from URL " + urlStr
391                 + ". Reason: " + e.getClass().getName() + ": " + e.getMessage(), e );
392         }
393 
394         File localWsdl = new File( urlDownloadDirectory, createSafeFileName( urlStr ) );
395 // Compare modification timestamp of the URL against
396 // that of the local copy.
397         if ( localWsdl.exists() && localWsdl.lastModified() == urlConnection.getLastModified() )
398         {
399             getLog().debug( "local copy of WSDL file from URL " + urlStr + " is up to date." );
400             return;
401         }
402 
403         // The local copy does not exist or it is outdated.
404         // Copy the file from the URL to disk
405 
406         if ( !urlDownloadDirectory.exists() )
407         {
408             urlDownloadDirectory.mkdirs();
409         }
410 
411         InputStream urlInput = null;
412         OutputStream localWsdlOutput = null;
413         try
414         {
415             urlInput = urlConnection.getInputStream();
416             localWsdlOutput = new FileOutputStream( localWsdl );
417 
418             IOUtil.copy( urlInput, localWsdlOutput );
419             localWsdlOutput.flush();
420 
421             getLog().info( "downloaded WSDL from URL " + urlStr + " (" + localWsdl.length() + " Bytes)." );
422 
423         }
424         catch ( Exception e )
425         {
426             throw new AxisPluginException( "unable to download WSDL file from " + urlStr + " to "
427                 + localWsdl.getAbsolutePath() + ". Reason: " + e.getClass().getName() + ": " + e.getMessage(), e );
428         }
429         finally
430         {
431             IOUtil.close( urlInput );
432             IOUtil.close( localWsdlOutput );
433         }
434 
435         localWsdl.setLastModified( urlConnection.getLastModified() );
436     }
437 
438     /**
439      * Extracts a stale or missing WSDL from the artifact referenced via the
440      * given source dependency name to the directory
441      * {@link #sourceDependencyDirectory}.
442      * <p/>
443      * <ul>
444      * <li>if the sourceDependency format is invalid
445      * <li>if the referenced artifact JAR file cannot be opened
446      * <li>if the referenced WSDL file cannot be found or retrieved from the referenced artifact
447      * </ul>
448      *
449      * @param sourceDependencyString the source dependency (in the format <code>groupId:artifactId:version:file</code>)
450      */
451     private void extractWSDLFromSourceDependency( String sourceDependencyString )
452         throws AxisPluginException
453     {
454         StringTokenizer strtok = new StringTokenizer( sourceDependencyString, ":" );
455 
456         if ( strtok.countTokens() != 4 )
457         {
458             throw new AxisPluginException( "invalid sourceDependency: " + sourceDependencyString
459                 + ". Expected format: groupId:artifactId:version:file" );
460         }
461 
462         String groupId = strtok.nextToken();
463         String artifactId = strtok.nextToken();
464         String version = strtok.nextToken();
465         String wsdlFileString = strtok.nextToken();
466 
467         JarEntry entry;
468         JarURLConnection jarConnection;
469         try
470         {
471             Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, "jar" );
472 
473             URL url = new URL( "jar:file:" + localRepository.getBasedir() + File.separator
474                 + localRepository.pathOf( artifact ) + "!" + wsdlFileString );
475 
476             jarConnection = (JarURLConnection) url.openConnection();
477 
478             entry = jarConnection.getJarEntry();
479             if ( entry == null )
480             {
481                 throw new AxisPluginException( "unable to find " + wsdlFileString
482                     + " in artifact of sourceDependency " + sourceDependencyString + "." );
483             }
484         }
485         catch ( Exception e )
486         {
487             throw new AxisPluginException( "unable to open JAR URL connection for extraction of "
488                 + "WSDL file from artifact of sourceDependency " + sourceDependencyString + ". Reason: "
489                 + e.getClass().getName() + ": " + e.getMessage(), e );
490         }
491 
492         File localWsdl = new File( sourceDependencyDirectory, createSafeFileName( sourceDependencyString ) );
493 
494 // Compare modification timestamp of the jar entry against
495 // that of the local copy
496         if ( localWsdl.exists() && entry.getTime() == localWsdl.lastModified() )
497         {
498             getLog().debug( "local copy of WSDL file from artifact of sourceDependency " + sourceDependencyString
499                 + " is up to date." );
500             return;
501         }
502 
503         // The local copy does not exist or it is outdated.
504         // Copy the file from the JAR entry to disk.
505 
506         if ( !sourceDependencyDirectory.exists() )
507         {
508             sourceDependencyDirectory.mkdirs();
509         }
510 
511         InputStream jarWsdlInput = null;
512         FileOutputStream localWsdlOutput = null;
513         try
514         {
515             jarWsdlInput = jarConnection.getInputStream();
516             localWsdlOutput = new FileOutputStream( localWsdl );
517 
518             IOUtil.copy( jarWsdlInput, localWsdlOutput );
519             localWsdlOutput.flush();
520 
521             getLog().info( "extracted WSDL from sourceDependency " + sourceDependencyString + " ("
522                 + localWsdl.length() + " Bytes)." );
523         }
524         catch ( Exception e )
525         {
526             throw new AxisPluginException( "unable to retrieve " + wsdlFileString
527                 + " from artifact of sourceDependency " + sourceDependencyString + ".", e );
528         }
529         finally
530         {
531             IOUtil.close( jarWsdlInput );
532             IOUtil.close( localWsdlOutput );
533         }
534 
535         localWsdl.setLastModified( entry.getTime() );
536     }
537 
538     /**
539      * move the generated test cases to a suitable location for being picked up by the testing phase
540      */
541     private void migrateTestSource()
542         throws AxisPluginException
543     {
544         if ( !testSourceDirectory.exists() )
545         {
546             testSourceDirectory.mkdirs();
547         }
548 
549         Set testSources = locateTestSources();
550 
551         for ( Iterator iter = testSources.iterator(); iter.hasNext(); )
552         {
553             File source = (File) iter.next();
554 
555             try
556             {
557                 FileUtils.copyFileToDirectory( source, getDestinationDirectory( source ) );
558                 FileUtils.fileDelete( source.getAbsolutePath() );
559             }
560             catch ( IOException ioe )
561             {
562                 throw new AxisPluginException( "error copying test sources", ioe );
563             }
564         }
565 
566         project.addTestCompileSourceRoot( testSourceDirectory.getPath() );
567     }
568 
569     /**
570      * Try to find out which directory the given generated test source file
571      * should be copied to. Calculate this based on the file's relative path to
572      * the output directory. If there is no package for the file, the
573      * packageSpace configuration is consulted.
574      *
575      * @param source A generated test source file
576      * @return The directory to which the generated test source file should be copied
577      */
578     private File getDestinationDirectory( File source )
579     {
580         String relativeFilePath = PathTool.getRelativeFilePath( outputDirectory.getAbsolutePath(),
581                                                                 source.getAbsolutePath() );
582         String relativePath = FileUtils.getPath( relativeFilePath );
583         if ( StringUtils.isEmpty( relativePath ) && packageSpace != null )
584         {
585             relativePath = StringUtils.replace( packageSpace, '.', File.separatorChar );
586         }
587         return new File( testSourceDirectory, relativePath );
588     }
589 
590     /**
591      * generate the parameter String[] to be passed into the main method
592      *
593      * @param wsdl path of the wsdl file to process
594      * @return argument array for the invocation of {@link org.codehaus.mojo.axistools.WSDL2JavaMojo}
595      */
596     private String[] generateWSDLArgumentList( File wsdl )
597         throws AxisPluginException
598     {
599         ArrayList argsList = new ArrayList();
600 
601         if ( debug )
602         {
603             argsList.add( "--Debug" );
604         }
605 
606         if ( verbose )
607         {
608             argsList.add( "-v" );
609         }
610 
611         argsList.add( "-o" );
612         argsList.add( outputDirectory.getAbsolutePath() );
613 
614         if ( serverSide )
615         {
616             argsList.add( "-s" );
617         }
618 
619         if ( testCases )
620         {
621             argsList.add( "-t" );
622         }
623 
624         if ( allElements )
625         {
626             argsList.add( "-a" );
627         }
628 
629         if ( noImports )
630         {
631             argsList.add( "-n" );
632         }
633 
634         if ( timeout != null )
635         {
636             argsList.add( "-O" );
637             argsList.add( timeout.toString() );
638         }
639 
640         if ( noWrapped )
641         {
642             argsList.add( "-W" );
643         }
644 
645         if ( wrapArrays )
646         {
647             argsList.add( "-w" );
648         }
649 
650         if ( skeletonDeploy )
651         {
652             argsList.add( "-S" );
653             argsList.add( "true" );
654         }
655 
656         if ( mappings != null && mappings.size() > 0 )
657         {
658             if ( packageSpace == null )
659             {
660                 Iterator iter = mappings.iterator();
661                 while ( iter.hasNext() )
662                 {
663                     Mapping mapping = (Mapping) iter.next();
664                     argsList.add( "-N" + mapping.getNamespace() + "=" + mapping.getTargetPackage() );
665                 }
666             }
667             else
668             {
669                 throw new AxisPluginException( "mappings and packageSpace can not be used together" );
670             }
671         }
672 
673         if ( fileNamespaceToPackage != null )
674         {
675             argsList.add( "-f" );
676             argsList.add( fileNamespaceToPackage.getAbsolutePath() );
677         }
678 
679         if ( deployScope != null )
680         {
681             argsList.add( "-d" );
682             argsList.add( deployScope );
683         }
684 
685         if ( typeMappingVersion != null )
686         {
687             if ( "1.1".equals( typeMappingVersion ) || "1.2".equals( typeMappingVersion ) )
688             {
689                 argsList.add( "-T" );
690                 argsList.add( typeMappingVersion );
691             }
692             else
693             {
694                 throw new AxisPluginException( "invalid typeMappingVersion (1.1 or 1.2)" );
695             }
696         }
697 
698         if ( factory != null )
699         {
700             argsList.add( "-F" );
701             argsList.add( factory );
702         }
703 
704         if ( nsIncludes != null )
705         {
706            for ( Iterator i = nsIncludes.iterator(); i.hasNext(); )
707            {
708             argsList.add( "-i" );
709             argsList.add( i.next() );
710            }
711         }
712 
713         if ( nsExcludes != null )
714         {
715            for ( Iterator i = nsExcludes.iterator(); i.hasNext(); )
716            {
717             argsList.add( "-x" );
718             argsList.add( i.next() );
719            }
720         }
721 
722         if ( helperGen )
723         {
724             argsList.add( "-H" );
725         }
726 
727         if ( username != null )
728         {
729             argsList.add( "-U" );
730             argsList.add( username );
731         }
732 
733         if ( password != null )
734         {
735             argsList.add( "-P" );
736             argsList.add( password );
737         }
738 
739         if ( implementationClassName != null )
740         {
741             argsList.add( "-c" );
742             argsList.add( implementationClassName );
743         }
744 
745         if ( packageSpace != null && !subPackageByFileName )
746         {
747             argsList.add( "-p" );
748             argsList.add( packageSpace );
749         }
750         else if ( packageSpace != null && subPackageByFileName )
751         {
752             argsList.add( "-p" );
753             argsList.add( packageSpace + "." + FileUtils.basename( wsdl.getAbsolutePath(), ".wsdl" ) );
754         }
755 
756         argsList.add( wsdl.toURI().toString() );
757 
758         getLog().debug( "argslist: " + argsList.toString() );
759 
760         return (String[]) argsList.toArray( new String[argsList.size()] );
761     }
762 
763     /**
764      * scans for the test cases that might have been generated by the call to wsdl2java
765      *
766      * @return Set of test case File objects
767      */
768     private Set locateTestSources()
769         throws AxisPluginException
770     {
771         SuffixMapping mapping = new SuffixMapping( "TestCase.java", "TestCase.class" );
772 
773         SourceInclusionScanner scanner = new StaleSourceScanner();
774 
775         scanner.addSourceMapping( mapping );
776 
777         Set testSources = new HashSet();
778 
779         try
780         {
781             testSources.addAll( scanner.getIncludedSources( outputDirectory, testSourceDirectory ) );
782         }
783         catch ( InclusionScanException e )
784         {
785             throw new AxisPluginException(
786                 "Error scanning source root: \'" + outputDirectory + "\' for stale wsdls to reprocess.", e );
787         }
788 
789         return testSources;
790     }
791 
792     private Set computeStaleWSDLs()
793         throws AxisPluginException
794     {
795         SuffixMapping mapping = new SuffixMapping( ".wsdl", ".wsdl" );
796 
797         SourceInclusionScanner scanner = new StaleSourceScanner( staleMillis );
798 
799         scanner.addSourceMapping( mapping );
800 
801         Set staleSources = new HashSet();
802 
803         try
804         {
805             if ( ( sourceDirectory != null ) && sourceDirectory.exists() )
806             {
807                 staleSources.addAll( scanner.getIncludedSources( sourceDirectory, timestampDirectory ) );
808             }
809 
810             if ( ( urlDownloadDirectory != null ) && urlDownloadDirectory.exists() )
811             {
812                 staleSources.addAll( scanner.getIncludedSources( urlDownloadDirectory, timestampDirectory ) );
813             }
814 
815             if ( ( sourceDependencyDirectory != null ) && sourceDependencyDirectory.exists() )
816             {
817                 staleSources.addAll( scanner.getIncludedSources( sourceDependencyDirectory, timestampDirectory ) );
818             }
819         }
820         catch ( InclusionScanException e )
821         {
822             throw new AxisPluginException(
823                 "Error scanning source root: \'" + sourceDirectory + "\' for stale wsdls to reprocess.", e );
824         }
825 
826         return staleSources;
827     }
828 
829     private void runEmitter( File wsdl )
830         throws AxisPluginException
831     {
832         Emitter emitter = new Emitter();
833         if ( mappings != null )
834         {
835             getLog().debug( "mappings size : " + mappings.size() );
836             HashMap mappingMap = this.getNamespaceMap( mappings );
837             getLog().debug( "mappingMap size : " + mappingMap.size() );
838             emitter.setNamespaceMap( mappingMap );
839         }
840 
841         URL wsdlUrl;
842 
843         try
844         {
845             wsdlUrl = wsdl.toURL();
846         }
847         catch ( MalformedURLException e )
848         {
849             throw new AxisPluginException( "error processing " + wsdl.getAbsolutePath(), e );
850         }
851 
852         getLog().debug( "wsdlUrl.toExternalForm() " + wsdlUrl.toExternalForm() );
853 
854 //emitter.setAllowInvalidURL(mojo.is)
855         emitter.setAllWanted( allElements );
856 // not exists in the mojo
857 //emitter.setBuildFileWanted(true);
858         emitter.setDebug( debug );
859 // not in the mojo
860 //emitter.setDefaultTypeMapping(mojo.gett)
861 //emitter.setDeploy(mojo.is)
862         if ( StringUtils.isNotEmpty( factory ) )
863         {
864             emitter.setFactory( factory );
865         }
866         emitter.setHelperWanted( helperGen );
867 
868         if ( StringUtils.isNotEmpty( implementationClassName ) )
869         {
870             emitter.setImplementationClassName( implementationClassName );
871         }
872 
873         // ?? is it correct ?
874         emitter.setImports( !noImports );
875 
876         // TODO:  is it comma separated in the mojo -> no documentation provided
877         emitter.setNamespaceExcludes( nsExcludes == null ? java.util.Collections.EMPTY_LIST : nsExcludes );
878 
879         // TODO:  is it comma separated in the mojo -> no documentation provided
880         emitter.setNamespaceIncludes( nsIncludes == null ? java.util.Collections.EMPTY_LIST : nsIncludes );
881 
882         emitter.setNowrap( noWrapped );
883 
884         if ( StringUtils.isNotEmpty( namespaceToPackage ) )
885         {
886             emitter.setNStoPkg( namespaceToPackage );
887         }
888         emitter.setOutputDir( outputDirectory.getPath() );
889         // TODO: is it the right mojo parameter certainly yes ;-)
890         if ( StringUtils.isNotEmpty( packageSpace ) )
891         {
892             emitter.setPackageName( packageSpace );
893         }
894         emitter.setPassword( password );
895 // not in the mojo properties for custom JavaGeneratorFactories
896 //emitter.setProperties(mojo.getp)
897 // not in the mojo but needed ??
898 //emitter.setQName2ClassMap();
899 //emitter.setQuiet(mojo.is)
900 //emitter.setScope(mojo.get)
901         emitter.setServerSide( serverSide );
902 // not in the mojo but needed ??
903 //emitter.setServiceDesc(mojo.gets)
904         emitter.setSkeletonWanted( skeletonDeploy );
905         emitter.setTestCaseWanted( testCases );
906 
907 // not in the mojo but needed ?
908 //emitter.setTypeCollisionProtection(mojo.is)
909         emitter.setTypeMappingVersion( typeMappingVersion );
910         emitter.setUsername( username );
911         emitter.setVerbose( verbose );
912         // not in the mojo but needed ?
913         emitter.setWrapArrays( wrapArrays );
914         try
915         {
916             emitter.run( wsdlUrl.toExternalForm() );
917         }
918         catch ( Exception e )
919         {
920             throw new AxisPluginException( "error running " + wsdlUrl.toExternalForm(), e );
921         }
922     }
923 
924     protected HashMap getNamespaceMap( List mappings )
925     {
926         HashMap namespaceMap = new HashMap( mappings.size() );
927         for ( int i = 0, size = mappings.size(); i < size; i++ )
928         {
929             Mapping mapping = (Mapping) mappings.get( i );
930             getLog().debug( "mapping " + mappings.toString() );
931             namespaceMap.put( mapping.getNamespace(), mapping.getTargetPackage() );
932         }
933         return namespaceMap;
934 
935     }
936 
937     public void setUrls( ArrayList urls )
938     {
939         this.urls = urls;
940     }
941 
942     public void setWsdlFiles( ArrayList wsdlFiles )
943     {
944         this.wsdlFiles = wsdlFiles;
945     }
946 
947     public void setSourceDependencies( ArrayList sourceDependencies )
948     {
949         this.sourceDependencies = sourceDependencies;
950     }
951 
952     public void setUrlDownloadDirectory( File urlDownloadDirectory )
953     {
954         this.urlDownloadDirectory = urlDownloadDirectory;
955     }
956 
957     public void setSourceDependencyDirectory( File sourceDependencyDirectory )
958     {
959         this.sourceDependencyDirectory = sourceDependencyDirectory;
960     }
961 
962     public void setUseEmitter( boolean useEmitter )
963     {
964         this.useEmitter = useEmitter;
965     }
966 
967     public void setMappings( ArrayList mappings )
968     {
969         this.mappings = mappings;
970     }
971 
972     public void setServerSide( boolean serverSide )
973     {
974         this.serverSide = serverSide;
975     }
976 
977     public void setPackageSpace( String packageSpace )
978     {
979         this.packageSpace = packageSpace;
980     }
981 
982     public void setVerbose( boolean verbose )
983     {
984         this.verbose = verbose;
985     }
986 
987     public void setTestCases( boolean testCases )
988     {
989         this.testCases = testCases;
990     }
991 
992     public void setRunTestCasesAsUnitTests( boolean runTestCasesAsUnitTests )
993     {
994         this.runTestCasesAsUnitTests = runTestCasesAsUnitTests;
995     }
996 
997     public void setAllElements( boolean allElements )
998     {
999         this.allElements = allElements;
1000     }
1001 
1002     public void setDebug( boolean debug )
1003     {
1004         this.debug = debug;
1005     }
1006 
1007     public void setTimeout( Integer timeout )
1008     {
1009         this.timeout = timeout;
1010     }
1011 
1012     public void setNoImports( boolean noImports )
1013     {
1014         this.noImports = noImports;
1015     }
1016 
1017     public void setNoWrapped( boolean noWrapped )
1018     {
1019         this.noWrapped = noWrapped;
1020     }
1021 
1022     public void setWrapArrays( boolean wrapArrays )
1023     {
1024         this.wrapArrays = wrapArrays;
1025     }
1026 
1027     public void setSkeletonDeploy( boolean skeletonDeploy )
1028     {
1029         this.skeletonDeploy = skeletonDeploy;
1030     }
1031 
1032     public void setNamespaceToPackage( String namespaceToPackage )
1033     {
1034         this.namespaceToPackage = namespaceToPackage;
1035     }
1036 
1037     public void setFileNamespaceToPackage( File fileNamespaceToPackage )
1038     {
1039         this.fileNamespaceToPackage = fileNamespaceToPackage;
1040     }
1041 
1042     public void setDeployScope( String deployScope )
1043     {
1044         this.deployScope = deployScope;
1045     }
1046 
1047     public void setTypeMappingVersion( String typeMappingVersion )
1048     {
1049         this.typeMappingVersion = typeMappingVersion;
1050     }
1051 
1052     public void setFactory( String factory )
1053     {
1054         this.factory = factory;
1055     }
1056 
1057     public void setNsIncludes( ArrayList nsIncludes )
1058     {
1059         this.nsIncludes = nsIncludes;
1060     }
1061 
1062     public void setNsExcludes( ArrayList nsExcludes )
1063     {
1064         this.nsExcludes = nsExcludes;
1065     }
1066 
1067     public void setHelperGen( boolean helperGen )
1068     {
1069         this.helperGen = helperGen;
1070     }
1071 
1072     public void setUsername( String username )
1073     {
1074         this.username = username;
1075     }
1076 
1077     public void setPassword( String password )
1078     {
1079         this.password = password;
1080     }
1081 
1082     public void setImplementationClassName( String implementationClassName )
1083     {
1084         this.implementationClassName = implementationClassName;
1085     }
1086 
1087     public void setSubPackageByFileName( boolean subPackageByFileName )
1088     {
1089         this.subPackageByFileName = subPackageByFileName;
1090     }
1091 
1092     public void setTestSourceDirectory( File testSourceDirectory )
1093     {
1094         this.testSourceDirectory = testSourceDirectory;
1095     }
1096 }