tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1376290 - /openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java
Date Wed, 22 Aug 2012 22:24:00 GMT
Author: rmannibucau
Date: Wed Aug 22 22:23:59 2012
New Revision: 1376290

URL: http://svn.apache.org/viewvc?rev=1376290&view=rev
Log:
minor optimization on .faces-config.xml file search with myfaces

Modified:
    openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java

Modified: openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java?rev=1376290&r1=1376289&r2=1376290&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-myfaces/src/main/java/org/apache/tomee/myfaces/TomEEFacesConfigResourceProvider.java
Wed Aug 22 22:23:59 2012
@@ -25,6 +25,7 @@ import org.apache.xbean.finder.UrlSet;
 
 import javax.faces.context.ExternalContext;
 import java.io.File;
+import java.io.FileFilter;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Collection;
@@ -34,13 +35,11 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import java.util.regex.Pattern;
 
 public class TomEEFacesConfigResourceProvider extends DefaultFacesConfigResourceProvider
{
     private static final String META_INF_PREFIX = "META-INF/";
     private static final String FACES_CONFIG_SUFFIX = ".faces-config.xml";
     private static final String FACES_CONFIG_IMPLICIT = "META-INF/faces-config.xml";
-    private static final Pattern FILE_PATTERN = Pattern.compile("^.*" + Pattern.quote(FACES_CONFIG_SUFFIX)
+ "$");
     private static final Map<ClassLoader, Collection<URL>> CACHED_RESOURCES =
new HashMap<ClassLoader, Collection<URL>>();
 
     @Override
@@ -84,8 +83,10 @@ public class TomEEFacesConfigResourcePro
             } else {
                 final File metaInf = new File(file, META_INF_PREFIX);
                 if (metaInf.exists() && metaInf.isDirectory()) {
-                    for (File f : Files.collect(metaInf, FILE_PATTERN)) {
-                        urlSet.add(f.toURI().toURL());
+                    for (File f : Files.collect(metaInf, FacesConfigSuffixFilter.INSTANCE))
{
+                        if (!f.isDirectory()) {
+                            urlSet.add(f.toURI().toURL());
+                        }
                     }
                 }
             }
@@ -106,4 +107,13 @@ public class TomEEFacesConfigResourcePro
     public static void clear(final ClassLoader loader) {
         CACHED_RESOURCES.remove(loader);
     }
+
+    private static class FacesConfigSuffixFilter implements FileFilter {
+        public static final FacesConfigSuffixFilter INSTANCE = new FacesConfigSuffixFilter();
+
+        @Override
+        public boolean accept(final File pathname) {
+            return pathname.isDirectory() || pathname.getName().endsWith(FACES_CONFIG_SUFFIX);
+        }
+    }
 }



Mime
View raw message