Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 70674 invoked from network); 27 Nov 2002 22:55:57 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 27 Nov 2002 22:55:57 -0000 Received: (qmail 10589 invoked by uid 97); 27 Nov 2002 22:56:43 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 10554 invoked by uid 97); 27 Nov 2002 22:56:42 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 10536 invoked by uid 98); 27 Nov 2002 22:56:41 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: JspC enhancement Date: Wed, 27 Nov 2002 14:45:39 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/coreStandardValveContext.java ApplicationFilterChain.java ApplicationFilterFactory.javaDummyRequest.java StandardPipeline.java StandardWrapperValve.java Thread-Index: AcKWT+blhfcPzlH6Sia3C2iWDf0EDAAAXZ2w From: "Brent Jenkins" To: "Tomcat Developers List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I'd like to propose a change to org.apache.jasper.JspC in Tomcat4.1.12. = Specifically, I'd like to introduce a new command line argument: "-pp" to apply a package name prefix and create the package name based = on the jsp directory structure. Tomcat4's "-p" option applies the = package name prefix, but creates all the jsps in the same package. This = leads to "duplicate class" problems if two jsps in different directories = share the same name. BACKGROUND: Our company used to use JspC in Tomcat3 to precompile our JSPs for = deployment. Tomcat3 JspC used to generate package names for the JSPs = that were based on the directory structure of the jsp directory. We've = recently moved to Tomcat4, and this feature apparently didn't carry over = to Tomcat4 codeline. =20 EXAMPLE: Given a directory structure of:=20 /jsp/index.jsp=20 /jsp/employee/index.jsp=20 Tomcat3 using JspC like this: java org.apache.jasper.JspC -d . -p foo.bar=20 would yield package and class names of: package foo.bar.jsp; public class index extends HttpJspBase package foo.bar.jsp.employee; public class index extends HttpJspBase Tomcat4 using JspC like this: java org.apache.jasper.JspC -d . -p foo.bar=20 would yield package and class names of: package foo.bar;=20 public class index_jsp extends HttpJspBase=20 package foo.bar;=20 public class index_jsp extends HttpJspBase=20 We'd get a duplicate class definition error here. Thus.... Tomcat4 using my proposed JspC like this: java org.apache.jasper.JspC -d . -pp foo.bar=20 would yield package and class names of: package foo.bar.jsp;=20 public class index_jsp extends HttpJspBase=20 package foo.bar.jsp.employee;=20 public class index_jsp extends HttpJspBase=20 I'd love to get this committed to the tomcat4 sources. Any suggestions? = I've included the code at the end of the email. Sincerely, Brent Jenkins /* * $Header: = /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.= java,v 1.12.2.1 2002/08/21 17:54:24 kinman Exp $ * $Revision: 1.12.2.1 $ * $Date: 2002/08/21 17:54:24 $ * * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software = itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products = derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * */ package org.apache.jasper; import java.io.*; import java.net.*; import java.util.*; import org.apache.jasper.compiler.JspReader; import org.apache.jasper.compiler.ServletWriter; import org.apache.jasper.compiler.Compiler; import org.apache.jasper.compiler.TldLocationsCache; import org.apache.jasper.servlet.JasperLoader; import org.apache.jasper.servlet.JspCServletContext; import org.apache.jasper.logging.Logger; import org.apache.jasper.logging.JasperLogger; /** * Shell for the jspc compiler. Handles all options associated with the * command line and creates compilation contexts which it then compiles * according to the specified options. * * This version can process files from a _single_ webapp at once, i.e. * a single docbase can be specified. * * It can be used as a Ant task using:
     <taskdef classname=3D"org.apache.jasper.JspC" name=3D"jasper2" =
>
        <classpath>
            <pathelement =
location=3D"${java.home}/../lib/tools.jar"/>
            <fileset dir=3D"${ENV.CATALINA_HOME}/server/lib">
                <include name=3D"*.jar"/>
            </fileset>
            <fileset dir=3D"${ENV.CATALINA_HOME}/common/lib">
                <include name=3D"*.jar"/>
            </fileset>
            <path refid=3D"myjars"/>
         </classpath>
    </taskdef>

    <jasper2 verbose=3D"0"
             package=3D"my.package"
             uriroot=3D"${webapps.dir}/${webapp.name}"
             webXmlFragment=3D"${build.dir}/generated_web.xml"
             =
outputDir=3D"${webapp.dir}/${webapp.name}/WEB-INF/src/my/package" />
 
* * @author Danno Ferrin * @author Pierre Delisle * @author Costin Manolache */ public class JspC implements Options { public static final String DEFAULT_IE_CLASS_ID =3D "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"; public static final String SWITCH_VERBOSE =3D "-v"; public static final String SWITCH_QUIET =3D "-q"; public static final String SWITCH_OUTPUT_DIR =3D "-d"; public static final String SWITCH_OUTPUT_SIMPLE_DIR =3D "-dd"; public static final String SWITCH_IE_CLASS_ID =3D "-ieplugin"; public static final String SWITCH_PACKAGE_NAME =3D "-p"; public static final String SWITCH_PACKAGE_PREFIX_NAME =3D "-pp"; public static final String SWITCH_CLASS_NAME =3D "-c"; public static final String SWITCH_FULL_STOP =3D "--"; public static final String SWITCH_COMPILE =3D "--compile"; public static final String SWITCH_URI_BASE =3D "-uribase"; public static final String SWITCH_URI_ROOT =3D "-uriroot"; public static final String SWITCH_FILE_WEBAPP =3D "-webapp"; public static final String SWITCH_WEBAPP_INC =3D "-webinc"; public static final String SWITCH_WEBAPP_XML =3D "-webxml"; public static final String SWITCH_MAPPED =3D "-mapped"; public static final String SWITCH_DIE =3D "-die"; public static final String SHOW_SUCCESS =3D"-s"; public static final String LIST_ERRORS =3D "-l"; public static final int NO_WEBXML =3D 0; public static final int INC_WEBXML =3D 10; public static final int ALL_WEBXML =3D 20; public static final int DEFAULT_DIE_LEVEL =3D 1; public static final int NO_DIE_LEVEL =3D 0; String classPath=3Dnull; URLClassLoader loader=3Dnull; // future direction //public static final String SWITCH_XML_OUTPUT =3D "-xml"; boolean largeFile =3D false; boolean mappedFile =3D false; int jspVerbosityLevel =3D Logger.INFORMATION; File scratchDir; String ieClassId =3D DEFAULT_IE_CLASS_ID; String targetPackage; String targetPackagePrefix; String targetClassName; String uriBase; String uriRoot; int dieLevel; boolean dieOnExit =3D false; static int die; // I realize it is duplication, but this is for // the static main catch boolean compile=3Dfalse; String compiler=3Dnull; boolean dirset; boolean classDebugInfo=3Dtrue; Vector extensions; Vector pages =3D new Vector(); // Generation of web.xml fragments String webxmlFile; int webxmlLevel; Writer mapout; CharArrayWriter servletout; CharArrayWriter mappingout; static PrintStream log; JspCServletContext context; /** * Cache for the TLD locations */ private TldLocationsCache tldLocationsCache =3D null; private boolean listErrors =3D false; private boolean showSuccess =3D false; public boolean getKeepGenerated() { // isn't this why we are running jspc? return true; } public boolean getLargeFile() { return largeFile; } public boolean isPoolingEnabled() { return true; } /** * Are we supporting HTML mapped servlets? */ public boolean getMappedFile() { return mappedFile; } // Off-line compiler, no need for security manager public Object getProtectionDomain() { return null; } public boolean getSendErrorToClient() { // implied send to System.err return true; } public void setClassDebugInfo( boolean b ) { classDebugInfo=3Db; } public boolean getClassDebugInfo() { // compile with debug info return classDebugInfo; } /** * Background compilation check intervals in seconds */ public int getCheckInterval() { return 300; } /** * Is Jasper being used in development mode? */ public boolean getDevelopment() { return false; } /** * JSP reloading check ? */ public boolean getReloading() { return true; } public String getIeClassId() { return ieClassId; } public int getJspVerbosityLevel() { return jspVerbosityLevel; } public File getScratchDir() { return scratchDir; } public Class getJspCompilerPlugin() { // we don't compile, so this is meanlingless return null; } public String getJspCompilerPath() { // we don't compile, so this is meanlingless return null; } /** * Compiler to use. */ public String getCompiler() { return compiler; } public void setCompiler(String c) { compiler=3Dc; } public TldLocationsCache getTldLocationsCache() { return tldLocationsCache; } public String getJavaEncoding() { return "UTF-8"; } public String getClassPath() { if( classPath !=3D null ) return classPath; return System.getProperty("java.class.path"); } public JspC() { Constants.jasperLog =3D new JasperLogger(); } // -------------------- Options -------------------- public void setClassPath(String s) { classPath=3Ds; } /** Base dir for the webapp. Used to generate class names and * resolve includes */ public void setUriroot( String s ) { if( s=3D=3Dnull ) { uriRoot=3Ds; return; } try { uriRoot=3Dnew File( s ).getCanonicalPath(); } catch( Exception ex ) { uriRoot=3Ds; } } public void setVerbose( int level ) { Constants.jasperLog.setVerbosityLevel(level); } public void setCompile( boolean b ) { compile=3Db; } public void setValidateXml( boolean b ) { org.apache.jasper.xmlparser.ParserUtils.validating=3Db; } public void setOutputDir( String s ) { if( s!=3D null ) { scratchDir=3Dnew File(new File(s).getAbsolutePath()); dirset=3Dtrue; } else { scratchDir=3Dnull; } } public void setPackage( String p ) { targetPackage=3Dp; } public void setPackagePrefix( String pp ) { targetPackagePrefix=3Dpp; } /** Class name of the generated file ( without package ). * Can only be used if a single file is converted. * XXX Do we need this feature ? */ public void setClassName( String p ) { targetClassName=3Dp; } /** File where we generate a web.xml fragment with the class = definitions. */ public void setWebXmlFragment( String s ) { webxmlFile=3Ds; webxmlLevel=3DINC_WEBXML; } /** * Resolve relative path, and create output directories. */ void setupContext(JspCompilationContext clctxt) { // set up a scratch/output dir if none is provided if (scratchDir =3D=3D null) { String temp =3D System.getProperty("java.io.tempdir"); if (temp =3D=3D null) { temp =3D ""; } scratchDir =3D new File(new File(temp).getAbsolutePath()); } String outputDir =3D scratchDir.getAbsolutePath(); if (dirset) { int indexOfSlash =3D clctxt.getJspFile().lastIndexOf('/'); /* String pathName =3D ""; if (indexOfSlash !=3D -1) { pathName =3D clctxt.getJspFile().substring(0, = indexOfSlash); } */ String tmpDir =3D outputDir + File.separatorChar; // + = pathName; File f =3D new File(tmpDir); if (!f.exists()) { f.mkdirs(); } } clctxt.setOutputDir( outputDir ); } void initClassLoader( JspCompilationContext clctxt ) throws = IOException { classPath =3D getClassPath(); ClassLoader parent=3Dthis.getClass().getClassLoader(); ArrayList urls =3D new ArrayList(); File webappBase=3Dnew File(uriRoot); if( parent instanceof URLClassLoader ) { URLClassLoader uL=3D(URLClassLoader) parent; URL path[]=3DuL.getURLs(); for( int i=3D0; i\n\t\t"); servletout.write(thisServletName); servletout.write("\n\t\t"); servletout.write(thisServletName); servletout.write("\n\t\n"); } if (mappingout !=3D null) { = mappingout.write("\n\t\n\t\t"); mappingout.write(thisServletName); mappingout.write("\n\t\t"); mappingout.write(file.replace('\\', '/')); mappingout.write("\n\t\n"); } } public boolean processFile(String file) throws JasperException { try { String jspUri=3Dfile.replace('\\','/'); String baseDir =3D scratchDir.getCanonicalPath(); this.setOutputDir( baseDir + jspUri.substring( 0, = jspUri.lastIndexOf( '/' ) ) ); JspCompilationContext clctxt =3D new JspCompilationContext ( jspUri, false, this, context, null, null ); /* Override the defaults */ if ((targetClassName !=3D null) && (targetClassName.length() = > 0)) { clctxt.setServletClassName(targetClassName); targetClassName =3D null; } if (targetPackage !=3D null) { clctxt.setServletPackageName(targetPackage); } if (targetPackagePrefix !=3D null) { // change the directory name to a package name String fullPackage =3D file.replace('\\','.'); // strip out nasty chars fullPackage =3D fullPackage.replace('-','_'); fullPackage =3D fullPackage.substring(0, = fullPackage.lastIndexOf('.')); fullPackage =3D fullPackage.substring(0, = fullPackage.lastIndexOf('.')); if ( showSuccess ) { log.println( "Building in package: " + = (targetPackagePrefix + fullPackage) ); } clctxt.setServletPackageName(targetPackagePrefix + = fullPackage); } setupContext(clctxt); if( loader=3D=3Dnull ) initClassLoader( clctxt ); clctxt.setClassLoader(loader); clctxt.setClassPath(classPath); Compiler clc =3D clctxt.createCompiler(); this.setOutputDir( baseDir ); if( compile ) { // Generate both .class and .java if( clc.isOutDated() ) { clc.compile(); } } else { // Only generate .java, compilation is separated // Don't compile if the .class file is newer than the = .jsp file if( clc.isOutDated(false) ) { clc.generateJava(); } } // Generate mapping generateWebMapping( file, clctxt ); if ( showSuccess ) { log.println( "Built File: " + file ); } return true; } catch (FileNotFoundException fne) { Constants.message("jspc.error.fileDoesNotExist", new Object[] {fne.getMessage()}, = Logger.WARNING); throw new JasperException( fne ); } catch (Exception e) { Constants.message("jspc.error.generalException", new Object[] {file, e}, Logger.ERROR); if ( listErrors ) { log.println( "Error in File: " + file ); return true; } else if (dieLevel !=3D NO_DIE_LEVEL) { dieOnExit =3D true; } throw new JasperException( e ); } } /** Find the WEB-INF dir by looking up in the directory tree. * This is used if no explicit docbase is set, but only files. * XXX Maybe we should require the docbase. */ private void locateUriRoot( File f ) { String tUriBase =3D uriBase; if (tUriBase =3D=3D null) { tUriBase =3D "/"; } try { if (f.exists()) { f =3D new File(f.getCanonicalPath()); while (f !=3D null) { File g =3D new File(f, "WEB-INF"); if (g.exists() && g.isDirectory()) { uriRoot =3D f.getCanonicalPath(); uriBase =3D tUriBase; Constants.message("jspc.implicit.uriRoot", new Object[] { uriRoot }, Logger.INFORMATION); break; } if (f.exists() && f.isDirectory()) { tUriBase =3D "/" + f.getName() + "/" + tUriBase; } String fParent =3D f.getParent(); if (fParent =3D=3D null) { f =3D new File(args[argPos]); fParent =3D f.getParent(); if (fParent =3D=3D null) { fParent =3D File.separator; } uriRoot =3D new = File(fParent).getCanonicalPath(); uriBase =3D "/"; break; } else { f =3D new File(fParent); } // If there is no acceptible candidate, uriRoot will // remain null to indicate to the CompilerContext to // use the current working/user dir. } try { File froot =3D new File(uriRoot); uriRoot =3D froot.getCanonicalPath(); } catch (IOException ioe) { // if we cannot get the base, leave it null } } } catch (IOException ioe) { // since this is an optional default and a null value // for uriRoot has a non-error meaning, we can just // pass straight through } } /** Locate all jsp files in the webapp. Used if no explicit * jsps are specified. */ public void scanFiles( File base ) { Stack dirs =3D new Stack(); dirs.push(base); if (extensions =3D=3D null) { extensions =3D new Vector(); extensions.addElement("jsp"); } while (!dirs.isEmpty()) { String s =3D dirs.pop().toString(); //System.out.println("--" + s); File f =3D new File(s); if (f.exists() && f.isDirectory()) { String[] files =3D f.list(); String ext; for (int i =3D 0; i < files.length; i++) { File f2 =3D new File(s, files[i]); //System.out.println(":" + f2.getPath()); if (f2.isDirectory()) { dirs.push(f2.getPath()); //System.out.println("++" + f2.getPath()); } else { ext =3D files[i].substring( = files[i].lastIndexOf('.') + 1); if (extensions.contains(ext)) { //System.out.println(s + "?" + files[i]); pages.addElement( s + File.separatorChar + = files[i]); } else { //System.out.println("not done:" + = ext); } } } } } } private void initWebXml() { try { if (webxmlLevel >=3D INC_WEBXML) { File fmapings =3D new File(webxmlFile); mapout =3D new FileWriter(fmapings); servletout =3D new CharArrayWriter(); mappingout =3D new CharArrayWriter(); } else { mapout =3D null; servletout =3D null; mappingout =3D null; } if (webxmlLevel >=3D ALL_WEBXML) { mapout.write(Constants.getString("jspc.webxml.header")); } else if (webxmlLevel>=3D INC_WEBXML) { mapout.write(Constants.getString("jspc.webinc.header")); } } catch (IOException ioe) { mapout =3D null; servletout =3D null; mappingout =3D null; } } private void completeWebXml() { if (mapout !=3D null) { try { servletout.writeTo(mapout); mappingout.writeTo(mapout); if (webxmlLevel >=3D ALL_WEBXML) { = mapout.write(Constants.getString("jspc.webxml.footer")); } else if (webxmlLevel >=3D INC_WEBXML) { = mapout.write(Constants.getString("jspc.webinc.footer")); } mapout.close(); } catch (IOException ioe) { // noting to do if it fails since we are done with it } } } private void initServletContext() { try { context =3Dnew JspCServletContext (new PrintWriter(System.out), new URL("file:" + uriRoot.replace('\\','/') + '/')); tldLocationsCache =3D new TldLocationsCache(context); } catch (MalformedURLException me) { System.out.println("**" + me); } } public void execute() throws JasperException { if( uriRoot=3D=3Dnull ) { if( pages.size() =3D=3D 0 ) { throw new JasperException( "No uriRoot or files"); } String firstJsp=3D(String)pages.elementAt( 0 ); locateUriRoot( new File( firstJsp ) ); } // No explicit page, we'll process all .jsp in the webapp if( pages.size() =3D=3D 0 ) { scanFiles( new File( uriRoot )); } File uriRootF =3D new File(uriRoot); if (!uriRootF.exists() || !uriRootF.isDirectory()) { throw new = JasperException(Constants.getString("jsp.error.jspc.uriroot_not_dir")); } if( context=3D=3Dnull ) initServletContext(); initWebXml(); Enumeration e =3D pages.elements(); while (e.hasMoreElements()) { String nextjsp =3D e.nextElement().toString(); try { File fjsp =3D new File(nextjsp); if (!fjsp.exists()) { Constants.message("jspc.error.fileDoesNotExist", new Object[] {fjsp}, = Logger.WARNING); continue; } String s =3D fjsp.getCanonicalPath(); //System.out.println("**" + s); if (s.startsWith(uriRoot)) { nextjsp =3D s.substring(uriRoot.length()); } } catch (IOException ioe) { // if we got problems dont change the file name } if (nextjsp.startsWith("." + File.separatorChar)) { nextjsp =3D nextjsp.substring(2); } processFile(nextjsp); } completeWebXml(); } // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CLI = support =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D int argPos; // value set by beutifully obsfucscated java boolean fullstop =3D false; String args[]; public static void main(String arg[]) { if (arg.length =3D=3D 0) { System.out.println(Constants.getString("jspc.usage")); } else { try { log=3DSystem.out; JspC jspc =3D new JspC(); jspc.setArgs(arg); jspc.execute(); } catch (JasperException je) { System.err.print("error:"); System.err.println(je.getMessage()); if (die !=3D NO_DIE_LEVEL) { System.exit(die); } } } } private String nextArg() { if ((argPos >=3D args.length) || (fullstop =3D SWITCH_FULL_STOP.equals(args[argPos]))) { return null; } else { return args[argPos++]; } } private String nextFile() { if (fullstop) argPos++; if (argPos >=3D args.length) { return null; } else { return args[argPos++]; } } void setArgs(String[] arg) { args =3D arg; String tok; int verbosityLevel =3D Logger.WARNING; dieLevel =3D NO_DIE_LEVEL; die =3D dieLevel; while ((tok =3D nextArg()) !=3D null) { if (tok.equals(SWITCH_QUIET)) { verbosityLevel =3D Logger.WARNING; } else if (tok.equals(SWITCH_VERBOSE)) { verbosityLevel =3D Logger.INFORMATION; } else if (tok.startsWith(SWITCH_VERBOSE)) { try { verbosityLevel =3D = Integer.parseInt(tok.substring(SWITCH_VERBOSE.length())); } catch (NumberFormatException nfe) { log.println( "Verbosity level " + tok.substring(SWITCH_VERBOSE.length()) + " is not valid. Option ignored."); } } else if (tok.equals(SWITCH_OUTPUT_DIR)) { tok =3D nextArg(); setOutputDir( tok ); } else if (tok.equals(SWITCH_OUTPUT_SIMPLE_DIR)) { tok =3D nextArg(); if (tok !=3D null) { scratchDir =3D new File(new = File(tok).getAbsolutePath()); dirset =3D false; } else { // either an in-java call with an explicit null // or a "-d --" sequence should cause this, // which would mean default handling /* no-op */ scratchDir =3D null; } } else if (tok.equals(SWITCH_PACKAGE_NAME)) { targetPackage =3D nextArg(); } else if (tok.equals(SWITCH_PACKAGE_PREFIX_NAME)) { targetPackagePrefix =3D nextArg(); } else if (tok.equals(SWITCH_COMPILE)) { compile=3Dtrue; } else if (tok.equals(SWITCH_CLASS_NAME)) { targetClassName =3D nextArg(); } else if (tok.equals(SWITCH_URI_BASE)) { uriBase=3DnextArg(); } else if (tok.equals(SWITCH_URI_ROOT)) { setUriroot( nextArg()); } else if (tok.equals(SWITCH_FILE_WEBAPP)) { setUriroot( nextArg()); } else if ( tok.equals( SHOW_SUCCESS ) ) { showSuccess =3D true; } else if ( tok.equals( LIST_ERRORS ) ) { listErrors =3D true; } else if (tok.equals(SWITCH_WEBAPP_INC)) { webxmlFile =3D nextArg(); if (webxmlFile !=3D null) { webxmlLevel =3D INC_WEBXML; } } else if (tok.equals(SWITCH_WEBAPP_XML)) { webxmlFile =3D nextArg(); if (webxmlFile !=3D null) { webxmlLevel =3D ALL_WEBXML; } } else if (tok.equals(SWITCH_MAPPED)) { mappedFile =3D true; } else if (tok.startsWith(SWITCH_DIE)) { try { dieLevel =3D Integer.parseInt( tok.substring(SWITCH_DIE.length())); } catch (NumberFormatException nfe) { dieLevel =3D DEFAULT_DIE_LEVEL; } die =3D dieLevel; } else { //pushBackArg(); if (!fullstop) { argPos--; } // Not a recognized Option? Start treting them as JSP = Pages break; } } // Add all extra arguments to the list of files while( true ) { String file =3D nextFile(); if( file=3D=3Dnull ) break; pages.addElement( file ); } Constants.jasperLog.setVerbosityLevel(verbosityLevel); } /** * allows user to set where the log goes other than System.out * @param log */ public static void setLog( PrintStream log ) { JspC.log =3D log; } } -- To unsubscribe, e-mail: For additional commands, e-mail: