You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/05/23 19:30:29 UTC

svn commit: r1126608 - in /cxf/trunk: maven-plugins/ maven-plugins/wadl2java-plugin/ maven-plugins/wadl2java-plugin/src/ maven-plugins/wadl2java-plugin/src/main/ maven-plugins/wadl2java-plugin/src/main/java/ maven-plugins/wadl2java-plugin/src/main/java...

Author: sergeyb
Date: Mon May 23 17:30:28 2011
New Revision: 1126608

URL: http://svn.apache.org/viewvc?rev=1126608&view=rev
Log:
[CXF-3538] Prototyping wadl2java maven plugin

Added:
    cxf/trunk/maven-plugins/wadl2java-plugin/
    cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java   (with props)
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java   (with props)
Modified:
    cxf/trunk/maven-plugins/pom.xml
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
    cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java

Modified: cxf/trunk/maven-plugins/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/pom.xml?rev=1126608&r1=1126607&r2=1126608&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/pom.xml (original)
+++ cxf/trunk/maven-plugins/pom.xml Mon May 23 17:30:28 2011
@@ -35,6 +35,7 @@
         <module>codegen-plugin</module>
         <module>java2ws-plugin</module>
         <module>wsdl-validator-plugin</module>
+        <module>wadl2java-plugin</module> 
         <module>corba</module>
         <module>archetypes</module>
     </modules>

Added: cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml Mon May 23 17:30:28 2011
@@ -0,0 +1,141 @@
+<?xml version="1.0"?>
+<!--
+  licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-wadl2java-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <version>2.4.1-SNAPSHOT</version>
+    <name>Apache CXF WADL2Java Code Generation Maven2 Plugin</name>
+    <url>http://cxf.apache.org</url>
+
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>2.4.1-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-artifact-resolver</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+            <version>2.0.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-archiver</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wadlto-jaxrs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-common-utilities</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ant</groupId>
+            <artifactId>ant</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ant</groupId>
+            <artifactId>ant-nodeps</artifactId>
+        </dependency>
+    </dependencies>
+    
+
+    <profiles>
+        <profile>
+            <id>ibmjdk</id>
+            <activation>
+                <property>
+                    <name>java.vendor</name>
+                    <value>IBM Corporation</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>xerces</groupId>
+                    <artifactId>xercesImpl</artifactId>
+                    <version>2.8.1</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+</project>

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java Mon May 23 17:30:28 2011
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.common;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Manages switching to the classloader needed for creating the java sources and restoring the old classloader
+ * when finished
+ */
+
+// TODO: Move to the common plugin module
+public class ClassLoaderSwitcher {
+
+    private Log log;
+    private String origClassPath;
+    private Map<Object, Object> origProps;
+    private ClassLoader origContextClassloader;
+
+    public ClassLoaderSwitcher(Log log) {
+        this.log = log;
+    }
+
+    /**
+     * Create and set the classloader that is needed for creating the java sources from wsdl
+     * 
+     * @param project
+     * @param useCompileClasspath
+     * @param classesDir
+     */
+    public Set<URI> switchClassLoader(MavenProject project,
+                                         boolean useCompileClasspath,
+                                         File classesDir) {
+        List<URL> urlList = new ArrayList<URL>();
+        StringBuilder buf = new StringBuilder();
+        Set<URI> ret = new LinkedHashSet<URI>();
+        
+        try {
+            urlList.add(classesDir.toURI().toURL());
+            if (!useCompileClasspath) {
+                urlList.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+            }
+        } catch (MalformedURLException e) {
+            // ignore
+        }
+
+        buf.append(classesDir.getAbsolutePath());
+        ret.add(classesDir.toURI());
+        buf.append(File.pathSeparatorChar);
+        if (!useCompileClasspath) {
+            buf.append(project.getBuild().getOutputDirectory());
+            ret.add(new File(project.getBuild().getOutputDirectory()).toURI());
+            buf.append(File.pathSeparatorChar);
+        }
+        List<?> artifacts = useCompileClasspath ? project.getCompileArtifacts() : project.getTestArtifacts();
+        for (Artifact a : CastUtils.cast(artifacts, Artifact.class)) {
+            try {
+                if (a.getFile() != null && a.getFile().exists()) {
+                    urlList.add(a.getFile().toURI().toURL());
+                    buf.append(a.getFile().getAbsolutePath());
+                    ret.add(a.getFile().toURI());
+                    buf.append(File.pathSeparatorChar);
+                    // System.out.println("     " +
+                    // a.getFile().getAbsolutePath());
+                }
+            } catch (MalformedURLException e) {
+                // ignore
+            }
+        }
+
+        origContextClassloader = Thread.currentThread().getContextClassLoader();
+        URLClassLoader loader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]),
+                                                   origContextClassloader);
+        String newCp = buf.toString();
+
+        log.debug("Classpath: " + urlList.toString());
+
+        origProps = new HashMap<Object, Object>(System.getProperties());
+
+        origClassPath = System.getProperty("java.class.path");
+
+        Thread.currentThread().setContextClassLoader(loader);
+        System.setProperty("java.class.path", newCp);
+        return ret;
+    }
+
+    /**
+     * Restore the old classloader
+     */
+    public void restoreClassLoader() {
+        Thread.currentThread().setContextClassLoader(origContextClassloader);
+        System.setProperty("java.class.path", origClassPath);
+
+        Map<Object, Object> newProps = new HashMap<Object, Object>(System.getProperties());
+        for (Object o : newProps.keySet()) {
+            if (!origProps.containsKey(o)) {
+                System.clearProperty(o.toString());
+            }
+        }
+        System.getProperties().putAll(origProps);
+        origContextClassloader = null; // don't hold a reference.
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java Mon May 23 17:30:28 2011
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.common;
+
+/**
+ * Represents a document file (wsdl, wadl) that is stored in a maven repository
+ */
+//TODO: Move to the common plugin module
+public class DocumentArtifact {
+    private String groupId;
+    private String artifactId;
+    private String version;
+    private String type;
+    
+    public DocumentArtifact() {
+        type = "wadl";
+    }
+        
+    public String getGroupId() {
+        return groupId;
+    }
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+    public String getArtifactId() {
+        return artifactId;
+    }
+    public void setArtifactId(String artifactId) {
+        this.artifactId = artifactId;
+    }
+    public String getVersion() {
+        return version;
+    }
+    public void setVersion(String version) {
+        this.version = version;
+    }
+    public String getType() {
+        return type;
+    }
+    public void setType(String type) {
+        this.type = type;
+    }
+    
+    public boolean doesMatch(DocumentArtifact artifact) {
+        return type.equals(artifact.getType()) && groupId.equals(artifact.getGroupId())
+              && artifactId.equals(artifact.getArtifactId()) 
+              && (version == null || version.equals(artifact.getVersion()));
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/DocumentArtifact.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java Mon May 23 17:30:28 2011
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.common;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.wadlto.WADLToJava;
+
+//TODO: Move to the common plugin module
+public final class ForkOnceCodeGenerator {
+    private ForkOnceCodeGenerator() {
+        //utility
+    }
+    public static void main(String args[]) throws Exception {
+        File file = new File(args[0]);
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+        String line = reader.readLine();
+        while (line != null) {
+            int i = Integer.parseInt(line);
+            if (i == -1) {
+                return;
+            }
+            String wargs[] = new String[i];
+            for (int x = 0; x < i; x++) {
+                wargs[x] = reader.readLine();
+            }
+            
+            new WADLToJava(wargs).run(new ToolContext());
+            
+            line = reader.readLine();
+        }
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ForkOnceCodeGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java Mon May 23 17:30:28 2011
@@ -0,0 +1,652 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wadlto;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.maven_plugin.common.DocumentArtifact;
+import org.apache.cxf.maven_plugin.common.ForkOnceCodeGenerator;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.wadlto.WADLToJava;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectUtils;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.Manifest;
+import org.codehaus.plexus.archiver.jar.Manifest.Attribute;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
+
+    /**
+     * @parameter expression="${cxf.testSourceRoot}"
+     */
+    File testSourceRoot;
+
+    /**
+     * Path where the generated sources should be placed
+     * 
+     * @parameter expression="${cxf.sourceRoot}"
+     *            default-value="${project.build.directory}/generated-sources/cxf"
+     * @required
+     */
+    File sourceRoot;
+
+    /**
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    String classesDirectory;
+
+    /**
+     * @parameter expression="${project}"
+     * @required
+     */
+    MavenProject project;
+
+    /**
+     * Default options to be used when a wsdl has not had it's options explicitly specified.
+     * 
+     * @parameter
+     */
+    Option defaultOptions = new Option();
+
+    
+
+    /**
+     * Directory in which the "DONE" markers are saved that
+     * 
+     * @parameter expression="${cxf.markerDirectory}"
+     *            default-value="${project.build.directory}/cxf-codegen-plugin-markers"
+     */
+    File markerDirectory;
+
+    /**
+     * Use the compile classpath rather than the test classpath for execution useful if the test dependencies
+     * clash with those of wsdl2java
+     * 
+     * @parameter expression="${cxf.useCompileClasspath}" default-value="false"
+     */
+    boolean useCompileClasspath;
+    
+    
+    /**
+     * Disables the scanning of the wsdlRoot/testWsdlRoot directories configured above.
+     * By default, we scan for *.wsdl (see include/exclude params as well) in the wsdlRoot
+     * directories and run wsdl2java on all the wsdl's we find.    This disables that scan
+     * and requires an explicit wsdlOption to be set for each wsdl that needs to be processed.
+     * @parameter expression="${cxf.disableDirectoryScan}" default-value="false"
+     */
+    boolean disableDirectoryScan;
+
+    /**
+     * By default all maven dependencies of type "wsdl" are added to the effective wsdlOptions. Setting this
+     * parameter to true disables this functionality
+     * 
+     * @parameter expression="${cxf.disableDependencyScan}" default-value="false"
+     */
+    boolean disableDependencyScan;
+
+    /**
+     * A list of wsdl files to include. Can contain ant-style wildcards and double wildcards. Defaults to
+     * *.wsdl
+     * 
+     * @parameter
+     */
+    String includes[];
+
+    /**
+     * A list of wsdl files to exclude. Can contain ant-style wildcards and double wildcards.
+     * 
+     * @parameter
+     */
+    String excludes[];
+
+    /**
+     * Allows running the JavaToWs in a separate process.
+     * Valid values are "false", "always", and "once"
+     * The value of "true" is equal to "once"
+     *
+     * @parameter default-value="false"
+     * @since 2.4
+     */
+    String fork;
+    
+    /**
+     * The local repository taken from Maven's runtime. Typically $HOME/.m2/repository.
+     * 
+     * @parameter expression="${localRepository}"
+     * @readonly
+     * @required
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * Artifact factory, needed to create artifacts.
+     * 
+     * @component
+     * @readonly
+     * @required
+     */
+    private ArtifactFactory artifactFactory;
+
+    /**
+     * The remote repositories used as specified in your POM.
+     * 
+     * @parameter expression="${project.repositories}"
+     * @readonly
+     * @required
+     */
+    private List repositories;
+
+    /**
+     * Artifact repository factory component.
+     * 
+     * @component
+     * @readonly
+     * @required
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    /**
+     * The Maven session.
+     * 
+     * @parameter expression="${session}"
+     * @readonly
+     * @required
+     */
+    private MavenSession mavenSession;
+
+    /**
+     * @component
+     * @readonly
+     * @required
+     */
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The plugin dependencies, needed for the fork mode.
+     *
+     * @parameter expression="${plugin.artifacts}"
+     * @required
+     * @readonly
+     */
+    private List<Artifact> pluginArtifacts;
+    
+
+    /**
+     * Sets the Java executable to use when fork parameter is <code>true</code>.
+     *
+     * @parameter default-value="${java.home}/bin/java"
+     * @since 2.4
+     */
+    private String javaExecutable;
+
+    /**
+     * Sets the JVM arguments (i.e. <code>-Xms128m -Xmx128m</code>) if fork is set to <code>true</code>.
+     *
+     * @parameter
+     * @since 2.4
+     */
+    private String additionalJvmArgs;
+    
+    /**
+     * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and deleting
+     * the second from the options list
+     * 
+     * @param options
+     */
+    
+    @SuppressWarnings("unchecked")
+    private Artifact resolveRemoteWsdlArtifact(List remoteRepos, Artifact artifact)
+        throws MojoExecutionException {
+        
+        /**
+         * First try to find the artifact in the reactor projects of the maven session.
+         * So an artifact that is not yet built can be resolved
+         */
+        List<MavenProject> rProjects = mavenSession.getSortedProjects();
+        for (MavenProject rProject : rProjects) {
+            if (artifact.getGroupId().equals(rProject.getGroupId())
+                && artifact.getArtifactId().equals(rProject.getArtifactId()) 
+                && artifact.getVersion().equals(rProject.getVersion())) {
+                Set<Artifact> artifacts = rProject.getArtifacts();
+                for (Artifact pArtifact : artifacts) {
+                    if ("wadl".equals(pArtifact.getType())) {
+                        return pArtifact;
+                    }
+                }
+            }
+        }
+        
+        /**
+         * If this did not work resolve the artifact using the artifactResolver
+         */
+        try {
+            artifactResolver.resolve(artifact, remoteRepos, localRepository);
+        } catch (ArtifactResolutionException e) {
+            throw new MojoExecutionException("Error downloading wsdl artifact.", e);
+        } catch (ArtifactNotFoundException e) {
+            throw new MojoExecutionException("Resource can not be found.", e);
+        }
+        
+        return artifact;
+    }
+
+    protected void downloadRemoteDocs(List<WadlOption> effectiveOptions) throws MojoExecutionException {
+        List remoteRepos;
+        try {
+            remoteRepos = ProjectUtils.buildArtifactRepositories(repositories, artifactRepositoryFactory,
+                                                                 mavenSession.getContainer());
+        } catch (InvalidRepositoryException e) {
+            throw new MojoExecutionException("Error build repositories for remote wsdls", e);
+        }
+        
+        for (WadlOption option : effectiveOptions) {
+            DocumentArtifact wsdlA = option.getWadlArtifact();
+            if (wsdlA == null) {
+                return;
+            }
+            Artifact wsdlArtifact = artifactFactory.createArtifact(wsdlA.getGroupId(), wsdlA.getArtifactId(),
+                                                                   wsdlA.getVersion(),
+                                                                   Artifact.SCOPE_COMPILE, wsdlA.getType());
+            wsdlArtifact = resolveRemoteWsdlArtifact(remoteRepos, wsdlArtifact);
+            if (wsdlArtifact != null) {
+                String path = wsdlArtifact.getFile().getAbsolutePath();
+                getLog().info("Resolved WSDL artifact to file " + path);
+                option.setWadl(path);
+            }
+        }
+    }
+
+    
+    
+    private void addPluginArtifact(Set<URI> artifactsPath) {
+        //for Maven 2.x, the actual artifact isn't in the list....  need to try and find it
+        URL url = getClass().getResource(getClass().getSimpleName() + ".class");
+        
+        try {
+            if ("jar".equals(url.getProtocol())) {
+                String s = url.getPath();
+                if (s.contains("!")) {
+                    s = s.substring(0, s.indexOf('!'));
+                    url = new URL(s);
+                }
+            }
+            URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
+            if (uri.getSchemeSpecificPart().endsWith(".class")) {
+                String s = uri.toString();
+                s = s.substring(0, s.length() - 6 - getClass().getName().length());
+                uri = new URI(s);
+            }
+            File file = new File(uri);
+            if (file.exists()) {
+                artifactsPath.add(file.toURI());
+            }
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+        }
+
+    }
+
+    protected void forkOnce(Set<URI> classPath, List<WadlOption> effectiveOptions) 
+        throws MojoExecutionException {
+        List<WadlOption> toDo = new LinkedList<WadlOption>();
+        List<List<String>> wargs = new LinkedList<List<String>>();
+        for (WadlOption option : effectiveOptions) {
+            File outputDirFile = option.getOutputDir();
+            outputDirFile.mkdirs();
+            URI basedir = project.getBasedir().toURI();
+            URI wadlURI = option.getWadlURI(basedir);
+            File doneFile = getDoneFile(basedir, wadlURI);
+
+            if (!shouldRun(option, doneFile, wadlURI)) {
+                continue;
+            }
+            doneFile.delete();
+            
+            toDo.add(option);
+            
+            wargs.add(option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
+                                                               .isDebugEnabled()));
+        }
+        if (wargs.isEmpty()) {
+            return;
+        }
+        
+        Set<URI> artifactsPath = new LinkedHashSet<URI>();
+        for (Artifact a : pluginArtifacts) {
+            File file = a.getFile();
+            if (file == null) {
+                throw new MojoExecutionException("Unable to find " + file + " for artifact "
+                                                 + a.getGroupId() + ":" + a.getArtifactId()
+                                                 + ":" + a.getVersion());
+            }
+            artifactsPath.add(file.toURI());
+        }
+        addPluginArtifact(artifactsPath);
+        artifactsPath.addAll(classPath);
+        
+        String args[] = createForkOnceArgs(wargs);
+        runForked(artifactsPath, ForkOnceCodeGenerator.class, args);
+        
+        for (WadlOption option : toDo) {
+            File dirs[] = option.getDeleteDirs();
+            if (dirs != null) {
+                for (int idx = 0; idx < dirs.length; ++idx) {
+                    deleteDir(dirs[idx]);
+                }
+            }
+            URI basedir = project.getBasedir().toURI();
+            URI wadlURI = option.getWadlURI(basedir);
+            File doneFile = getDoneFile(basedir, wadlURI);
+            try {
+                doneFile.createNewFile();
+            } catch (Throwable e) {
+                getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+                getLog().debug(e);
+            }
+        }
+    }
+
+    private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException {
+        try {
+            File f = FileUtils.createTempFile("cxf-w2j", "args");
+            PrintWriter fw = new PrintWriter(new FileWriter(f));
+            for (List<String> args : wargs) {
+                fw.println(Integer.toString(args.size()));
+                for (String s : args) {
+                    fw.println(s);
+                }
+            }
+            fw.println("-1");
+            fw.close();
+            return new String[] {f.getAbsolutePath()};
+        } catch (IOException ex) {
+            throw new MojoExecutionException("Could not create argument file", ex);
+        }
+    }
+
+    protected Bus callCodeGenerator(WadlOption option, 
+                              Bus bus,
+                              Set<URI> classPath) throws MojoExecutionException {
+        File outputDirFile = option.getOutputDir();
+        outputDirFile.mkdirs();
+        URI basedir = project.getBasedir().toURI();
+        URI wadlURI = option.getWadlURI(basedir);
+        File doneFile = getDoneFile(basedir, wadlURI);
+
+        if (!shouldRun(option, doneFile, wadlURI)) {
+            return bus;
+        }
+        doneFile.delete();
+
+        List<String> list = option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
+                                                           .isDebugEnabled());
+        String[] args = (String[])list.toArray(new String[list.size()]);
+        getLog().debug("Calling wadl2java with args: " + Arrays.toString(args));
+        
+        if (!"false".equals(fork)) {
+            Set<URI> artifactsPath = new LinkedHashSet<URI>();
+            for (Artifact a : pluginArtifacts) {
+                File file = a.getFile();
+                if (file == null) {
+                    throw new MojoExecutionException("Unable to find " + file + " for artifact "
+                                                     + a.getGroupId() + ":" + a.getArtifactId()
+                                                     + ":" + a.getVersion());
+                }
+                artifactsPath.add(file.toURI());
+            }
+            addPluginArtifact(artifactsPath);
+            artifactsPath.addAll(classPath);
+            
+            runForked(artifactsPath, WADLToJava.class, args);
+
+        } else {
+            if (bus == null) {
+                bus = BusFactory.newInstance().createBus();
+                BusFactory.setThreadDefaultBus(bus);
+            }
+            try {
+                new WADLToJava(args).run(new ToolContext());
+            } catch (Throwable e) {
+                getLog().debug(e);
+                throw new MojoExecutionException(e.getMessage(), e);
+            }  
+        }
+        
+
+        try {
+            doneFile.createNewFile();
+        } catch (Throwable e) {
+            getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+            getLog().debug(e);
+        }
+        return bus;
+    }
+    private File getJavaExecutable() throws IOException {
+        String exe = (SystemUtils.IS_OS_WINDOWS && !javaExecutable.endsWith(".exe")) ? ".exe" : "";
+        File javaExe = new File(javaExecutable + exe);
+
+        if (!javaExe.isFile()) {
+            throw new IOException("The java executable '" + javaExe
+                + "' doesn't exist or is not a file. Verify the <javaExecutable/> parameter.");
+        }
+
+        return javaExe;
+    }
+
+    private void runForked(Set<URI> classPath, Class cls, String[] args) throws MojoExecutionException {
+        getLog().info("Running wsdl2java in fork mode...");
+
+        Commandline cmd = new Commandline();
+        cmd.getShell().setQuotedArgumentsEnabled(false); // for JVM args
+        cmd.setWorkingDirectory(project.getBuild().getDirectory());
+        try {
+            cmd.setExecutable(getJavaExecutable().getAbsolutePath());
+        } catch (IOException e) {
+            getLog().debug(e);
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        cmd.createArg().setLine(additionalJvmArgs);
+        
+        File file = null;
+        try {
+            //file = new File("/tmp/test.jar"); 
+            file = FileUtils.createTempFile("cxf-codegen", ".jar");
+
+            JarArchiver jar = new JarArchiver();
+            jar.setDestFile(file.getAbsoluteFile());
+            
+            Manifest manifest = new Manifest();
+            Attribute attr = new Attribute();
+            attr.setName("Class-Path");
+            StringBuilder b = new StringBuilder(8000);
+            for (URI cp : classPath) {
+                b.append(cp.toURL().toExternalForm()).append(' ');
+            }
+            attr.setValue(b.toString());
+            manifest.getMainSection().addConfiguredAttribute(attr);
+            
+            attr = new Attribute();
+            attr.setName("Main-Class");
+            attr.setValue(cls.getName());
+            manifest.getMainSection().addConfiguredAttribute(attr);
+
+            jar.addConfiguredManifest(manifest);
+            jar.createArchive();
+            
+            cmd.createArg().setValue("-jar");
+            cmd.createArg().setValue(file.getAbsolutePath());
+
+            
+        } catch (Exception e1) {
+            throw new MojoExecutionException("Could not create runtime jar", e1);
+        }
+        cmd.addArguments(args);
+        
+
+        CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+        CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
+
+        int exitCode;
+        try {
+            exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
+        } catch (CommandLineException e) {
+            getLog().debug(e);
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        String output = StringUtils.isEmpty(out.getOutput()) ? null : '\n' + out.getOutput().trim();
+
+        String cmdLine = CommandLineUtils.toString(cmd.getCommandline());
+
+        if (exitCode != 0) {
+            if (StringUtils.isNotEmpty(output)) {
+                getLog().info(output);
+            }
+
+            StringBuffer msg = new StringBuffer("\nExit code: ");
+            msg.append(exitCode);
+            if (StringUtils.isNotEmpty(err.getOutput())) {
+                msg.append(" - ").append(err.getOutput());
+            }
+            msg.append('\n');
+            msg.append("Command line was: ").append(cmdLine).append('\n').append('\n');
+
+            throw new MojoExecutionException(msg.toString());
+        }
+
+        if (file != null) {
+            file.delete();
+        }
+        if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WSDL2Java Error")) {
+            StringBuffer msg = new StringBuffer();
+            msg.append(err.getOutput());
+            msg.append('\n');
+            msg.append("Command line was: ").append(cmdLine).append('\n').append('\n');
+            throw new MojoExecutionException(msg.toString());
+        }
+
+    }
+
+    private File getDoneFile(URI basedir, URI wsdlURI) {
+        String doneFileName = wsdlURI.toString();
+        
+        // Strip the basedir from the doneFileName
+        if (doneFileName.startsWith(basedir.toString())) {
+            doneFileName = doneFileName.substring(basedir.toString().length());
+        }
+
+        // If URL to WSDL, replace ? and & since they're invalid chars for file names
+        // Not to mention slashes.
+        doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/', '_').replace('\\', '_')
+            .replace(':', '_');
+
+        return new File(markerDirectory, "." + doneFileName + ".DONE");
+    }
+
+    /**
+     * Determine if code should be generated from the given wsdl
+     * 
+     * @param wsdlOption
+     * @param doneFile
+     * @param wsdlURI
+     * @return
+     */
+    private boolean shouldRun(WadlOption wsdlOption, File doneFile, URI wsdlURI) {
+        long timestamp = 0;
+        if ("file".equals(wsdlURI.getScheme())) {
+            timestamp = new File(wsdlURI).lastModified();
+        } else {
+            try {
+                timestamp = wsdlURI.toURL().openConnection().getDate();
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+        boolean doWork = false;
+        if (!doneFile.exists()) {
+            doWork = true;
+        } else if (timestamp > doneFile.lastModified()) {
+            doWork = true;
+        } else {
+            File files[] = wsdlOption.getDependencies();
+            if (files != null) {
+                for (int z = 0; z < files.length; ++z) {
+                    if (files[z].lastModified() > doneFile.lastModified()) {
+                        doWork = true;
+                    }
+                }
+            }
+        }
+        return doWork;
+    }
+
+    /**
+     * Recursively delete the given directory
+     * 
+     * @param f
+     * @return
+     */
+    protected boolean deleteDir(File f) {
+        if (f.isDirectory()) {
+            File files[] = f.listFiles();
+            for (int idx = 0; idx < files.length; ++idx) {
+                deleteDir(files[idx]);
+            }
+        }
+
+        if (f.exists()) {
+            return f.delete();
+        }
+
+        return true;
+    }
+
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java Mon May 23 17:30:28 2011
@@ -0,0 +1,236 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wadlto;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class Option {
+
+
+    /**
+     * Directory where generated java classes will be created. Defaults to plugin 'sourceRoot' parameter
+     */
+    protected File outputDir;
+
+    /**
+     * A set of dependent files used to detect the generator must process WSDL, even 
+     * if generator marker files are up to date.
+     */
+    File dependencies[];
+
+    /**
+     * Redundant directories to be deleted after code generation
+     */
+    File redundantDirs[];
+    
+    /**
+     * Extra arguments to pass to the command-line code generator. For compatibility as well as to
+     * specify any extra flags not addressed by other parameters
+     */
+    List<String> extraargs = new ArrayList<String>();
+
+    /**
+     * Specifies JAXB binding files. Use spaces to separate multiple entries.
+     */
+    String bindingFiles[] = new String[0];
+
+    /**
+     * Specifies catalog file to map the imported wadl/schema
+     */
+    String catalog;
+    
+    /**
+     * Specifies resource id
+     */
+    private String resourcename;
+    
+    /**
+     * Specifies package name of WADL resource elements 
+     */
+    private String packagename;
+    
+    /**
+     * Enables or disables generation of the impl classes. Default value is false.
+     * If set then only implementation classes will be generated
+     */
+    private Boolean generateImpl;
+    
+    /**
+     * Enables or disables generation of the interface classes. Setting this property
+     * only makes sense when generateImpl is also set. In other cases it is ignored and
+     * interfaces are always generated.
+     *  
+     * 
+     * 
+     */
+    private Boolean generateInterface;
+    
+    /**
+     * 
+     */
+    private List<String> schemaPackagenames = new ArrayList<String>();
+
+    public Option() {
+        super();
+    }
+
+    public void setDependencies(File files[]) {
+        dependencies = files;
+    }
+
+    public File[] getDependencies() {
+        return dependencies;
+    }
+
+    public void setDeleteDirs(File files[]) {
+        redundantDirs = files;
+    }
+
+    public File[] getDeleteDirs() {
+        return redundantDirs;
+    }
+
+    public File getOutputDir() {
+        return outputDir;
+    }
+
+    public void setOutputDir(File f) {
+        outputDir = f;
+    }
+    
+    public void setBindingFiles(String files[]) {
+        bindingFiles = files;
+    }
+    public String[] getBindingFiles() {
+        return bindingFiles;
+    }
+    public void addBindingFile(File file) {
+        String tmp[] = new String[bindingFiles.length + 1];
+        System.arraycopy(bindingFiles, 0, tmp, 0, bindingFiles.length);
+        bindingFiles = tmp;
+        bindingFiles[bindingFiles.length - 1] = file.getAbsolutePath();
+    }
+    
+    public List<String> getSchemaPackagenames() {
+        return schemaPackagenames;
+    }
+
+    public void setSchemaPackagenames(List<String> pn) {
+        this.schemaPackagenames = pn;
+    }
+    
+    public String getCatalog() {
+        return catalog;
+    }
+
+    public void setCatalog(String catalog) {
+        this.catalog = catalog;
+    }
+    
+    public String getPackagename() {
+        return packagename;
+    }
+
+    public void setPackagename(String name) {
+        this.packagename = name;
+    }
+
+    public void setResourcename(String resourceName) {
+        this.resourcename = resourceName;
+    }
+
+    public String getResourcename() {
+        return resourcename;
+    }
+
+    public boolean isImpl() {
+        return generateImpl == null ? false : generateImpl;
+    }
+    
+    public void setImpl(boolean impl) {
+        this.generateImpl = impl;
+    }
+    
+    public boolean isInterface() {
+        return generateInterface == null ? false : generateInterface;
+    }
+    
+    public void setInterface(boolean interf) {
+        this.generateInterface = interf;
+    }
+
+    public List<String> getExtraargs() {
+        return extraargs;
+    }
+
+    public void setExtraargs(List<String> ea) {
+        this.extraargs.clear();
+        this.extraargs.addAll(ea);
+    }
+    
+    public void copyOptions(Option destination) {
+        destination.setBindingFiles(getBindingFiles());
+        destination.setCatalog(getCatalog());
+        destination.setResourcename(getResourcename());
+        destination.setSchemaPackagenames(getSchemaPackagenames());
+        destination.setDeleteDirs(getDeleteDirs());
+        destination.setDependencies(getDependencies());
+        destination.setOutputDir(getOutputDir());
+    }
+    
+    
+    
+    private <T> T setIfNull(T dest, T source) {
+        if (dest == null) {
+            dest = source;
+        }
+        return dest;
+    }
+    
+    public void merge(Option defaultOptions) {
+        catalog = setIfNull(catalog, defaultOptions.catalog);
+        generateImpl = setIfNull(generateImpl, defaultOptions.generateImpl);
+        generateInterface = setIfNull(generateInterface, defaultOptions.generateInterface);
+        packagename = setIfNull(packagename, defaultOptions.packagename);
+        outputDir = setIfNull(outputDir, defaultOptions.outputDir);
+        bindingFiles = mergeList(bindingFiles, defaultOptions.bindingFiles, String.class);
+        dependencies = mergeList(dependencies, defaultOptions.dependencies, File.class);
+        redundantDirs = mergeList(redundantDirs, defaultOptions.redundantDirs, File.class);
+        schemaPackagenames.addAll(defaultOptions.schemaPackagenames);
+        extraargs.addAll(defaultOptions.extraargs);
+    }
+    
+    @SuppressWarnings("unchecked")
+    private <T> T[] mergeList(T[] l1, T[] l2, Class<T> cls) {
+        if (l1 == null) {
+            return l2;
+        } else if (l2 == null) {
+            return l1;
+        }
+        int len = l1.length + l2.length;
+        T ret[] = (T[])java.lang.reflect.Array.newInstance(cls, len);
+        System.arraycopy(l1, 0, ret, 0, l1.length);
+        System.arraycopy(l2, 0, ret, l1.length, l2.length);
+        return ret;
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/Option.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java Mon May 23 17:30:28 2011
@@ -0,0 +1,183 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wadlto;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.maven_plugin.common.DocumentArtifact;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+public final class OptionLoader {
+    private static final String WADL_TYPE = "wadl";
+    private static final String WADL_BINDINGS = "-binding-?\\d*.xml$";
+    
+    private OptionLoader() {
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static List<WadlOption> loadWsdlOptionsFromDependencies(MavenProject project, 
+                                                                   Option defaultOptions, File outputDir) {
+        List<WadlOption> options = new ArrayList<WadlOption>();
+        Set<Artifact> dependencies = project.getDependencyArtifacts();
+        for (Artifact artifact : dependencies) {
+            WadlOption option = generateWsdlOptionFromArtifact(artifact, outputDir);
+            if (option != null) {
+                if (defaultOptions != null) {
+                    option.merge(defaultOptions);
+                }
+                options.add(option);
+            }
+        }
+        return options;
+    }
+
+    private static WadlOption generateWsdlOptionFromArtifact(Artifact artifact, File outputDir) {
+        if (!WADL_TYPE.equals(artifact.getType())) {
+            return null;
+        }
+        WadlOption option = new WadlOption();
+        DocumentArtifact wsdlArtifact = new DocumentArtifact();
+        wsdlArtifact.setArtifactId(artifact.getArtifactId());
+        wsdlArtifact.setGroupId(artifact.getGroupId());
+        wsdlArtifact.setType(artifact.getType());
+        wsdlArtifact.setVersion(artifact.getVersion());
+        option.setWadlArtifact(wsdlArtifact);
+        option.setOutputDir(outputDir);
+        return option;
+    }
+
+    /**
+     * Scan files in a directory and generate one wsdlOption per file found. Extra args for code generation
+     * can be defined in a file that is named like the wsdl file and ends in -options. Binding files can be
+     * defined in files named like the wsdl file and end in -binding-*.xml
+     * 
+     * @param wsdlBasedir
+     * @param includes file name patterns to include
+     * @param excludes file name patterns to exclude
+     * @param defaultOptions options that should be used if no special file is given
+     * @return list of one WsdlOption object for each wsdl found
+     * @throws MojoExecutionException
+     */
+    public static List<WadlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, String includes[],
+                                                            String excludes[], Option defaultOptions,
+                                                            File defaultOutputDir)
+        throws MojoExecutionException {
+
+        if (wsdlBasedir == null) {
+            return new ArrayList<WadlOption>();
+        }
+
+        if (!wsdlBasedir.exists()) {
+            throw new MojoExecutionException(wsdlBasedir + " does not exist");
+        }
+
+        List<File> wsdlFiles = getWsdlFiles(wsdlBasedir, includes, excludes);
+        List<WadlOption> wsdlOptions = new ArrayList<WadlOption>();
+        for (File wsdl : wsdlFiles) {
+            WadlOption wsdlOption = generateWsdlOptionFromFile(wsdl, defaultOptions, defaultOutputDir);
+            if (wsdlOption != null) {
+                wsdlOptions.add(wsdlOption);
+            }
+        }
+        return wsdlOptions;
+    }
+
+    private static String joinWithComma(String[] arr) {
+        if (arr == null) {
+            return "";
+        }
+        StringBuilder str = new StringBuilder();
+
+        if (arr != null) {
+            for (String s : arr) {
+                if (str.length() > 0) {
+                    str.append(',');
+                }
+                str.append(s);
+            }
+        }
+        return str.toString();
+    }
+
+    private static List<File> getWsdlFiles(File dir, String includes[], String excludes[])
+        throws MojoExecutionException {
+
+        List<String> exList = new ArrayList<String>();
+        if (excludes != null) {
+            exList.addAll(Arrays.asList(excludes));
+        }
+        exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
+
+        String inc = joinWithComma(includes);
+        String ex = joinWithComma(exList.toArray(new String[exList.size()]));
+
+        try {
+            List newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
+            return CastUtils.cast(newfiles);
+        } catch (IOException exc) {
+            throw new MojoExecutionException(exc.getMessage(), exc);
+        }
+    }
+
+
+    protected static WadlOption generateWsdlOptionFromFile(final File wadl, final Option defaultOptions,
+                                                           File defaultOutputDir)
+        throws MojoExecutionException {
+
+        if (wadl == null || !wadl.exists()) {
+            return null;
+        }
+
+        final String wadlFileName = wadl.getName();
+        int idx = wadlFileName.toLowerCase().lastIndexOf(".wadl");
+        if (idx == -1) {
+            idx = wadlFileName.lastIndexOf('.');
+        }
+        if (idx == -1) {
+            return null;
+        }
+
+        final WadlOption wsdlOption = new WadlOption();
+        final String wadlName = wadlFileName.substring(0, idx);
+
+        List<File> bindingFiles = FileUtils.getFiles(wadl.getParentFile(), wadlName + WADL_BINDINGS);
+        if (bindingFiles != null) {
+            for (File binding : bindingFiles) {
+                wsdlOption.addBindingFile(binding);
+            }
+        }
+        wsdlOption.setWadl(wadl.toURI().toString());
+
+        if (wsdlOption.getOutputDir() == null) {
+            wsdlOption.setOutputDir(defaultOutputDir);
+        }
+
+        return wsdlOption;
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java Mon May 23 17:30:28 2011
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wadlto;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.maven_plugin.common.ClassLoaderSwitcher;
+import org.apache.maven.plugin.MojoExecutionException;
+
+
+/**
+ * @goal wadl2java
+ * @phase generate-sources
+ * @description CXF WADL To Java Tool
+ * @requiresDependencyResolution test
+ */
+public class WADL2JavaMojo extends AbstractCodeGeneratorMojo {
+    /**
+     * @parameter
+     */
+    WadlOption wadlOptions[];
+
+    /**
+     * @parameter expression="${cxf.wadlRoot}" default-value="${basedir}/src/main/resources/wadl"
+     */
+    File wadlRoot;
+
+    /**
+     * @parameter expression="${cxf.testWadlRoot}" default-value="${basedir}/src/test/resources/wadl"
+     */
+    File testWadlRoot;
+    
+    private void mergeOptions(List<WadlOption> effectiveOptions) {
+        if (wadlOptions == null) {
+            return;
+        }
+        File outputDirFile = testSourceRoot == null ? sourceRoot : testSourceRoot;
+        for (WadlOption o : wadlOptions) {
+            if (defaultOptions != null) {
+                o.merge(defaultOptions);
+            }
+            if (o.getOutputDir() == null) {
+                o.setOutputDir(outputDirFile);
+            }
+
+            effectiveOptions.add(o);
+        }
+    }
+
+    public void execute() throws MojoExecutionException {
+        if (includes == null) {
+            includes = new String[] {
+                "*.wadl"
+            };
+        }
+        File classesDir = new File(classesDirectory);
+        classesDir.mkdirs();
+        markerDirectory.mkdirs();
+
+        List<WadlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
+
+        if (effectiveWsdlOptions.size() == 0) {
+            getLog().info("Nothing to generate");
+            return;
+        }
+
+        ClassLoaderSwitcher classLoaderSwitcher = new ClassLoaderSwitcher(getLog());
+        boolean result = true;
+
+        Bus bus = null;
+        try {
+            Set<URI> cp = classLoaderSwitcher.switchClassLoader(project, useCompileClasspath, classesDir);
+
+            if ("once".equals(fork) || "true".equals(fork)) {
+                forkOnce(cp, effectiveWsdlOptions);
+            } else {
+                for (WadlOption o : effectiveWsdlOptions) {
+                    bus = callCodeGenerator(o, bus, cp);
+    
+                    File dirs[] = o.getDeleteDirs();
+                    if (dirs != null) {
+                        for (int idx = 0; idx < dirs.length; ++idx) {
+                            result = result && deleteDir(dirs[idx]);
+                        }
+                    }
+                }
+            }
+        } finally {
+            // cleanup as much as we can.
+            if (bus != null) {
+                bus.shutdown(true);
+            }
+            classLoaderSwitcher.restoreClassLoader();
+        }
+        if (project != null && sourceRoot != null && sourceRoot.exists()) {
+            project.addCompileSourceRoot(sourceRoot.getAbsolutePath());
+        }
+        if (project != null && testSourceRoot != null && testSourceRoot.exists()) {
+            project.addTestCompileSourceRoot(testSourceRoot.getAbsolutePath());
+        }
+
+        System.gc();
+    }
+    
+    /**
+     * @return effective WsdlOptions
+     * @throws MojoExecutionException
+     */
+    private List<WadlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions() 
+        throws MojoExecutionException {
+        List<WadlOption> effectiveOptions = new ArrayList<WadlOption>();
+        List<WadlOption> temp;
+        if (wadlRoot != null && wadlRoot.exists() && !disableDirectoryScan) {
+            temp = OptionLoader.loadWsdlOptionsFromFiles(wadlRoot, includes, excludes, defaultOptions,
+                                                             sourceRoot);
+            effectiveOptions.addAll(temp);
+        }
+        if (testWadlRoot != null && testWadlRoot.exists() && !disableDirectoryScan) {
+            temp = OptionLoader.loadWsdlOptionsFromFiles(testWadlRoot, includes, excludes,
+                                                             defaultOptions, testSourceRoot);
+            effectiveOptions.addAll(temp);
+        }
+        if (!disableDependencyScan) {
+            temp = OptionLoader.loadWsdlOptionsFromDependencies(project, defaultOptions, sourceRoot);
+            effectiveOptions.addAll(temp);
+        }
+        mergeOptions(effectiveOptions);
+        downloadRemoteDocs(effectiveOptions);
+        return effectiveOptions;
+    }
+    
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java?rev=1126608&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java (added)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java Mon May 23 17:30:28 2011
@@ -0,0 +1,170 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin.wadlto;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.maven_plugin.common.DocumentArtifact;
+import org.apache.cxf.tools.util.URIParserUtil;
+
+public class WadlOption extends Option {
+
+    /**
+     * The WADL file to process.
+     */
+    String wadl;
+
+    /**
+     * Alternatively to the wsdl string an artifact can be specified
+     */
+    DocumentArtifact wadlArtifact;
+
+    public String getWadl() {
+        return wadl;
+    }
+
+    public void setWadl(String w) {
+        wadl = w;
+    }
+
+    public DocumentArtifact getWadlArtifact() {
+        return wadlArtifact;
+    }
+
+    public void setWadlArtifact(DocumentArtifact wadlArtifact) {
+        this.wadlArtifact = wadlArtifact;
+    }
+    
+    /**
+     * Try to find a file matching the wadl path (either absolutely, relatively to the current dir or to
+     * the project base dir)
+     * 
+     * @return wadl file
+     */
+    public File getDocumentFile(File baseDir) {
+        if (wadl == null) {
+            return null;
+        }
+        File file = null;
+        try {
+            URI uri = new URI(wadl);
+            if (uri.isAbsolute()) {
+                file = new File(uri);
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+        if (file == null || !file.exists()) {
+            file = new File(wadl);
+        }
+        if (!file.exists()) {
+            file = new File(baseDir, wadl);
+        }
+        return file;
+    }
+    
+    public URI getWadlURI(URI baseURI) {
+        String wadlLocation = getWadl();
+        File wadlFile = new File(wadlLocation);
+        return wadlFile.exists() ? wadlFile.toURI() 
+            : baseURI.resolve(URIParserUtil.escapeChars(wadlLocation));
+    }
+
+
+    public int hashCode() {
+        if (wadl != null) {
+            return wadl.hashCode();
+        }
+        return -1;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof WadlOption)) {
+            return false;
+        }
+
+        WadlOption t = (WadlOption)obj;
+        return t.getWadl().equals(getWadl());
+    }
+
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("WADL: ").append(wadl).append('\n');
+        builder.append("OutputDir: ").append(outputDir).append('\n');
+        builder.append('\n');
+        return builder.toString();
+    }
+
+    public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wsdlURI, boolean debug) {
+        List<String> list = new ArrayList<String>();
+        addIfNotNull(list, outputDirFile, "-d");
+        for (String binding : getBindingFiles()) {
+            File bindingFile = new File(binding);
+            URI bindingURI = bindingFile.exists() ? bindingFile.toURI() : basedir.resolve(binding);
+            list.add("-b");
+            list.add(bindingURI.toString());
+        }
+        addIfNotNull(list, getCatalog(), "-catalog");
+        addIfNotNull(list, getResourcename(), "-resource");
+        addIfNotNull(list, getPackagename(), "-p");
+        addList(list, "-sp", true, getSchemaPackagenames());
+        addIfTrue(list, isImpl(), "-impl");
+        addIfTrue(list, isInterface(), "-interface");
+        addList(list, "", false, getExtraargs());
+        list.add(wsdlURI.toString());
+        return list;
+    }
+
+    
+    // TODO: the following 3 helpers can go to a superclass or common utility class
+    //       to be used by WADL and WSDL Pptions 
+    private static void addIfNotNull(List<String> list, Object value, String key) {
+        if (value != null) {
+            list.add(key);
+            list.add(value.toString());
+        }
+    }
+
+    private static void addList(List<String> destList, String key, boolean keyAsOwnElement,
+                                List<String> sourceList) {
+        if (sourceList == null) {
+            return;
+        }
+        for (String value : sourceList) {
+            if (keyAsOwnElement) {
+                destList.add(key);
+                destList.add(value);
+            } else {
+                // Maven makes empty tags into null
+                // instead of empty strings. so replace null by ""
+                destList.add(key + ((value == null) ? "" : value));
+            }
+        }
+    }
+    
+    private static void addIfTrue(List<String> list, boolean expression, String key) {
+        if (expression) {
+            list.add(key);
+        }
+    }
+}

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java?rev=1126608&r1=1126607&r2=1126608&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java Mon May 23 17:30:28 2011
@@ -31,10 +31,10 @@ public final class WadlToolConstants {
      * Default
      */
     public static final String CFG_INTERFACE = ToolConstants.CFG_INTERFACE;
-    public static final String CFG_SERVER = ToolConstants.CFG_SERVER;
+    public static final String CFG_IMPL = ToolConstants.CFG_IMPL;
     public static final String CFG_TYPES = ToolConstants.CFG_TYPES;
     public static final String CFG_PACKAGENAME = ToolConstants.CFG_PACKAGENAME;
-    public static final String CFG_TYPES_PACKAGENAME = "typesPackagename";
+    public static final String CFG_SCHEMA_PACKAGENAME = "schemaPackagename";
     public static final String CFG_RESOURCENAME = "resourcename";
     
     public static final String CFG_CATALOG = ToolConstants.CFG_CATALOG;

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java?rev=1126608&r1=1126607&r2=1126608&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java Mon May 23 17:30:28 2011
@@ -99,11 +99,11 @@ public class JAXRSContainer extends Abst
         
         SourceGenerator sg = new SourceGenerator();
         sg.setBus(getBus());
-        boolean isInterface = context.optionSet(WadlToolConstants.CFG_INTERFACE);
-        boolean isServer = context.optionSet(WadlToolConstants.CFG_SERVER);
-        if (isServer) {
-            sg.setGenerateInterfaces(isInterface);
-            sg.setGenerateImplementation(true);
+
+        boolean generateImpl = context.optionSet(WadlToolConstants.CFG_IMPL);
+        sg.setGenerateImplementation(generateImpl);
+        if (generateImpl) {
+            sg.setGenerateInterfaces(context.optionSet(WadlToolConstants.CFG_INTERFACE));
         }
         sg.setPackageName((String)context.get(WadlToolConstants.CFG_PACKAGENAME));
         sg.setResourceName((String)context.get(WadlToolConstants.CFG_RESOURCENAME));
@@ -172,7 +172,7 @@ public class JAXRSContainer extends Abst
     // org.apache.cxf.tools.wsdlto.databinding.jaxb ?
     private void setPackageAndNamespaces() {
         String[] schemaPackageNamespaces = new String[]{};
-        Object value = context.get(WadlToolConstants.CFG_TYPES_PACKAGENAME);
+        Object value = context.get(WadlToolConstants.CFG_SCHEMA_PACKAGENAME);
         if (value != null) {
             schemaPackageNamespaces = value instanceof String ? new String[]{(String)value}
                                                    : (String[])value;
@@ -188,7 +188,7 @@ public class JAXRSContainer extends Abst
                 // this is the default schema package name
                 // if CFG_PACKAGENAME is set then it's only used for JAX-RS resource 
                 // classes
-                context.put(WadlToolConstants.CFG_TYPES_PACKAGENAME, packagename);
+                context.put(WadlToolConstants.CFG_SCHEMA_PACKAGENAME, packagename);
             }
         }
         

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml?rev=1126608&r1=1126607&r2=1126608&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml Mon May 23 17:30:28 2011
@@ -43,7 +43,7 @@ Examples:
                 </associatedArgument>
             </option>
             
-            <option id="typePackagename" maxOccurs="unbounded">
+            <option id="schemaPackagename" maxOccurs="unbounded">
                 <annotation>
                     Specifies the java package name to use for the generated code
                     representing WADL grammar elements.

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java?rev=1126608&r1=1126607&r2=1126608&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java Mon May 23 17:30:28 2011
@@ -218,7 +218,7 @@ public class JAXRSContainerTest extends 
             context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
             context.put(WadlToolConstants.CFG_PACKAGENAME, "custom.books.service");
-            context.put(WadlToolConstants.CFG_TYPES_PACKAGENAME, "http://superbooks=custom.books.schema");
+            context.put(WadlToolConstants.CFG_SCHEMA_PACKAGENAME, "http://superbooks=custom.books.schema");
             context.put(WadlToolConstants.CFG_COMPILE, "true");
 
             container.setContext(context);
@@ -243,7 +243,7 @@ public class JAXRSContainerTest extends 
             ToolContext context = new ToolContext();
             context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
-            context.put(WadlToolConstants.CFG_SERVER, "true");
+            context.put(WadlToolConstants.CFG_IMPL, "true");
             context.put(WadlToolConstants.CFG_COMPILE, "true");
             
             container.setContext(context);
@@ -268,7 +268,7 @@ public class JAXRSContainerTest extends 
             context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
             context.put(WadlToolConstants.CFG_INTERFACE, "true");
-            context.put(WadlToolConstants.CFG_SERVER, "true");
+            context.put(WadlToolConstants.CFG_IMPL, "true");
             context.put(WadlToolConstants.CFG_COMPILE, "true");
             
             container.setContext(context);