Author: rmannibucau
Date: Wed Jul 18 09:54:16 2012
New Revision: 1362835

URL: http://svn.apache.org/viewvc?rev=1362835&view=rev
Log:
TOMEE-331 exclusions.list in WEB-INF

Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1362835&r1=1362834&r2=1362835&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
 Wed Jul 18 09:54:16 2012
@@ -53,6 +53,8 @@ import org.apache.xbean.finder.UrlSet;
 import org.apache.xbean.finder.archive.Archive;
 import org.apache.xbean.finder.archive.ClassesArchive;
 import org.apache.xbean.finder.archive.JarArchive;
+import org.apache.xbean.finder.filter.Filter;
+import org.apache.xbean.finder.filter.Filters;
 import org.xml.sax.SAXException;
 
 import javax.xml.bind.JAXBException;
@@ -95,7 +97,7 @@ public class DeploymentLoader implements
     private static final String OPENEJB_ALTDD_PREFIX = "openejb.altdd.prefix";
     private static final String ddDir = "META-INF/";
     private boolean scanManagedBeans = true;
-    private static final Collection<String> KNOWN_DESCRIPTORS = 
Arrays.asList("web.xml", "ejb-jar.xml", "openejb-jar.xml", 
"env-entries.properties", "beans.xml", "ra.xml", "application.xml", 
"application-client.xml", "persistence-fragment.xml", "persistence.xml", 
"validation.xml");
+    private static final Collection<String> KNOWN_DESCRIPTORS = 
Arrays.asList("web.xml", "ejb-jar.xml", "openejb-jar.xml", 
"env-entries.properties", "beans.xml", "ra.xml", "application.xml", 
"application-client.xml", "persistence-fragment.xml", "persistence.xml", 
"validation.xml", NewLoaderLogic.EXCLUSION_FILE);
 
     public AppModule load(final File jarFile) throws OpenEJBException {
         // verify we have a valid file
@@ -749,7 +751,7 @@ public class DeploymentLoader implements
         // create web module
         final WebModule webModule = new WebModule(webApp, contextRoot, 
warClassLoader, warFile.getAbsolutePath(), moduleName);
         webModule.setUrls(Arrays.asList(webUrls));
-        webModule.setScannableUrls(filterWebappUrls(webUrls));
+        webModule.setScannableUrls(filterWebappUrls(webUrls, 
descriptors.get(NewLoaderLogic.EXCLUSION_FILE)));
         webModule.getAltDDs().putAll(descriptors);
         webModule.getWatchedResources().add(warPath);
         webModule.getWatchedResources().add(warFile.getAbsolutePath());
@@ -771,10 +773,20 @@ public class DeploymentLoader implements
         return webModule;
     }
 
-    public static List<URL> filterWebappUrls(final URL[] webUrls) {
+    public static List<URL> filterWebappUrls(final URL[] webUrls, URL 
exclusions) {
+        Filter excludeFilter = null;
+        if (exclusions != null) {
+            try {
+                final String[] prefixes = 
NewLoaderLogic.readInputStreamList(exclusions.openStream());
+                excludeFilter = Filters.prefixes(prefixes);
+            } catch (IOException e) {
+                logger.warning("can't read " + exclusions.toExternalForm());
+            }
+        }
+
         UrlSet urls = new UrlSet(webUrls);
         try {
-            urls = applyBuiltinExcludes(urls);
+            urls = applyBuiltinExcludes(urls, null, excludeFilter);
         } catch (MalformedURLException e) {
             return Arrays.asList(webUrls);
         }

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java?rev=1362835&r1=1362834&r2=1362835&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
 Wed Jul 18 09:54:16 2012
@@ -60,7 +60,7 @@ public class NewLoaderLogic {
     public static final String DEFAULT_EXCLUSIONS_ALIAS = "default-list";
     public static final String ADDITIONAL_EXCLUDES = 
SystemInstance.get().getOptions().get("openejb.additional.exclude", (String) 
null);
     public static final String ADDITIONAL_INCLUDE = 
SystemInstance.get().getOptions().get("openejb.additional.include", (String) 
null);
-    private static final String EXCLUSION_FILE = "exclusions.list";
+    public static final String EXCLUSION_FILE = "exclusions.list";
     private static String[] exclusions = null;
 
     public static UrlSet filterArchives(final Filter filter, final ClassLoader 
classLoader, UrlSet urlSet) {
@@ -157,6 +157,10 @@ public class NewLoaderLogic {
     }
 
     public static UrlSet applyBuiltinExcludes(final UrlSet urlSet, final 
Filter includeFilter) throws MalformedURLException {
+        return applyBuiltinExcludes(urlSet, includeFilter, null);
+    }
+
+    public static UrlSet applyBuiltinExcludes(final UrlSet urlSet, final 
Filter includeFilter, final Filter excludeFilter) throws MalformedURLException {
         final Filter filter = Filters.prefixes(getExclusions());
 
         //filter = Filters.optimize(filter, new 
PatternFilter(".*/openejb-.*"));
@@ -167,7 +171,9 @@ public class NewLoaderLogic {
             final File file = URLs.toFile(url);
 
             final String name = filter(file).getName();
-            if (filter.accept(name) && (includeFilter == null || 
!includeFilter.accept(name))) {
+            if (filter.accept(name)
+                    && (includeFilter == null || !includeFilter.accept(name))
+                    && (excludeFilter == null || excludeFilter.accept(name))) {
                 iterator.remove();
             }
         }
@@ -247,7 +253,7 @@ public class NewLoaderLogic {
         return read;
     }
 
-    private static String[] readInputStreamList(final InputStream is) {
+    public static String[] readInputStreamList(final InputStream is) {
 
         final List<String> list = new ArrayList<String>();
         BufferedReader reader = null;


Reply via email to