kinman 2003/08/26 17:47:19 Modified: jasper2/src/share/org/apache/jasper JspC.java jasper2/src/share/org/apache/jasper/compiler JspConfig.java Log: - When precompiling with JSPC, files that mathch the url-pattern specified in jsp-config should be included for compilation. Revision Changes Path 1.58 +12 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- JspC.java 12 Aug 2003 19:40:17 -0000 1.57 +++ JspC.java 27 Aug 2003 00:47:19 -0000 1.58 @@ -776,7 +776,7 @@ * Locate all jsp files in the webapp. Used if no explicit * jsps are specified. */ - public void scanFiles( File base ) { + public void scanFiles( File base ) throws JasperException { Stack dirs = new Stack(); dirs.push(base); if (extensions == null) { @@ -798,12 +798,14 @@ dirs.push(f2.getPath()); //System.out.println("++" + f2.getPath()); } else { + String path = f2.getPath(); + String uri = path.substring(uriRoot.length()); ext = files[i].substring(files[i].lastIndexOf('.') + 1); - if (extensions.contains(ext)) { + if (extensions.contains(ext) || + jspConfig.isJspPage(uri)) { //System.out.println(s + "?" + files[i]); - pages.addElement(s + File.separatorChar - + files[i]); + pages.addElement(path); } else { //System.out.println("not done:" + ext); } @@ -831,6 +833,9 @@ locateUriRoot( firstJspF ); } + if( context==null ) + initServletContext(); + // No explicit page, we'll process all .jsp in the webapp if (pages.size() == 0) { scanFiles( new File( uriRoot )); @@ -845,9 +850,6 @@ throw new JasperException( Localizer.getMessage("jsp.error.jspc.uriroot_not_dir")); } - - if( context==null ) - initServletContext(); initWebXml(); 1.12 +61 -9 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspConfig.java Index: JspConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspConfig.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- JspConfig.java 31 Jul 2003 18:51:16 -0000 1.11 +++ JspConfig.java 27 Aug 2003 00:47:19 -0000 1.12 @@ -208,12 +208,7 @@ } } - /** - * Find a property that best matches the supplied resource. - * @param uri the resource supplied. - * @return a JspProperty if a match is found, null otherwise - */ - public JspProperty findJspProperty(String uri) throws JasperException { + private void init() throws JasperException { if (!initialized) { processWebDotXml(ctxt); @@ -223,6 +218,16 @@ null, null, null); initialized = true; } + } + + /** + * Find a property that best matches the supplied resource. + * @param uri the resource supplied. + * @return a JspProperty indicating the best match, or some default. + */ + public JspProperty findJspProperty(String uri) throws JasperException { + + init(); // JSP Configuration settings do not apply to tag files if (jspProperties == null || uri.endsWith(".tag") @@ -362,6 +367,53 @@ return new JspProperty(isXml, isELIgnored, isScriptingInvalid, pageEncoding, includePreludes, includeCodas); + } + + /** + * To find out if an uri matches an url pattern in jsp config. If so, + * then the uri is a JSP page. This is used primarily for jspc. + */ + public boolean isJspPage(String uri) throws JasperException { + + init(); + if (jspProperties == null) { + return false; + } + + String uriPath = null; + int index = uri.lastIndexOf('/'); + if (index >=0 ) { + uriPath = uri.substring(0, index+1); + } + String uriExtension = null; + index = uri.lastIndexOf('.'); + if (index >=0) { + uriExtension = uri.substring(index+1); + } + + Iterator iter = jspProperties.iterator(); + while (iter.hasNext()) { + + JspPropertyGroup jpg = (JspPropertyGroup) iter.next(); + JspProperty jp = jpg.getJspProperty(); + + String extension = jpg.getExtension(); + String path = jpg.getPath(); + + if (extension == null) { + if (uri.equals(path)) { + // There is an exact match + return true; + } + } else { + if ((path == null || path.equals(uriPath)) && + (extension.equals("*") || extension.equals(uriExtension))) { + // Matches *, *.ext, /p/*, or /p/*.ext + return true; + } + } + } + return false; } static class JspPropertyGroup {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]