tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [2/2] tomee git commit: ensuring container loader is well set in TomEEEmbeddedMojo otherwise it completely breaks all behavior based on classloader (so things as small as CDI) + few fixes to get right classloader - after ear changes - in tomee-embedded m
Date Fri, 06 Feb 2015 15:58:25 GMT
ensuring container loader is well set in TomEEEmbeddedMojo otherwise it completely breaks all
behavior based on classloader (so things as small as CDI) + few fixes to get right classloader
- after ear changes - in tomee-embedded maven plugin + johnzon 0.5-incubating


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

Branch: refs/heads/develop
Commit: 4127ae53f554ac28e5caacadd8923c56135898f5
Parents: 17369cc
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Fri Feb 6 16:57:59 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Fri Feb 6 16:57:59 2015 +0100

----------------------------------------------------------------------
 .../openejb/core/ParentClassLoaderFinder.java   |  1 -
 .../maven/plugins/TomEEEmbeddedMojo.java        | 34 ++++++++++++++------
 server/openejb-cxf-rs/pom.xml                   |  2 +-
 .../tomee/catalina/TomEEWebappClassLoader.java  |  4 +--
 .../internal/StandardContextCustomizer.java     |  2 +-
 5 files changed, 29 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4127ae53/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
index 1f42be2..dca0d39 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ParentClassLoaderFinder.java
@@ -22,7 +22,6 @@ import org.apache.openejb.loader.SystemInstance;
 
 public interface ParentClassLoaderFinder {
     ClassLoader FALLBACK = OpenEJB.class.getClassLoader();
-    ;
 
     ClassLoader getParentClassLoader(final ClassLoader fallback);
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/4127ae53/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
index ee66cb5..fa22a0c 100644
--- a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
+++ b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
@@ -167,6 +167,9 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
     @Parameter
     private List<String> applications;
 
+    @Parameter
+    private List<String> applicationScopes;
+
     @Parameter(property = "tomee-plugin.skip-current-project", defaultValue = "false")
     private boolean skipCurrentProject;
 
@@ -180,6 +183,7 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
             return;
         }
 
+
         final Properties originalSystProp = new Properties();
         originalSystProp.putAll(System.getProperties());
 
@@ -331,24 +335,36 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
     private ClassLoader createClassLoader(final ClassLoader parent) {
         final List<URL> urls = new ArrayList<>();
         for (final Artifact artifact : (Set<Artifact>) project.getArtifacts()) {
+            final String scope = artifact.getScope();
+            if ((applicationScopes == null && !(Artifact.SCOPE_COMPILE.equals(scope)
|| Artifact.SCOPE_RUNTIME.equals(scope)))
+                    || (applicationScopes != null && !applicationScopes.contains(scope)))
{
+                continue;
+            }
             try {
                 urls.add(artifact.getFile().toURI().toURL());
             } catch (final MalformedURLException e) {
                 getLog().warn("can't use artifact " + artifact.toString());
             }
         }
-        for (final File file : modules) {
-            if (file.exists()) {
-                try {
-                    urls.add(file.toURI().toURL());
-                } catch (final MalformedURLException e) {
-                    getLog().warn("can't use path " + file.getAbsolutePath());
+        if (modules != null) {
+            for (final File file : modules) {
+                if (file.exists()) {
+                    try {
+                        urls.add(file.toURI().toURL());
+                    } catch (final MalformedURLException e) {
+                        getLog().warn("can't use path " + file.getAbsolutePath());
+                    }
+                } else {
+                    getLog().warn("can't find " + file.getAbsolutePath());
                 }
-            } else {
-                getLog().warn("can't find " + file.getAbsolutePath());
             }
         }
-        return new URLClassLoader(urls.toArray(new URL[urls.size()]), parent);
+        return urls.isEmpty() ? parent : new URLClassLoader(urls.toArray(new URL[urls.size()]),
parent) {
+            @Override
+            public boolean equals(final Object obj) {
+                return super.equals(obj) || parent.equals(obj); // fake container loader
since we deploy the classpath normally (see tomee webapp loader)
+            }
+        };
     }
 
     private Configuration getConfig() { // lazy way but it works fine

http://git-wip-us.apache.org/repos/asf/tomee/blob/4127ae53/server/openejb-cxf-rs/pom.xml
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/pom.xml b/server/openejb-cxf-rs/pom.xml
index 473d23f..668ea00 100644
--- a/server/openejb-cxf-rs/pom.xml
+++ b/server/openejb-cxf-rs/pom.xml
@@ -117,7 +117,7 @@
     <dependency> <!-- JohnzonProvider, WadlDocumentMessageBodyWriter and JsrProvider
-->
       <groupId>org.apache.johnzon</groupId>
       <artifactId>johnzon-jaxrs</artifactId>
-      <version>0.2-incubating</version>
+      <version>0.5-incubating</version>
     </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/4127ae53/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java
b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java
index 4f29dff..466d80d 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappClassLoader.java
@@ -94,7 +94,7 @@ public class TomEEWebappClassLoader extends ParallelWebappClassLoader {
         hashCode = construct();
         setJavaseClassLoader(getSystemClassLoader());
         containerClassLoader = ParentClassLoaderFinder.Helper.get();
-        isEar = getParent() != containerClassLoader;
+        isEar = getParent() != null && !getParent().equals(containerClassLoader);
         originalDelegate = getDelegate();
     }
 
@@ -103,7 +103,7 @@ public class TomEEWebappClassLoader extends ParallelWebappClassLoader
{
         hashCode = construct();
         setJavaseClassLoader(getSystemClassLoader());
         containerClassLoader = ParentClassLoaderFinder.Helper.get();
-        isEar = getParent() != containerClassLoader;
+        isEar = getParent() != null && !getParent().equals(containerClassLoader);
         originalDelegate = getDelegate();
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/4127ae53/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java
b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java
index 2c59cdd..e1d4de6 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/internal/StandardContextCustomizer.java
@@ -84,7 +84,7 @@ public class StandardContextCustomizer {
                 }
                 break;
             case Lifecycle.CONFIGURE_START_EVENT:
-                SystemInstance.get().getComponent(TomcatWebAppBuilder.class).setFinderOnContextConfig(StandardContext.class.cast(data),
module.appModule());
+                SystemInstance.get().getComponent(TomcatWebAppBuilder.class).setFinderOnContextConfig(context,
module.appModule());
                 break;
             default:
         }


Mime
View raw message