tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler TldLocationsCache.java
Date Sat, 02 Jun 2001 20:18:23 GMT
remm        01/06/02 13:18:23

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        TldLocationsCache.java
  Log:
  - Update the TLD parsing code so that it doesn't try to directly access the
    filesystem. Instead, it uses the new getResourcePaths call of the
    Servlet API 2.3.
  - Based on a patch submitted by Robert Petersen <robert at orangefood.com>
  
  Revision  Changes    Path
  1.9       +13 -31    jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TldLocationsCache.java
  
  Index: TldLocationsCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TldLocationsCache.java	2001/03/22 17:20:08	1.8
  +++ TldLocationsCache.java	2001/06/02 20:18:23	1.9
  @@ -61,6 +61,7 @@
   import java.util.Hashtable;
   import java.util.Enumeration;
   import java.util.Iterator;
  +import java.util.Set;
   import java.util.jar.*;
   import java.net.JarURLConnection;
   import java.net.*;
  @@ -197,22 +198,15 @@
       private void processJars(ServletContext ctxt)
           throws JasperException
       {
  -        URL libURL = null;
  -        try {
  -            libURL = ctxt.getResource("/WEB-INF/lib");
  -        } catch (MalformedURLException e) {}
   
  -        if ((libURL != null) && "file".equals(libURL.getProtocol())) {
  -            File libFile = new File(libURL.getFile());
  -            if (libFile.exists() && libFile.canRead() &&
  -                libFile.isDirectory()) {
  -                String filenames[] = libFile.list();
  -                for (int i=0; i<filenames.length; i++) {
  -                    if (!filenames[i].endsWith(".jar")) continue;
  -                    tldConfigJar(ctxt, "/WEB-INF/lib/" + filenames[i]);
  -                }
  -            }
  +        Set libSet = ctxt.getResourcePaths("/WEB-INF/lib");
  +        Iterator it = libSet.iterator();
  +        while (it.hasNext()) {
  +            String resourcePath = (String) it.next();
  +            if (resourcePath.endsWith(".jar")) 
  +                tldConfigJar(ctxt, resourcePath);
           }
  +
       }
   
       /**
  @@ -279,23 +273,11 @@
           // Parse the tag library descriptor at the specified resource path
           ParserUtils pu = new ParserUtils();
           TreeNode tld = pu.parseXMLDocument(resourcePath, in);
  -        Iterator taglibs = tld.findChildren("taglib");
  -        int n = 0;
  -        while (taglibs.hasNext()) {
  -            n++;
  -            if (n > 1) {
  -                Constants.message("jsp.error.more.than.one.taglib",
  -                                  new Object[] {resourcePath},
  -                                  Logger.ERROR);
  -                return null;
  -            }
  -            TreeNode taglib = (TreeNode) taglibs.next();
  -            TreeNode uri = taglib.findChild("uri");
  -            if (uri != null) {
  -                String body = uri.getBody();
  -                if (body != null)
  -                    return body;
  -            }
  +        TreeNode uri = tld.findChild("uri");
  +        if (uri != null) {
  +            String body = uri.getBody();
  +            if (body != null)
  +                return body;
           }
           return null; // No <uri> element is present
   
  
  
  

Mime
View raw message