cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5479] Making sure a single classloader is used to load multiple root resources
Date Wed, 11 Jun 2014 10:22:57 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5e673228d -> e3a2b0323


[CXF-5479] Making sure a single classloader is used to load multiple root resources


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

Branch: refs/heads/master
Commit: e3a2b0323de8fd58686dc0db135146d645d4fcc8
Parents: 5e67322
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jun 11 11:22:36 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jun 11 11:22:36 2014 +0100

----------------------------------------------------------------------
 .../maven_plugin/javatowadl/Java2WADLMojo.java  | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e3a2b032/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
index 4b0065c..a52b349 100644
--- a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
+++ b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
@@ -179,6 +179,8 @@ public class Java2WADLMojo extends AbstractMojo {
      */
     private String outputFileExtension;
     
+    private ClassLoader resourceClassLoader;
+    
     public void execute() throws MojoExecutionException {
         List<Class<?>> resourceClasses = loadResourceClasses();
         initClassResourceInfoList(resourceClasses);
@@ -282,19 +284,21 @@ public class Java2WADLMojo extends AbstractMojo {
     
     
     private ClassLoader getClassLoader() throws MojoExecutionException {
-        try {
-            List<?> runtimeClasspathElements = project.getRuntimeClasspathElements();
-            URL[] runtimeUrls = new URL[runtimeClasspathElements.size()];
-            for (int i = 0; i < runtimeClasspathElements.size(); i++) {
-                String element = (String)runtimeClasspathElements.get(i);
-                runtimeUrls[i] = new File(element).toURI().toURL();
+        if (resourceClassLoader == null) {
+            try {
+                List<?> runtimeClasspathElements = project.getRuntimeClasspathElements();
+                URL[] runtimeUrls = new URL[runtimeClasspathElements.size()];
+                for (int i = 0; i < runtimeClasspathElements.size(); i++) {
+                    String element = (String)runtimeClasspathElements.get(i);
+                    runtimeUrls[i] = new File(element).toURI().toURL();
+                }
+                resourceClassLoader = new URLClassLoader(runtimeUrls, Thread.currentThread()
+                    .getContextClassLoader());
+            } catch (Exception e) {
+                throw new MojoExecutionException(e.getMessage(), e);
             }
-            URLClassLoader newLoader = new URLClassLoader(runtimeUrls, Thread.currentThread()
-                .getContextClassLoader());
-            return newLoader;
-        } catch (Exception e) {
-            throw new MojoExecutionException(e.getMessage(), e);
         }
+        return resourceClassLoader;
     }
     private List<Class<?>> loadResourceClasses() throws MojoExecutionException
{
         List<Class<?>> resourceClasses = new ArrayList<Class<?>>(classResourceNames.size());


Mime
View raw message