cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5986] Copying some more code from the WSDL plugin to do with supporting filesets, and checking CXF ClasspathScanner too
Date Tue, 09 Sep 2014 16:39:55 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes b535ff659 -> 3b349d5d2


[CXF-5986] Copying some more code from the WSDL plugin to do with supporting filesets, and
checking CXF ClasspathScanner too


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3b349d5d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3b349d5d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3b349d5d

Branch: refs/heads/3.0.x-fixes
Commit: 3b349d5d2217d04828e9482ea10dcd3cceb1d1b6
Parents: b535ff6
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Sep 9 17:37:10 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Sep 9 17:39:35 2014 +0100

----------------------------------------------------------------------
 .../cxf/common/util/ClasspathScanner.java       |  18 +-
 .../cxf/common/util/SpringClasspathScanner.java |  13 +-
 .../wadlto/AbstractCodeGeneratorMojo.java       | 227 +++++++++++--------
 .../cxf/maven_plugin/wadlto/OptionLoader.java   |  78 +++++--
 .../cxf/maven_plugin/wadlto/WADL2JavaMojo.java  |  19 +-
 .../cxf/maven_plugin/wadlto/WadlOption.java     |  41 +++-
 .../cxf/jaxrs/utils/schemas/SchemaHandler.java  |   2 +-
 7 files changed, 256 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
index 870e749..41a491e 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
@@ -32,7 +32,7 @@ import java.util.Set;
 public class ClasspathScanner {
     public static final String ALL_FILES = "**/*";
     public static final String ALL_CLASS_FILES = ALL_FILES + ".class";
-    public static final String ALL_PACKAGES = "*";
+    public static final String WILDCARD = "*";
     public static final String CLASSPATH_URL_SCHEME = "classpath:";
     
     static final ClasspathScanner HELPER;
@@ -120,7 +120,19 @@ public class ClasspathScanner {
      */
     public static List<URL> findResources(String basePackage, String extension) 
         throws IOException {
-        return findResources(Collections.singletonList(basePackage), extension);
+        return findResources(basePackage, extension, null);
+    }
+    
+    /**
+     * Scans list of base packages for all resources with the given extension. 
+     * @param basePackage base package 
+     * @param extension the extension matching resources needs to have
+     * @return list of all discovered resource URLs 
+     * @throws IOException resource is not accessible
+     */
+    public static List<URL> findResources(String basePackage, String extension, ClassLoader
loader) 
+        throws IOException {
+        return findResources(Collections.singletonList(basePackage), extension, loader);
     }
     
     /**
@@ -146,7 +158,7 @@ public class ClasspathScanner {
         final Set<String> basePackages = new HashSet<String>(values.length);
         for (final String value : values) {
             final String trimmed = value.trim();
-            if (trimmed.equals(ClasspathScanner.ALL_PACKAGES)) {
+            if (trimmed.equals(WILDCARD)) {
                 basePackages.clear();
                 basePackages.add(trimmed);
                 break;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
index b026c66..769d1f0 100644
--- a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
@@ -70,11 +70,10 @@ class SpringClasspathScanner extends ClasspathScanner {
         }
         
         for (final String basePackage: basePackages) {
-            final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
-            
+            final boolean scanAllPackages = basePackage.equals(WILDCARD);
             final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX

-                + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(basePackage))

-                + ALL_CLASS_FILES;
+                + (scanAllPackages ? "" : basePackage.contains(WILDCARD) ? basePackage 
+                    : ClassUtils.convertClassNameToResourcePath(basePackage)) + ALL_CLASS_FILES;
             
             final Resource[] resources = resolver.getResources(packageSearchPath);    
             
@@ -136,7 +135,7 @@ class SpringClasspathScanner extends ClasspathScanner {
         ResourcePatternResolver resolver = getResolver(loader);
         
         for (final String basePackage: basePackages) {
-            final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
+            final boolean scanAllPackages = basePackage.equals(WILDCARD);
             
             String theBasePackage = basePackage;
             if (theBasePackage.startsWith(CLASSPATH_URL_SCHEME)) {
@@ -144,8 +143,8 @@ class SpringClasspathScanner extends ClasspathScanner {
             }
             
             final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX

-                + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(theBasePackage))

-                + ALL_FILES + "." + extension;
+                + (scanAllPackages ? "" : basePackage.contains(WILDCARD) ? basePackage 
+                    : ClassUtils.convertClassNameToResourcePath(theBasePackage)) + ALL_FILES
+ "." + extension;
             
             final Resource[] resources = resolver.getResources(packageSearchPath);      
                 
             for (final Resource resource: resources) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
index 311a52d..9b06164 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.URI;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.Arrays;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -48,6 +49,7 @@ 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.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -89,7 +91,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
     MavenProject project;
 
     /**
-     * Default options to be used when a wsdl has not had it's options explicitly specified.
+     * Default options to be used when a wadl has not had it's options explicitly specified.
      * 
      * @parameter
      */
@@ -107,7 +109,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
 
     /**
      * Use the compile classpath rather than the test classpath for execution useful if the
test dependencies
-     * clash with those of wsdl2java
+     * clash with those of wadl2java
      * 
      * @parameter expression="${cxf.useCompileClasspath}" default-value="false"
      */
@@ -115,16 +117,16 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
     
     
     /**
-     * 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.
+     * Disables the scanning of the wadlRoot/testWadlRoot directories configured above.
+     * By default, we scan for *.wadl (see include/exclude params as well) in the wadlRoot
+     * directories and run wadl2java on all the wadl's we find.    This disables that scan
+     * and requires an explicit wadlOption to be set for each wadl 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
+     * By default all maven dependencies of type "wadl" are added to the effective wadlOptions.
Setting this
      * parameter to true disables this functionality
      * 
      * @parameter expression="${cxf.disableDependencyScan}" default-value="false"
@@ -132,15 +134,15 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
     boolean disableDependencyScan;
 
     /**
-     * A list of wsdl files to include. Can contain ant-style wildcards and double wildcards.
Defaults to
-     * *.wsdl
+     * A list of wadl files to include. Can contain ant-style wildcards and double wildcards.
Defaults to
+     * *.wadl
      * 
      * @parameter
      */
     String includes[];
 
     /**
-     * A list of wsdl files to exclude. Can contain ant-style wildcards and double wildcards.
+     * A list of wadl files to exclude. Can contain ant-style wildcards and double wildcards.
      * 
      * @parameter
      */
@@ -234,15 +236,17 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
      */
     private String additionalJvmArgs;
     
+    private ClassLoader resourceClassLoader;
+    
     /**
-     * Merge WsdlOptions that point to the same file by adding the extraargs to the first
option and deleting
+     * Merge WadlOptions 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)
+    private Artifact resolveRemoteWadlArtifact(List<?> remoteRepos, Artifact artifact)
         throws MojoExecutionException {
         
         /**
@@ -269,7 +273,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
         try {
             artifactResolver.resolve(artifact, remoteRepos, localRepository);
         } catch (ArtifactResolutionException e) {
-            throw new MojoExecutionException("Error downloading wsdl artifact.", e);
+            throw new MojoExecutionException("Error downloading wadl artifact.", e);
         } catch (ArtifactNotFoundException e) {
             throw new MojoExecutionException("Resource can not be found.", e);
         }
@@ -283,21 +287,21 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
             remoteRepos = ProjectUtils.buildArtifactRepositories(repositories, artifactRepositoryFactory,
                                                                  mavenSession.getContainer());
         } catch (InvalidRepositoryException e) {
-            throw new MojoExecutionException("Error build repositories for remote wsdls",
e);
+            throw new MojoExecutionException("Error build repositories for remote wadls",
e);
         }
         
         for (WadlOption option : effectiveOptions) {
-            DocumentArtifact wsdlA = option.getWadlArtifact();
-            if (wsdlA == null) {
+            DocumentArtifact wadlA = option.getWadlArtifact();
+            if (wadlA == 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);
+            Artifact wadlArtifact = artifactFactory.createArtifact(wadlA.getGroupId(), wadlA.getArtifactId(),
+                                                                   wadlA.getVersion(),
+                                                                   Artifact.SCOPE_COMPILE,
wadlA.getType());
+            wadlArtifact = resolveRemoteWadlArtifact(remoteRepos, wadlArtifact);
+            if (wadlArtifact != null) {
+                String path = wadlArtifact.getFile().getAbsolutePath();
+                getLog().info("Resolved WADL artifact to file " + path);
                 option.setWadl(path);
             }
         }
@@ -341,18 +345,19 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
             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;
+            for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+                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()));
             }
-            doneFile.delete();
-            
-            toDo.add(option);
-            
-            wargs.add(option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
-                                                               .isDebugEnabled()));
         }
         if (wargs.isEmpty()) {
             return;
@@ -382,13 +387,14 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
                 }
             }
             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);
+            for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+                File doneFile = getDoneFile(basedir, wadlURI);
+                try {
+                    doneFile.createNewFile();
+                } catch (Throwable e) {
+                    getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+                    getLog().debug(e);
+                }
             }
         }
     }
@@ -411,60 +417,91 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
         }
     }
 
+    private ClassLoader getResourceLoader() throws MojoExecutionException {
+        if (resourceClassLoader == null) {
+            try {
+                List<?> runtimeClasspathElements = project.getRuntimeClasspathElements();
+                List<?> resources = project.getResources();
+                List<?> testResources = project.getTestResources();
+                URL[] runtimeUrls = new URL[runtimeClasspathElements.size() + resources.size()
+ testResources.size()];
+                for (int i = 0; i < runtimeClasspathElements.size(); i++) {
+                    String element = (String)runtimeClasspathElements.get(i);
+                    runtimeUrls[i] = new File(element).toURI().toURL();
+                }
+                for (int i = 0, j = runtimeClasspathElements.size(); i < resources.size();
i++, j++) {
+                    Resource r = (Resource)resources.get(i);
+                    runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL();
+                }
+                for (int i = 0, j = runtimeClasspathElements.size() + resources.size(); i
< testResources.size();
+                    i++, j++) {
+                    Resource r = (Resource)testResources.get(i);
+                    runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL();
+                }
+                resourceClassLoader = new URLClassLoader(runtimeUrls, Thread.currentThread()
+                    .getContextClassLoader());
+            } catch (Exception e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+        return resourceClassLoader;
+    }
+    
     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 = 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());
+        for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+            File doneFile = getDoneFile(basedir, wadlURI);
+    
+            if (!shouldRun(option, doneFile, wadlURI)) {
+                return bus;
             }
-            addPluginArtifact(artifactsPath);
-            artifactsPath.addAll(classPath);
+            doneFile.delete();
+    
+            List<String> list = option.generateCommandLine(outputDirFile, basedir,
wadlURI, getLog()
+                                                               .isDebugEnabled());
+            String[] args = list.toArray(new String[list.size()]);
+            getLog().debug("Calling wadl2java with args: " + Arrays.toString(args));
             
-            runForked(artifactsPath, WADLToJava.class, args);
-
-        } else {
-            if (bus == null) {
-                bus = BusFactory.newInstance().createBus();
-                BusFactory.setThreadDefaultBus(bus);
+            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 {
-                new WADLToJava(args).run(new ToolContext());
+                doneFile.createNewFile();
             } catch (Throwable e) {
+                getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
                 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;
     }
@@ -481,7 +518,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
     }
 
     private void runForked(Set<URI> classPath, Class<?> cls, String[] args) throws
MojoExecutionException {
-        getLog().info("Running wsdl2java in fork mode...");
+        getLog().info("Running wadl2java in fork mode...");
 
         Commandline cmd = new Commandline();
         cmd.getShell().setQuotedArgumentsEnabled(true); // for JVM args
@@ -565,7 +602,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
         if (file != null) {
             file.delete();
         }
-        if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WSDL2Java
Error")) {
+        if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WADL2Java
Error")) {
             StringBuffer msg = new StringBuffer();
             msg.append(err.getOutput());
             msg.append('\n');
@@ -575,15 +612,15 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
 
     }
 
-    private File getDoneFile(URI basedir, URI wsdlURI) {
-        String doneFileName = wsdlURI.toString();
+    private File getDoneFile(URI basedir, URI wadlURI) {
+        String doneFileName = wadlURI.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
+        // If URL to WADL, replace ? and & since they're invalid chars for file names
         // Not to mention slashes.
         doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/',
'_').replace('\\', '_')
             .replace(':', '_');
@@ -592,20 +629,20 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo
{
     }
 
     /**
-     * Determine if code should be generated from the given wsdl
+     * Determine if code should be generated from the given wadl
      * 
-     * @param wsdlOption
+     * @param wadlOption
      * @param doneFile
-     * @param wsdlURI
+     * @param wadlURI
      * @return
      */
-    private boolean shouldRun(WadlOption wsdlOption, File doneFile, URI wsdlURI) {
+    private boolean shouldRun(WadlOption wadlOption, File doneFile, URI wadlURI) {
         long timestamp = 0;
-        if ("file".equals(wsdlURI.getScheme())) {
-            timestamp = new File(wsdlURI).lastModified();
+        if ("file".equals(wadlURI.getScheme())) {
+            timestamp = new File(wadlURI).lastModified();
         } else {
             try {
-                timestamp = wsdlURI.toURL().openConnection().getDate();
+                timestamp = wadlURI.toURL().openConnection().getDate();
             } catch (Exception e) {
                 // ignore
             }
@@ -616,7 +653,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
         } else if (timestamp > doneFile.lastModified()) {
             doWork = true;
         } else {
-            File files[] = wsdlOption.getDependencies();
+            File files[] = wadlOption.getDependencies();
             if (files != null) {
                 for (int z = 0; z < files.length; ++z) {
                     if (files[z].lastModified() > doneFile.lastModified()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
----------------------------------------------------------------------
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
index 9dbe432..97e5e33 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
@@ -35,6 +35,7 @@ import org.apache.maven.project.MavenProject;
 
 public final class OptionLoader {
     private static final String WADL_TYPE = "wadl";
+    private static final String WADL_OPTIONS = "-options$";
     private static final String WADL_BINDINGS = "-binding-?\\d*.xml$";
     
     private OptionLoader() {
@@ -73,39 +74,39 @@ public final class OptionLoader {
     }
 
     /**
-     * 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
+     * Scan files in a directory and generate one wadlOption per file found. Extra args for
code generation
+     * can be defined in a file that is named like the wadl file and ends in -options. Binding
files can be
+     * defined in files named like the wadl file and end in -binding-*.xml
      * 
-     * @param wsdlBasedir
+     * @param wadlBasedir
      * @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
+     * @return list of one WadlOption object for each wadl found
      * @throws MojoExecutionException
      */
-    public static List<WadlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, String
includes[],
+    public static List<WadlOption> loadWadlOptionsFromFile(File wadlBasedir, String
includes[],
                                                             String excludes[], Option defaultOptions,
                                                             File defaultOutputDir)
         throws MojoExecutionException {
 
-        if (wsdlBasedir == null) {
+        if (wadlBasedir == null) {
             return new ArrayList<WadlOption>();
         }
 
-        if (!wsdlBasedir.exists()) {
-            throw new MojoExecutionException(wsdlBasedir + " does not exist");
+        if (!wadlBasedir.exists()) {
+            throw new MojoExecutionException(wadlBasedir + " 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);
+        List<File> wadlFiles = getWadlFiles(wadlBasedir, includes, excludes);
+        List<WadlOption> wadlOptions = new ArrayList<WadlOption>();
+        for (File wadl : wadlFiles) {
+            WadlOption wadlOption = generateWadlOptionFromFile(wadl, defaultOptions, defaultOutputDir);
+            if (wadlOption != null) {
+                wadlOptions.add(wadlOption);
             }
         }
-        return wsdlOptions;
+        return wadlOptions;
     }
 
     private static String joinWithComma(String[] arr) {
@@ -123,7 +124,7 @@ public final class OptionLoader {
         return str.toString();
     }
 
-    private static List<File> getWsdlFiles(File dir, String includes[], String excludes[])
+    private static List<File> getWadlFiles(File dir, String includes[], String excludes[])
         throws MojoExecutionException {
 
         List<String> exList = new ArrayList<String>();
@@ -144,7 +145,7 @@ public final class OptionLoader {
     }
 
 
-    protected static WadlOption generateWsdlOptionFromFile(final File wadl, final Option
defaultOptions,
+    protected static WadlOption generateWadlOptionFromFile(final File wadl, final Option
defaultOptions,
                                                            File defaultOutputDir)
         throws MojoExecutionException {
 
@@ -161,21 +162,48 @@ public final class OptionLoader {
             return null;
         }
 
-        final WadlOption wsdlOption = new WadlOption();
+        final WadlOption wadlOption = new WadlOption();
         final String wadlName = wadlFileName.substring(0, idx);
 
+        final String[] options = readOptionsFromFile(wadl.getParentFile(), wadlName);
+        if (options.length > 0) {
+            wadlOption.getExtraargs().addAll(Arrays.asList(options));
+        }
+        
         List<File> bindingFiles = FileUtils.getFiles(wadl.getParentFile(), wadlName
+ WADL_BINDINGS);
         if (bindingFiles != null) {
             for (File binding : bindingFiles) {
-                wsdlOption.addBindingFile(binding);
+                wadlOption.addBindingFile(binding);
             }
         }
-        wsdlOption.setWadl(wadl.toURI().toString());
-
-        if (wsdlOption.getOutputDir() == null) {
-            wsdlOption.setOutputDir(defaultOutputDir);
+        wadlOption.setWadl(wadl.toURI().toString());
+        
+        if (wadlOption.getOutputDir() == null) {
+            wadlOption.setOutputDir(defaultOutputDir);
         }
 
-        return wsdlOption;
+        return wadlOption;
+    }
+    
+    private static String[] readOptionsFromFile(File dir, String wsdlName) throws MojoExecutionException
{
+        String[] noOptions = new String[] {};
+        List<File> files = FileUtils.getFiles(dir, wsdlName + WADL_OPTIONS); 
+        if (files.size() <= 0) {
+            return noOptions;
+        }
+        File optionsFile = files.iterator().next();
+        if (optionsFile == null || !optionsFile.exists()) {
+            return noOptions;
+        }
+        try {
+            List<String> lines = FileUtils.readLines(optionsFile);
+            if (lines.size() <= 0) {
+                return noOptions;
+            }
+            return lines.iterator().next().split(" ");
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error reading options from file "
+                                             + optionsFile.getAbsolutePath(), e);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
index c4b536a..eca7157 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
@@ -71,16 +71,11 @@ public class WADL2JavaMojo extends AbstractCodeGeneratorMojo {
     }
 
     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();
+        List<WadlOption> effectiveWsdlOptions = createWadlOptionsFromScansAndExplicitWadlOptions(classesDir);
 
         if (effectiveWsdlOptions.size() == 0) {
             getLog().info("Nothing to generate");
@@ -129,12 +124,22 @@ public class WADL2JavaMojo extends AbstractCodeGeneratorMojo {
      * @return effective WsdlOptions
      * @throws MojoExecutionException
      */
-    private List<WadlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions() 
+    private List<WadlOption> createWadlOptionsFromScansAndExplicitWadlOptions(File
classesDir) 
         throws MojoExecutionException {
         List<WadlOption> effectiveOptions = new ArrayList<WadlOption>();
         
         mergeOptions(effectiveOptions);
         downloadRemoteDocs(effectiveOptions);
+        if (effectiveOptions.isEmpty()) {
+            if (includes == null) {
+                includes = new String[] {
+                    "*.wadl"
+                };
+            }
+            File defaultRoot = wadlRoot != null && wadlRoot.exists() ? wadlRoot :
testWadlRoot;
+            effectiveOptions.addAll(
+                OptionLoader.loadWadlOptionsFromFile(defaultRoot, includes, excludes, null,
classesDir));
+        }
         return effectiveOptions;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
----------------------------------------------------------------------
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
index b707bf6..85989e2 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
@@ -21,9 +21,13 @@ package org.apache.cxf.maven_plugin.wadlto;
 
 import java.io.File;
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.cxf.common.util.ClasspathScanner;
 import org.apache.cxf.common.util.URIParserUtil;
 import org.apache.cxf.maven_plugin.common.DocumentArtifact;
 
@@ -34,11 +38,17 @@ public class WadlOption extends Option {
      */
     String wadl;
 
+    String wadlFileExtension = "wadl";
+    
     /**
-     * Alternatively to the wsdl string an artifact can be specified
+     * Alternatively to the wadl string an artifact can be specified
      */
     DocumentArtifact wadlArtifact;
 
+    public WadlOption() {
+        super();
+    }
+    
     public String getWadl() {
         return wadl;
     }
@@ -83,8 +93,23 @@ public class WadlOption extends Option {
         return file;
     }
     
-    public URI getWadlURI(URI baseURI) {
+    public List<URI> getWadlURIs(URI baseURI, ClassLoader resourceLoader) {
         String wadlLocation = getWadl();
+        if (wadlLocation.contains(".") && !wadlLocation.contains("*")) {
+            return Collections.singletonList(getWadlURI(baseURI, wadlLocation));
+        }
+        List<URI> uris = new LinkedList<URI>();
+        try {
+            for (URL nextLocation : ClasspathScanner.findResources(wadlLocation, wadlFileExtension,
resourceLoader)) {
+                uris.add(getWadlURI(baseURI, nextLocation.toURI().getPath()));
+            }
+        } catch (Exception ex) {
+            // ignore
+        }
+        return uris;
+    }
+    
+    private URI getWadlURI(URI baseURI, String wadlLocation) {
         File wadlFile = new File(wadlLocation);
         return wadlFile.exists() ? wadlFile.toURI() 
             : baseURI.resolve(URIParserUtil.escapeChars(wadlLocation));
@@ -115,7 +140,7 @@ public class WadlOption extends Option {
         return builder.toString();
     }
 
-    public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wsdlURI,
boolean debug) {
+    public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wadlURI,
boolean debug) {
         List<String> list = new ArrayList<String>();
         addIfNotNull(list, outputDirFile, "-d");
         for (String binding : getBindingFiles()) {
@@ -131,7 +156,7 @@ public class WadlOption extends Option {
         addIfTrue(list, isImpl(), "-impl");
         addIfTrue(list, isInterface(), "-interface");
         addList(list, "", false, getExtraargs());
-        list.add(wsdlURI.toString());
+        list.add(wadlURI.toString());
         return list;
     }
 
@@ -167,4 +192,12 @@ public class WadlOption extends Option {
             list.add(key);
         }
     }
+
+    public String getWadlFileExtension() {
+        return wadlFileExtension;
+    }
+
+    public void setWadlFileExtension(String wadlFileExtension) {
+        this.wadlFileExtension = wadlFileExtension;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/3b349d5d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
index e694eb5..f085535 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
@@ -88,7 +88,7 @@ public class SchemaHandler {
             for (String loc : locations) {
                 List<URL> schemaURLs = new LinkedList<URL>();
                 
-                if (loc.lastIndexOf(".") == -1) {
+                if (loc.lastIndexOf(".") == -1 || loc.lastIndexOf('*') != -1) {
                     schemaURLs = ClasspathScanner.findResources(loc, "xsd");
                 } else {
                     URL url = ResourceUtils.getResourceURL(loc, bus);


Mime
View raw message