geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1070721 - in /geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment: BundleTldScanner.java JarFileTldScanner.java
Date Tue, 15 Feb 2011 01:23:20 GMT
Author: xuhaihong
Date: Tue Feb 15 01:23:20 2011
New Revision: 1070721

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

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

Modified: geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java?rev=1070721&r1=1070720&r2=1070721&view=diff
==============================================================================
--- geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
(original)
+++ geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
Tue Feb 15 01:23:20 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(tldURL);
             }
         }
-        
+
         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/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java?rev=1070721&r1=1070720&r2=1070721&view=diff
==============================================================================
--- geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
(original)
+++ geronimo/server/branches/3.0-M2/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
Tue Feb 15 01:23:20 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");
@@ -60,26 +60,27 @@ public class JarFileTldScanner {
         try {
             Enumeration<JarEntry> entries = jarFile.entries();
             while (entries.hasMoreElements()) {
-                JarEntry jarEntry = entries.nextElement();
-                if (jarEntry.getName().startsWith("WEB-INF/") && jarEntry.getName().endsWith(".tld"))
{
-                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
+                String jarEntryName = entries.nextElement().getName();
+                if (jarEntryName.startsWith("WEB-INF") && jarEntryName.endsWith(".tld"))
{
+
+                    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(jarEntryName)));
                     if (targetFile != null) {
                         modURLs.add(targetFile.toURI().toURL());
                     }
-                }
-                if (jarEntry.getName().startsWith("WEB-INF/lib/") && jarEntry.getName().endsWith(".jar"))
{
-                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
+                } else if (jarEntryName.startsWith("WEB-INF/lib/") && jarEntryName.endsWith(".jar"))
{
+                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntryName)));
                     List<URL> jarUrls = scanJAR(new JarFile(targetFile), "META-INF/");
                     for (URL jarURL : jarUrls) {
                         modURLs.add(jarURL);
                     }
                 }
             }
-        }
-        catch (IOException ioe) {
+        } catch (IOException ioe) {
             throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName()
+ " " + ioe.getMessage(), ioe);
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName()
+ " " + e.getMessage(), e);
         }
 
@@ -97,7 +98,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 +187,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