yoavs 2004/11/18 06:23:55 Modified: webapps/docs changelog.xml jasper2/src/share/org/apache/jasper JspC.java jasper2/src/share/org/apache/jasper/resources LocalStrings.properties LocalStrings_es.properties LocalStrings_fr.properties LocalStrings_ja.properties Log: Bugzilla 32257: add configurable file name extensions to JspC. Revision Changes Path 1.170 +11 -0 jakarta-tomcat-catalina/webapps/docs/changelog.xml Index: changelog.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v retrieving revision 1.169 retrieving revision 1.170 diff -u -r1.169 -r1.170 --- changelog.xml 17 Nov 2004 20:17:46 -0000 1.169 +++ changelog.xml 18 Nov 2004 14:23:55 -0000 1.170 @@ -52,6 +52,17 @@ </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <update> + <bug>32257</bug>: Added ability to customize JSP file extensions in JspC. (yoavs) + </update> + <update> + Updated JspC usage messages to include recently added configurable parameters. (yoavs) + </update> + </changelog> + </subsection> + <subsection name="Webapps"> <changelog> <update> 1.88 +47 -7 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.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- JspC.java 22 Oct 2004 17:13:27 -0000 1.87 +++ JspC.java 18 Nov 2004 14:23:55 -0000 1.88 @@ -32,6 +32,7 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.util.Stack; import java.util.StringTokenizer; import java.util.Vector; @@ -80,6 +81,7 @@ * @author Danno Ferrin * @author Pierre Delisle * @author Costin Manolache + * @author Yoav Shapira */ public class JspC implements Options { @@ -112,6 +114,8 @@ private static final String SWITCH_DIE = "-die"; private static final String SWITCH_POOLING = "-poolingEnabled"; private static final String SWITCH_ENCODING = "-javaEncoding"; + private static final String SWITCH_ADD_EXTENSION = "-addExtension"; + private static final String SHOW_SUCCESS ="-s"; private static final String LIST_ERRORS = "-l"; private static final int NO_WEBXML = 0; @@ -151,7 +155,13 @@ private String compilerSourceVM = "1.4"; private boolean classDebugInfo = true; - private Vector extensions; + + /** + * The file extensions to be handled as JSP files. + * Default list is .jsp and .jspx. + */ + private List extensions; + private Vector pages = new Vector(); private boolean errorOnUseBeanInvalidClassAttribute = true; @@ -284,6 +294,8 @@ setCompilerSourceVM(nextArg()); } else if (tok.equals(SWITCH_TARGET)) { setCompilerTargetVM(nextArg()); + } else if (tok.equals(SWITCH_ADD_EXTENSION)) { + addExtension(nextArg()); } else { if (tok.startsWith("-")) { throw new JasperException("Unrecognized option: " + tok + @@ -499,7 +511,7 @@ } public TldLocationsCache getTldLocationsCache() { - return tldLocationsCache; + return tldLocationsCache; } /** @@ -537,6 +549,32 @@ } /** + * Returns the list of file extensions + * that are treated as JSP files. + * + * @return The list of extensions + */ + public List getExtensions() { + return extensions; + } + + /** + * Adds the given file extension to the + * list of extensions handled as JSP files. + * + * @param extension The extension to add, e.g. "myjsp" + */ + public void addExtension(final String extension) { + if(extension != null) { + if(extensions == null) { + extensions = new Vector(); + } + + extensions.add(extension); + } + } + + /** * Base dir for the webapp. Used to generate class names and resolve * includes */ @@ -851,11 +889,13 @@ public void scanFiles( File base ) throws JasperException { Stack dirs = new Stack(); dirs.push(base); - if (extensions == null) { - extensions = new Vector(); - extensions.addElement("jsp"); - extensions.addElement("jspx"); + + // Make sure default extensions are always included + if ((getExtensions() == null) || (getExtensions().size() < 2)) { + addExtension("jsp"); + addExtension("jspx"); } + while (!dirs.isEmpty()) { String s = dirs.pop().toString(); File f = new File(s); @@ -870,7 +910,7 @@ String path = f2.getPath(); String uri = path.substring(uriRoot.length()); ext = files[i].substring(files[i].lastIndexOf('.') +1); - if (extensions.contains(ext) || + if (getExtensions().contains(ext) || jspConfig.isJspPage(uri)) { pages.addElement(path); } 1.6 +7 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- LocalStrings.properties 5 Oct 2004 07:24:33 -0000 1.5 +++ LocalStrings.properties 18 Nov 2004 14:23:55 -0000 1.6 @@ -228,6 +228,10 @@ \ -classpath <path> Overrides java.class.path system property\n\ \ -xpoweredBy Add X-Powered-By response header\n\ \ -trimSpaces Trim spaces in template text between actions, directives\n\ +\ -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\ +\ -source <version> Set the -source argument to the compiler (default 1.4)\n\ +\ -target <version> Set the -target argument to the compiler (default 1.4)\n\ +\ -addExtension <ext> Add a file extension for JSP processing, e.g "myjsp"\n\ jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\ \n\ @@ -235,7 +239,7 @@ \ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"\n\ \ "http://java.sun.com/dtd/web-app_2_3.dtd">\n\ <!--\n\ -Automatically created by Tomcat JspC.\n\ +Automatically created by Apache Jakarta Tomcat JspC.\n\ -->\n\ <web-app>\n\ \n @@ -244,7 +248,7 @@ \n jspc.webinc.header=\n\ <!--\n\ -Automatically created by Tomcat JspC.\n\ +Automatically created by Apache Jakarta Tomcat JspC.\n\ Place this fragment in the web.xml before all icon, display-name,\n\ description, distributable, and context-param elements.\n\ -->\n 1.2 +6 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_es.properties Index: LocalStrings_es.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_es.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LocalStrings_es.properties 1 Sep 2004 10:08:48 -0000 1.1 +++ LocalStrings_es.properties 18 Nov 2004 14:23:55 -0000 1.2 @@ -227,6 +227,11 @@ \ -ieplugin <clsid> Java Plugin classid para Internet Explorer\n\ \ -classpath <path> Pasa por alto la propiedad de sistema java.class.path\n\ \ -xpoweredBy Añade cabecera de respuesta X-Powered-By\n\ +\ -trimSpaces Trim spaces in template text between actions, directives\n\ +\ -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\ +\ -source <version> Set the -source argument to the compiler (default 1.4)\n\ +\ -target <version> Set the -target argument to the compiler (default 1.4)\n\ +\ -addExtension <ext> Add a file extension for JSP processing, e.g "myjsp"\n\ jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\ \n\ 1.2 +6 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_fr.properties Index: LocalStrings_fr.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_fr.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LocalStrings_fr.properties 1 Sep 2004 10:08:48 -0000 1.1 +++ LocalStrings_fr.properties 18 Nov 2004 14:23:55 -0000 1.2 @@ -181,6 +181,11 @@ \ -webxml <file> Création d''un fichier web.xml complet pour l''option -webapp.\n\ \ -ieplugin <clsid> Le classid du Plugin Java Plugin pour Internet Explorer\n\ \ -sax2 <driverclassname> Le nom de classe du Driver SAX 2.0 à utiliser\n\ +\ -trimSpaces Trim spaces in template text between actions, directives\n\ +\ -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\ +\ -source <version> Set the -source argument to the compiler (default 1.4)\n\ +\ -target <version> Set the -target argument to the compiler (default 1.4)\n\ +\ -addExtension <ext> Add a file extension for JSP processing, e.g "myjsp"\n\ jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\ \n\ 1.2 +6 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_ja.properties Index: LocalStrings_ja.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/LocalStrings_ja.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LocalStrings_ja.properties 1 Sep 2004 10:08:48 -0000 1.1 +++ LocalStrings_ja.properties 18 Nov 2004 14:23:55 -0000 1.2 @@ -224,6 +224,11 @@ \ -classpath <path> java.class.path\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u4e0a\u66f8\u304d\n\ \ -xpoweredBy X-Powered-By\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u306e\u8ffd\u52a0\n\ \ -trimSpaces \u30a2\u30af\u30b7\u30e7\u30f3\u3084\u6307\u793a\u5b50\u306e\u9593\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c6\u30ad\u30b9\u30c8\u4e2d\u306e\u30b9\u30da\u30fc\u30b9\u3092\u524a\u9664\n\ +\ -trimSpaces Trim spaces in template text between actions, directives\n\ +\ -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\ +\ -source <version> Set the -source argument to the compiler (default 1.4)\n\ +\ -target <version> Set the -target argument to the compiler (default 1.4)\n\ +\ -addExtension <ext> Add a file extension for JSP processing, e.g "myjsp"\n\ jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\ \n\
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]