openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1497672 - in /openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone: OwbSWClassLoader.java OwbStandaloneConfiguration.java OwbStandaloneContainer.java
Date Fri, 28 Jun 2013 08:14:13 GMT
Author: rmannibucau
Date: Fri Jun 28 08:14:13 2013
New Revision: 1497672

URL: http://svn.apache.org/r1497672
Log:
OWB-876 virtual resource handling in arquillian - allow to exclude some resources from filtering

Modified:
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbSWClassLoader.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneConfiguration.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbSWClassLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbSWClassLoader.java?rev=1497672&r1=1497671&r2=1497672&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbSWClassLoader.java
(original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbSWClassLoader.java
Fri Jun 28 08:14:13 2013
@@ -35,6 +35,7 @@ import java.net.URLClassLoader;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
@@ -45,12 +46,14 @@ public class OwbSWClassLoader extends UR
     private final String prefix;
     private final boolean useOnlyArchiveResources;
     private final Archive<?> archive;
+    private final Collection<String> useOnlyArchiveResourcesExcludes;
 
-    public OwbSWClassLoader(final ClassLoader parent, final Archive<?> archive, final
boolean useOnlyArchiveResources)
+    public OwbSWClassLoader(final ClassLoader parent, final Archive<?> archive, final
boolean useOnlyArchiveResources, final Collection<String> useOnlyArchiveResourcesExcludes)
     {
         super(new URL[0], parent);
 
         this.useOnlyArchiveResources = useOnlyArchiveResources;
+        this.useOnlyArchiveResourcesExcludes = useOnlyArchiveResourcesExcludes;
         this.archive = archive;
 
         if (WebArchive.class.isInstance(archive))
@@ -92,7 +95,13 @@ public class OwbSWClassLoader extends UR
         if (useOnlyArchiveResources)
         {
             final Enumeration<URL> urls = findResources(name);
-            if (urls.hasMoreElements())
+            if (useOnlyArchiveResourcesExcludes.contains(name))
+            {
+                final Collection<URL> returnValue = new ArrayList<URL>(Collections.list(urls));
+                returnValue.addAll(Collections.list(super.getResources(name)));
+                return Collections.enumeration(returnValue);
+            }
+            else if (urls.hasMoreElements())
             {
                 return urls;
             } // else user probably used the fact the test is embedded

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneConfiguration.java?rev=1497672&r1=1497671&r2=1497672&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneConfiguration.java
(original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneConfiguration.java
Fri Jun 28 08:14:13 2013
@@ -31,6 +31,7 @@ public class OwbStandaloneConfiguration 
      * can be useful when a resource should appear a single time in an app
      */
     private boolean useOnlyArchiveResources = false;
+    private String useOnlyArchiveResourcesExcludes = null;
 
     @Override
     public void validate() throws ConfigurationException
@@ -47,4 +48,14 @@ public class OwbStandaloneConfiguration 
     {
         this.useOnlyArchiveResources = useOnlyArchiveResources;
     }
+
+    public String getUseOnlyArchiveResourcesExcludes()
+    {
+        return useOnlyArchiveResourcesExcludes;
+    }
+
+    public void setUseOnlyArchiveResourcesExcludes(final String useOnlyArchiveResourcesExcludes)
+    {
+        this.useOnlyArchiveResourcesExcludes = useOnlyArchiveResourcesExcludes;
+    }
 }

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java?rev=1497672&r1=1497671&r2=1497672&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
(original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
Fri Jun 28 08:14:13 2013
@@ -35,6 +35,9 @@ import org.jboss.shrinkwrap.descriptor.a
 
 import javax.enterprise.inject.spi.BeanManager;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.logging.Logger;
 
 /**
@@ -57,6 +60,7 @@ public class OwbStandaloneContainer impl
 
     private final ThreadLocal<ClassLoader> originalLoader = new ThreadLocal<ClassLoader>();
     private boolean useOnlyArchiveResources;
+    private Collection<String> useOnlyArchiveResourcesExcludes = new ArrayList<String>();
 
     @Override
     public Class<OwbStandaloneConfiguration> getConfigurationClass()
@@ -79,6 +83,10 @@ public class OwbStandaloneContainer impl
         WebBeansFinder.setSingletonService(singletonService);
 
         useOnlyArchiveResources = owbStandaloneConfiguration.isUseOnlyArchiveResources();
+        if (useOnlyArchiveResources && owbStandaloneConfiguration.getUseOnlyArchiveResourcesExcludes()
!= null)
+        {
+            useOnlyArchiveResourcesExcludes = Arrays.asList(owbStandaloneConfiguration.getUseOnlyArchiveResourcesExcludes().split(","));
+        }
 
     }
 
@@ -107,7 +115,7 @@ public class OwbStandaloneContainer impl
 
         final ClassLoader parentLoader = Thread.currentThread().getContextClassLoader();
         originalLoader.set(parentLoader);
-        Thread.currentThread().setContextClassLoader(new OwbSWClassLoader(parentLoader, archive,
useOnlyArchiveResources));
+        Thread.currentThread().setContextClassLoader(new OwbSWClassLoader(parentLoader, archive,
useOnlyArchiveResources, useOnlyArchiveResourcesExcludes));
 
         try
         {



Mime
View raw message