[ 
http://jira.codehaus.org/browse/MAXISTOOLS-14?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dennis Lundberg moved MOJO-502 to MAXISTOOLS-14:
------------------------------------------------

    Component/s:     (was: axistools)
            Key: MAXISTOOLS-14  (was: MOJO-502)
        Project: Maven 2.x Axis Tools Plugin  (was: Mojo)

> WSDL2JavaMojo namespaceToPackage isn't used correctly.  Fix supplied.
> ---------------------------------------------------------------------
>
>                 Key: MAXISTOOLS-14
>                 URL: http://jira.codehaus.org/browse/MAXISTOOLS-14
>             Project: Maven 2.x Axis Tools Plugin
>          Issue Type: Bug
>            Reporter: Mike Laurie
>            Assignee: Dan Tran
>            Priority: Minor
>
> At present, when not using the emitter, the namespaceToPackage configuration 
> element is incorrectly passed through.
> The [axis 
> documentation|http://ws.apache.org/axis/java/reference.html#WSDL2JavaReference]
>  says:
> {panel}
> -N, --NStoPkg <argument>=<value> 
> By default, package names are generated from the namespace strings in the 
> WSDL document in a magical manner (typically, if the namespace is of the form 
> "http://x.y.com"; or "urn:x.y.com" the corresponding package will be 
> "com.y.x"). If this magic is not what you want, you can provide your own 
> mapping using the --NStoPkg argument, which can be repeated as often as 
> necessary, once for each unique namespace mapping. For example, if there is a 
> namespace in the WSDL document called "urn:AddressFetcher2", and you want 
> files generated from the objects within this namespace to reside in the 
> package samples.addr, you would provide the following option to WSDL2Java:
> --NStoPkg urn:AddressFetcher2=samples.addr
> (Note that if you use the short option tag, "-N", then there must not be a 
> space between "-N" and the namespace.) 
> {panel}
> The maven-axistools-plugin is using the -N argument, and it only supplies one 
> of them. However, it doesn't conform to the last condition above.  The code 
> is as follows:
> {code:title=DefaultWSDL2JavaPlugin.java}
>         if ( namespaceToPackage != null )
>         {
>             if ( packageSpace == null )
>             {
>                 argsList.add( "-N" );
>                 argsList.add( namespaceToPackage );
>             }
>             else
>             {
>                 throw new AxisPluginException( "NStoPkg and packageSpace can 
> not be used together" );
>             }
>         }
> {code}
> I guess this issue can be overcome by supplying a fileNStoPkg value and 
> putting the mappings in the file, hence why I've logged this issue as minor.
> Anyway, I suggest that you ditch the namespaceToPackage option on the Mojo, 
> and use the mappings configuration list as used for the emitter (see also 
> MOJO-501).
> Replace the above code with:
> {code:title=DefaultWSDL2JavaPlugin.java}
>         if ( mappings != null && mappings.size() > 0 )
>         {
>             if ( packageSpace == null )
>             {
>                 Iterator iter = mappings.iterator();
>                 while(iter.hasNext()){
>                     Mapping mapping = (Mapping)iter.next();
>                       argsList.add( "-N"
>                                     + mapping.getNamespace()
>                                     +"="
>                                     + mapping.getTargetPackage());
>                 }
>             }
>             else
>             {
>                 throw new AxisPluginException( "mappings and packageSpace can 
> not be used together" );
>             }
>         }
> {code}
> My diff file:
> {noformat}
> $ svn diff
> Index: 
> src/main/java/org/codehaus/mojo/axistools/wsdl2java/DefaultWSDL2JavaPlugin.java
> ===================================================================
> --- 
> src/main/java/org/codehaus/mojo/axistools/wsdl2java/DefaultWSDL2JavaPlugin.java
>      (revision 2342)
> +++ 
> src/main/java/org/codehaus/mojo/axistools/wsdl2java/DefaultWSDL2JavaPlugin.java
>      (working copy)
> @@ -584,19 +584,30 @@
>              argsList.add( "true" );
>          }
> -        if ( namespaceToPackage != null )
> +        if ( mappings != null && mappings.size() > 0 )
>          {
>              if ( packageSpace == null )
>              {
> -                argsList.add( "-N" );
> -                argsList.add( namespaceToPackage );
> +                Iterator iter = mappings.iterator();
> +                while(iter.hasNext()){
> +                    Mapping mapping = (Mapping)iter.next();
> +                       argsList.add( "-N"
> +                                     + mapping.getNamespace().trim()
> +                                     +"="
> +                                     + mapping.getTargetPackage().trim());
> +                }
>              }
>              else
>              {
> -                throw new AxisPluginException( "NStoPkg and packageSpace can 
> not be used together" );
> +                throw new AxisPluginException( "mappings and packageSpace 
> can not be used together" );
>              }
>          }
> +        if ( namespaceToPackage != null )
> +        {
> +               throw new AxisPluginException("Use of namespaceToPackage has 
> been deprecated.  Please use the mappings configuration instead.");
> +        }
> +
>          if ( fileNamespaceToPackage != null )
>          {
>              argsList.add( "-f" );
> {noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to