geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1070414 - in /geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment: BundleTldScanner.java JarFileTldScanner.java
Date Mon, 14 Feb 2011 09:22:08 GMT
Author: xuhaihong
Date: Mon Feb 14 09:22:07 2011
New Revision: 1070414

URL: http://svn.apache.org/viewvc?rev=1070414&view=rev
Log:
GERONIMO-5810 Limit tld scanning scope in BundleTldScanner

Modified:
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java?rev=1070414&r1=1070413&r2=1070414&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
(original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
Mon Feb 14 09:22:07 2011
@@ -46,24 +46,29 @@ public class BundleTldScanner {
             throw new IllegalArgumentException("Expected DeployableBundle");
         }
         Bundle bundle = ((DeployableBundle) deployable).getBundle();
-        
+
         List<URL> modURLs = new ArrayList<URL>();
-        Enumeration e = bundle.findEntries("WEB-INF/", "*.tld", true);
+        Enumeration<URL> e = bundle.findEntries("WEB-INF/", "*.tld", true);
         if (e != null) {
             while (e.hasMoreElements()) {
-                modURLs.add((URL) e.nextElement());
+                URL tldURL = e.nextElement();
+                String tldPath = tldURL.getPath();
+                if (tldPath.startsWith("/WEB-INF/classes") || tldPath.startsWith("/WEB-INF/lib")
|| (tldPath.startsWith("/WEB-INF/tags") && !tldPath.endsWith("implicit.tld"))) {
+                    continue;
+                }
+                modURLs.add(e.nextElement());
             }
         }
-        
+
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
         PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
-        
+
         BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin, bundle,
"META-INF/", ".tld");
         modURLs.addAll(resourceFinder.find());
-        
+
         bundle.getBundleContext().ungetService(reference);
 
         return modURLs;
     }
- 
+
 }

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java?rev=1070414&r1=1070413&r2=1070414&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
(original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
Mon Feb 14 09:22:07 2011
@@ -38,7 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class JarFileTldScanner {
-    
+
     private static final Logger log = LoggerFactory.getLogger(JarFileTldScanner.class);
 
     /**
@@ -50,7 +50,7 @@ public class JarFileTldScanner {
      */
     public List<URL> scanModule(WebModule webModule) throws DeploymentException {
         log.debug("scanModule( " + webModule.getName() + " ): Entry");
-        
+
         Deployable deployable = webModule.getDeployable();
         if (!(deployable instanceof DeployableJarFile)) {
             throw new IllegalArgumentException("Expected DeployableJarFile");
@@ -61,7 +61,11 @@ public class JarFileTldScanner {
             Enumeration<JarEntry> entries = jarFile.entries();
             while (entries.hasMoreElements()) {
                 JarEntry jarEntry = entries.nextElement();
-                if (jarEntry.getName().startsWith("WEB-INF/") && jarEntry.getName().endsWith(".tld"))
{
+                if(jarEntry.getName().endsWith(".tld")) {
+                    String jarEntryName = jarEntry.getName();
+                    if (jarEntryName.startsWith("WEB-INF/classes") || jarEntryName.startsWith("WEB-INF/lib")
|| (jarEntryName.startsWith("WEB-INF/tags") && !jarEntryName.endsWith("implicit.tld")))
{
+                        continue;
+                    }
                     File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
                     if (targetFile != null) {
                         modURLs.add(targetFile.toURI().toURL());
@@ -97,7 +101,7 @@ public class JarFileTldScanner {
      */
     private List<URL> scanJAR(JarFile jarFile, String prefix) throws DeploymentException
{
         log.debug("scanJAR( " + jarFile.getName() + " ): Entry");
-        
+
         List<URL> jarURLs = new ArrayList<URL>();
         try {
             Enumeration<JarEntry> entries = jarFile.entries();
@@ -186,7 +190,7 @@ public class JarFileTldScanner {
         log.debug("scanDirectory() Exit: URL[" + dirURLs.size() + "]: " + dirURLs.toString());
         return dirURLs;
     }
-    
+
     private static URI createURI(String path) throws URISyntaxException {
         path = path.replaceAll(" ", "%20");
         return new URI(path);



Mime
View raw message