tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1198591 - in /openejb/trunk/openejb: arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java
Date Sun, 06 Nov 2011 23:39:37 GMT
Author: rmannibucau
Date: Sun Nov  6 23:39:36 2011
New Revision: 1198591

URL: http://svn.apache.org/viewvc?rev=1198591&view=rev
Log:
when we create the webapp classloader we replace the classloader by a wrapper (TomEEWebappClassLoader)
which now uses the created classloader to get resources before the real webapp classloader
which adds its resources only if we didn't find it in our classloader. It aims to avoid to
find twice the same resources because we almost duplicate all the webappclassloader in ours.

Modified:
    openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java
    openejb/trunk/openejb/assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java

Modified: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java?rev=1198591&r1=1198590&r2=1198591&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java
(original)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/Tests.java
Sun Nov  6 23:39:36 2011
@@ -45,7 +45,7 @@ public class Tests {
 
         String output = new String(os.toByteArray(), "UTF-8");
         assertNotNull("Response shouldn't be null", output);
-        assertTrue("Output should contain: " + expectedOutput, output.contains(expectedOutput));
+        assertTrue("Output should contain: " + expectedOutput + " and it is not in '" + output
+ "'", output.contains(expectedOutput));
     }
 
 }

Modified: openejb/trunk/openejb/assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java?rev=1198591&r1=1198590&r2=1198591&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java
(original)
+++ openejb/trunk/openejb/assembly/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java
Sun Nov  6 23:39:36 2011
@@ -9,10 +9,10 @@ import org.apache.tomcat.util.ExceptionU
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
 
 /**
  * @author rmannibucau
@@ -59,23 +59,23 @@ public class TomEEWebappLoader extends W
          * @throws IOException
          */
         @Override public Enumeration<URL> getResources(final String name) throws IOException
{
-            Set<URL> urls = new HashSet<URL>();
+            List<URL> urls = new ArrayList<URL>();
 
             if (webapp instanceof WebappClassLoader && ((WebappClassLoader) webapp).isStarted()
|| webapp.getParent() == null) { // we set a parent so if it is null webapp was detroyed
-                Enumeration<URL> webappClassLoaderResources = webapp.getResources(name);
-                add(urls, webappClassLoaderResources);
-            } else { // app is the parent of webapp so if webapp is ok no need to do it
-                Enumeration<URL> appClassLoaderResources = app.getResources(name);
-                add(urls, appClassLoaderResources);
+                addIfNotExist(urls, app.getResources(name), true);
+                addIfNotExist(urls, webapp.getResources(name), false);
+                return new ArrayEnumeration(urls);
             }
-
-            return new ArrayEnumeration(urls);
+            return app.getResources(name);
         }
 
-        private static void add(Collection<URL> urls, Enumeration<URL> enumUrls)
{
+        private static void addIfNotExist(Collection<URL> urls, Enumeration<URL>
enumUrls, boolean force) {
             try {
                 while (enumUrls.hasMoreElements()) {
-                    urls.add(enumUrls.nextElement());
+                    URL url = enumUrls.nextElement();
+                    if (force || !urls.contains(url)) {
+                        urls.add(url);
+                    }
                 }
             } catch (IllegalStateException ese) {
                 // ignored: if jars are already closed...shutdown for instance



Mime
View raw message