Author: markt
Date: Mon May 26 17:52:57 2014
New Revision: 1597617

URL: http://svn.apache.org/r1597617
Log:
Implement third part of pull request from Greg Wilkins to make Jasper more 
independent from Tomcat.
Add support for using an existing list of TLDs rather than scanning for them
This closes #4

Added:
    tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java   (with 
props)
Modified:
    tomcat/trunk/java/org/apache/jasper/servlet/JasperInitializer.java
    tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java

Modified: tomcat/trunk/java/org/apache/jasper/servlet/JasperInitializer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JasperInitializer.java?rev=1597617&r1=1597616&r2=1597617&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JasperInitializer.java 
(original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JasperInitializer.java Mon May 
26 17:52:57 2014
@@ -98,7 +98,7 @@ public class JasperInitializer implement
         }
 
         // scan the application for TLDs
-        TldScanner scanner = new TldScanner(context, true, validate, 
blockExternal);
+        TldScanner scanner = newTldScanner(context, true, validate, 
blockExternal);
         try {
             scanner.scan();
         } catch (IOException | SAXException e) {
@@ -114,4 +114,9 @@ public class JasperInitializer implement
                 new TldCache(context, scanner.getUriTldResourcePathMap(),
                         scanner.getTldResourcePathTaglibXmlMap()));
     }
+
+    protected TldScanner newTldScanner(ServletContext context, boolean 
namespaceAware,
+            boolean validate, boolean blockExternal) {
+        return new TldScanner(context, namespaceAware, validate, 
blockExternal);
+    }
 }

Added: tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java?rev=1597617&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java (added)
+++ tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java Mon May 26 
17:52:57 2014
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.servlet;
+
+import java.net.URL;
+import java.util.Collection;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tomcat.util.descriptor.tld.TldResourcePath;
+
+public class TldPreScanned extends TldScanner {
+
+    private final Collection<URL> preScannedURLs;
+
+    public TldPreScanned (ServletContext context, boolean namespaceAware, 
boolean validation,
+            boolean blockExternal, Collection<URL> preScannedTlds) {
+        super(context, namespaceAware, validation, blockExternal);
+        preScannedURLs = preScannedTlds;
+    }
+
+    @Override
+    public void scanJars() {
+        for (URL url : preScannedURLs){
+            String str = url.toExternalForm();
+            int a = str.indexOf("jar:");
+            int b = str.indexOf("!/");
+            if (a >= 0 && b> 0) {
+                String fileUrl = str.substring(a + 4, b);
+                String path = str.substring(b + 2);
+                try {
+                    parseTld(new TldResourcePath(new URL(fileUrl), null, 
path));
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            } else {
+                throw new IllegalStateException("Bad tld url: "+str);
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: tomcat/trunk/java/org/apache/jasper/servlet/TldPreScanned.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java?rev=1597617&r1=1597616&r2=1597617&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java Mon May 26 
17:52:57 2014
@@ -243,13 +243,13 @@ public class TldScanner {
         }
     }
 
-    private void parseTld(String resourcePath) throws IOException, 
SAXException {
+    protected void parseTld(String resourcePath) throws IOException, 
SAXException {
         TldResourcePath tldResourcePath =
                 new TldResourcePath(context.getResource(resourcePath), 
resourcePath);
         parseTld(tldResourcePath);
     }
 
-    private void parseTld(TldResourcePath path) throws IOException, 
SAXException {
+    protected void parseTld(TldResourcePath path) throws IOException, 
SAXException {
         if (tldResourcePathTaglibXmlMap.containsKey(path)) {
             // TLD has already been parsed as a result of processing web.xml
             return;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to