tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1902 avoid mojarra to fail when CDI is not activated
Date Fri, 12 Aug 2016 13:09:31 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 56ec4be8b -> 112743174


TOMEE-1902 avoid mojarra to fail when CDI is not activated


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

Branch: refs/heads/master
Commit: 112743174ddc842071657e324910444c70056c4d
Parents: 56ec4be
Author: Romain manni-Bucau <rmannibucau@gmail.com>
Authored: Fri Aug 12 15:09:20 2016 +0200
Committer: Romain manni-Bucau <rmannibucau@gmail.com>
Committed: Fri Aug 12 15:09:20 2016 +0200

----------------------------------------------------------------------
 .../tests/jsf/ejb/JSFInjectionTest.java         |  2 ++
 .../tomee/catalina/TomEEWebappClassLoader.java  | 22 +++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/11274317/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/ejb/JSFInjectionTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/ejb/JSFInjectionTest.java
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/ejb/JSFInjectionTest.java
index 54ee332..43c63ab 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/ejb/JSFInjectionTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/ejb/JSFInjectionTest.java
@@ -22,6 +22,7 @@ import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.arquillian.test.api.ArquillianResource;
 import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,6 +42,7 @@ public class JSFInjectionTest extends JSFs {
     public static WebArchive getArchive() {
         return base("jsf-injection-test.war")
                 .addClasses(DummyEJB.class, DummyManagedBean.class)
+                .addAsWebInfResource(new StringAsset("openejb.cdi.activated = false"), "application.properties")
// ensure plume doesn't fail without CDI on
                 .addAsWebResource(new ClassLoaderAsset(
                         JSFInjectionTest.class.getPackage().getName().replace('.', '/').concat("/").concat("dummy.xhtml")),
"dummy.xhtml");
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/11274317/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 fbdd7bd..0ca7a1e 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
@@ -39,6 +39,7 @@ import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.URLs;
 import org.apache.openejb.util.classloader.URLClassLoaderFirst;
 import org.apache.openejb.util.reflection.Reflections;
+import org.apache.webbeans.config.WebBeansContext;
 
 import java.io.File;
 import java.io.IOException;
@@ -50,6 +51,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -461,11 +463,25 @@ public class TomEEWebappClassLoader extends ParallelWebappClassLoader
{
                     it.remove();
                 }
             }
-            if (list.size() == 1) {
-                return Collections.enumeration(list);
-            }
             return Collections.enumeration(list);
         }
+        if ("META-INF/faces-config.xml".equals(name)) { // mojarra workaround
+            try {
+                if (WebBeansContext.currentInstance() == null && Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.jsf.ignore-owb",
"true"))) {
+                    final Collection<URL> list = new HashSet<>(Collections.list(super.getResources(name)));
+                    final Iterator<URL> it = list.iterator();
+                    while (it.hasNext()) {
+                        final String fileName = Files.toFile(it.next()).getName();
+                        if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && fileName.endsWith(".jar"))
{
+                            it.remove();
+                        }
+                    }
+                    return Collections.enumeration(list);
+                }
+            } catch (final Throwable th) {
+                // no-op
+            }
+        }
         return URLClassLoaderFirst.filterResources(name, super.getResources(name));
     }
 


Mime
View raw message