costin      2002/06/14 13:39:12

  Modified:    jasper2/src/share/org/apache/jasper
                        JspCompilationContext.java JspEngineContext.java
  Removed:     jasper2/src/share/org/apache/jasper CommandLineContext.java
  Log:
  Time to break Jasper2...
  
  This is the first round of refactoring, eliminating the huge duplication
  between JspEngineContext and CLContext.
  
  JspCompilationContext is now a normal bean, with getters and setters. It
  can be overriden or used as is, and it includes all the code that used to
  be in JspEngineContext for mangling.
  
  The main purpose of the class is to deal with paths and resources -
  including mangling, etc.
  
  CommandLineContext is no longer needed - we use the same code as in JspEngineContext.
  I moved some of the extra checks to deal with the lack of RuntimeContext
  when doing CLI compilation.
  
  There are few methods remaining in JspEngineContext - dealing with class
  loading. The goal is to move them back to the base class, and thus
  enable JspC to do the same depenency checking as JspServlet.
  
  ( at the moment JspC can't look for include deps )
  
  Revision  Changes    Path
  1.5       +353 -72   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
  
  Index: JspCompilationContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JspCompilationContext.java        2 Jun 2002 21:36:31 -0000       1.4
  +++ JspCompilationContext.java        14 Jun 2002 20:39:12 -0000      1.5
  @@ -68,141 +68,350 @@
   import org.apache.jasper.compiler.JspReader;
   import org.apache.jasper.compiler.ServletWriter;
   import java.io.IOException;
  +import java.io.File;
  +import java.io.FileNotFoundException;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.net.MalformedURLException;
   import org.apache.jasper.compiler.Compiler;
  +import org.apache.jasper.servlet.JspServletWrapper;
  +import javax.servlet.ServletContext;
  +import org.apache.jasper.compiler.JspRuntimeContext;
   
   /**
    * A place holder for various things that are used through out the JSP
    * engine. This is a per-request/per-context data structure. Some of
    * the instance variables are set at different points.
    *
  + * Most of the path-related stuff is here - mangling names, versions, dirs,
  + * loading resources and dealing with uris. 
  + *
    * @author Anil K. Vijendran
    * @author Harish Prabandham
    * @author Pierre Delisle
  + * @author Costin Manolache
    */
  -public interface JspCompilationContext {
  +public class JspCompilationContext {
   
  -    /**
  -     * The classpath that is passed off to the Java compiler. 
  -     */
  -    public String getClassPath();
  +    protected String servletClassName;
  +    protected String jspUri;
  +    private boolean isErrPage;
  +    protected String servletPackageName = Constants.JSP_PACKAGE_NAME;
  +    protected String servletJavaFileName;
  +    protected String jspPath;
  +    protected String classFileName;
  +    protected String contentType;
  +    protected JspReader reader;
  +    protected ServletWriter writer;
  +    protected Options options;
  +    protected JspServletWrapper jsw;
  +    protected Compiler jspCompiler;
  +    protected String classPath;
  +
  +    protected String baseURI;
  +    protected String outputDir;
  +    protected ServletContext context;
  +    protected URLClassLoader loader;
  +
  +    protected JspRuntimeContext rctxt;
  +
  +    protected int removed = 0;
  +    protected boolean reload = true;
  +    
  +    // jspURI _must_ be relative to the context
  +    protected JspCompilationContext(String jspUri, boolean isErrPage, Options 
options,
  +                                    ServletContext context, JspServletWrapper jsw,
  +                                    JspRuntimeContext rctxt) {
  +        this.jspUri = jspUri;
  +        this.isErrPage = isErrPage;
  +        this.options=options;
  +        this.jsw=jsw;
  +        this.context=context;
  +        
  +        this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
  +        // hack fix for resolveRelativeURI
  +        if (baseURI == null) {
  +            baseURI = "/";
  +        } else if (baseURI.charAt(0) != '/') {
  +            // strip the basde slash since it will be combined with the
  +            // uriBase to generate a file
  +            baseURI = "/" + baseURI;
  +        }
  +        if (baseURI.charAt(baseURI.length() - 1) != '/') {
  +            baseURI += '/';
  +        }
  +        this.rctxt=rctxt;
  +    }
  +
  +    /* ==================== Methods to override ==================== */
       
  +    /** ---------- Class path and loader ---------- */
  +
       /**
  -     * Get the input reader for the JSP text. 
  +     * The classpath that is passed off to the Java compiler. 
        */
  -    public JspReader getReader();
  -    
  +    public String getClassPath() {
  +        return classPath;
  +    }
  +
       /**
  -     * Where is the servlet being generated?
  +     * The classpath that is passed off to the Java compiler. 
        */
  -    public ServletWriter getWriter();
  -    
  +    public void setClassPath(String classPath) {
  +        this.classPath = classPath;
  +    }
  +
       /**
        * What class loader to use for loading classes while compiling
        * this JSP?
        */
  -    public ClassLoader getClassLoader();
  +    public ClassLoader getClassLoader() {
  +        return loader;
  +    }
   
  -    /**
  -     * Are we processing something that has been declared as an
  -     * errorpage? 
  -     */
  -    public boolean isErrorPage();
  +    public void setClassLoader(URLClassLoader loader) {
  +     this.loader = loader;
  +    }
  +
  +    /** ---------- Input/Output  ---------- */
       
       /**
        * The scratch directory to generate code into.
        */
  -    public String getOutputDir();
  -    
  +    public String getOutputDir() {
  +        return outputDir;
  +    }
  +
  +    public void setOutputDir( String s ) {
  +        this.outputDir=s;
  +    }
  +
       /**
  -     * Path of the JSP URI. Note that this is not a file name. This is
  -     * the context rooted URI of the JSP file. 
  +     * Create a "Compiler" object based on some init param data. This
  +     * is not done yet. Right now we're just hardcoding the actual
  +     * compilers that are created. 
        */
  -    public String getJspFile();
  +    public Compiler createCompiler() throws JasperException {
  +        if (jspCompiler != null ) {
  +            return jspCompiler;
  +        }
  +        jspCompiler = new Compiler(this, jsw);
  +        return jspCompiler;
  +    }
  +
  +    /** ---------- Access resources in the webapp ---------- */
  +
  +    /** 
  +     * Get the full value of a URI relative to this compilations context
  +     * uses current file as the base.
  +     */
  +    public String resolveRelativeUri(String uri) {
  +        // sometimes we get uri's massaged from File(String), so check for
  +        // a root directory deperator char
  +        if (uri.startsWith("/") || uri.startsWith(File.separator)) {
  +            return uri;
  +        } else {
  +            return baseURI + uri;
  +        }
  +    }
  +
  +    /**
  +     * Gets a resource as a stream, relative to the meanings of this
  +     * context's implementation.
  +     * @return a null if the resource cannot be found or represented 
  +     *         as an InputStream.
  +     */
  +    public java.io.InputStream getResourceAsStream(String res) {
  +        return context.getResourceAsStream(res);
  +    }
  +
  +
  +    public URL getResource(String res) throws MalformedURLException {
  +        return context.getResource(res);
  +    }
  +
  +    /** 
  +     * Gets the actual path of a URI relative to the context of
  +     * the compilation.
  +     */
  +    public String getRealPath(String path) {
  +        if (context != null) {
  +            return context.getRealPath(path);
  +        }
  +        return path;
  +    }
       
  +    /* ==================== Common implementation ==================== */
  +
       /**
        * Just the class name (does not include package name) of the
        * generated class. 
        */
  -    public String getServletClassName();
  +    public String getServletClassName() {
  +        if (servletClassName != null) {
  +            return servletClassName;
  +        }
  +        int iSep = jspUri.lastIndexOf('/') + 1;
  +        int iEnd = jspUri.length();
  +        StringBuffer modifiedClassName = 
  +            new StringBuffer(jspUri.length() - iSep);
  +     if (!Character.isJavaIdentifierStart(jspUri.charAt(iSep))) {
  +         // If the first char is not a legal Java letter or digit,
  +         // prepend a '$'.
  +         modifiedClassName.append('$');
  +     }
  +        for (int i = iSep; i < iEnd; i++) {
  +            char ch = jspUri.charAt(i);
  +            if (Character.isLetterOrDigit(ch)) {
  +                modifiedClassName.append(ch);
  +            } else if (ch == '.') {
  +                modifiedClassName.append('$');
  +            } else {
  +                modifiedClassName.append(mangleChar(ch));
  +            }
  +        }
  +        servletClassName = modifiedClassName.toString();
  +        return servletClassName;
  +    }
  +
  +    public void setServletClassName(String servletClassName) {
  +        this.servletClassName = servletClassName;
  +    }
       
       /**
  -     * The package name into which the servlet class is generated.
  +     * Path of the JSP URI. Note that this is not a file name. This is
  +     * the context rooted URI of the JSP file. 
        */
  -    public String getServletPackageName();
  +    public String getJspFile() {
  +        return jspUri;
  +    }
   
       /**
  -     * Full path name of the Java file into which the servlet is being
  -     * generated. 
  +     * Are we processing something that has been declared as an
  +     * errorpage? 
        */
  -    public String getServletJavaFileName();
  -
  -    public String getJspPath();
  +    public boolean isErrorPage() {
  +        return isErrPage;
  +    }
   
  -    public String getClassFileName();
  +    public void setErrorPage(boolean isErrPage) {
  +        this.isErrPage = isErrPage;
  +    }
   
       /**
  -     * Are we keeping generated code around?
  +     * Package name for the generated class.
        */
  -    public boolean keepGenerated();
  +    public String getServletPackageName() {
  +        return servletPackageName;
  +    }
   
       /**
  -     * The content type of this JSP.
  -     *
  -     * Content type includes content type and encoding. 
  +     * The package name into which the servlet class is generated.
        */
  -    public String getContentType();
  +    public void setServletPackageName(String servletPackageName) {
  +        this.servletPackageName = servletPackageName;
  +    }
   
       /**
  -     * Get hold of the Options object for this context. 
  +     * Full path name of the Java file into which the servlet is being
  +     * generated. 
        */
  -    public Options getOptions();
  +    public String getServletJavaFileName() {
   
  -    public void setContentType(String contentType);
  +        if (servletJavaFileName != null) {
  +            return servletJavaFileName;
  +        }
  +
  +        String outputDir = getOutputDir();
  +        servletJavaFileName = getServletClassName() + ".java";
  +     if (outputDir != null && !outputDir.equals("")) {
  +            if( outputDir.endsWith("/" ) ) {
  +                servletJavaFileName = outputDir + servletJavaFileName;
  +            } else {
  +                servletJavaFileName = outputDir + "/" + servletJavaFileName;
  +            }
  +        }
  +     return servletJavaFileName;
  +    }
   
  -    public void setReader(JspReader reader);
  -    
  -    public void setWriter(ServletWriter writer);
  -    
  -    void setServletClassName(String servletClassName);
  -    
  -    public void setServletPackageName(String servletPackageName);
  +    public void setServletJavaFileName(String servletJavaFileName) {
  +        this.servletJavaFileName = servletJavaFileName;
  +    }
   
  -    public void setServletJavaFileName(String servletJavaFileName);
  -    
  -    public void setErrorPage(boolean isErrPage);
  +    /**
  +     * Get hold of the Options object for this context. 
  +     */
  +    public Options getOptions() {
  +        return options;
  +    }
   
       /**
  -     * Create a "Compiler" object based on some init param data. This
  -     * is not done yet. Right now we're just hardcoding the actual
  -     * compilers that are created. 
  +     * Path of the JSP relative to the work directory.
        */
  -    public Compiler createCompiler() throws JasperException;
  +    public String getJspPath() {
  +        if (jspPath != null) {
  +            return jspPath;
  +        }
  +        String dirName = getJspFile();
  +        int pos = dirName.lastIndexOf('/');
  +        if (pos > 0) {
  +            dirName = dirName.substring(0, pos + 1);
  +        } else {
  +            dirName = "";
  +        }
  +        jspPath = dirName + getServletClassName() + ".java";
  +        if (jspPath.startsWith("/")) {
  +            jspPath = jspPath.substring(1);
  +        }
  +        return jspPath;
  +    }
   
  +    public String getClassFileName() {
  +        if (classFileName != null) {
  +            return classFileName;
  +        }
  +
  +        String outputDir = getOutputDir();
  +        classFileName = getServletClassName() + ".class";
  +     if (outputDir != null && !outputDir.equals("")) {
  +         classFileName = outputDir + File.separatorChar + classFileName;
  +        }
  +     return classFileName;
  +    }
   
  -    /** 
  -     * Get the full value of a URI relative to this compilations context
  +    /**
  +     * Get the content type of this JSP.
  +     *
  +     * Content type includes content type and encoding.
        */
  -    public String resolveRelativeUri(String uri);
  +    public String getContentType() {
  +        return contentType;
  +    }
  +
  +    public void setContentType(String contentType) {
  +        this.contentType = contentType;
  +    }
   
       /**
  -     * Gets a resource as a stream, relative to the meanings of this
  -     * context's implementation.
  -     * @return a null if the resource cannot be found or represented 
  -     *         as an InputStream.
  +     * Get the input reader for the JSP text. 
        */
  -    public java.io.InputStream getResourceAsStream(String res);
  +    public JspReader getReader() { 
  +        return reader;
  +    }
   
  -    public java.net.URL getResource(String res) throws MalformedURLException;
  +    public void setReader(JspReader reader) {
  +        this.reader = reader;
  +    }
   
  -    /** 
  -     * Gets the actual path of a URI relative to the context of
  -     * the compilation.
  +    /**
  +     * Where is the servlet being generated?
        */
  -    public String getRealPath(String path);
  +    public ServletWriter getWriter() {
  +        return writer;
  +    }
   
  -    static interface Interface1 {
  +    public void setWriter(ServletWriter writer) {
  +        this.writer = writer;
       }
   
       /**
  @@ -219,6 +428,78 @@
        * web.xml or implicitely via the uri tag in the TLD 
        * of a taglib deployed in a jar file (WEB-INF/lib).
        */
  -    public String[] getTldLocation(String uri) throws JasperException;
  +    public String[] getTldLocation(String uri) throws JasperException {
  +     String[] location = 
  +         getOptions().getTldLocationsCache().getLocation(uri);
  +     return location;
  +    }
  +
  +    /**
  +     * Are we keeping generated code around?
  +     */
  +    public boolean keepGenerated() {
  +        return getOptions().getKeepGenerated();
  +    }
  +
  +    // ==================== Removal ==================== 
  +
  +    public void incrementRemoved() {
  +        if (removed > 1) {
  +            jspCompiler.removeGeneratedFiles();
  +            if( rctxt != null )
  +                rctxt.removeWrapper(jspUri);
  +        }
  +        removed++;
  +    }
  +
  +
  +    public boolean isRemoved() {
  +        if (removed > 1 ) {
  +            return true;
  +        }
  +        return false;
  +    }
  +
  +    // ==================== Compile and reload ====================
  +    
  +    public void compile() throws JasperException, FileNotFoundException {
  +        createCompiler();
  +        if (jspCompiler.isOutDated()) {
  +            try {
  +                jspCompiler.compile();
  +                reload = true;
  +            } catch (Exception ex) {
  +                throw new JasperException(
  +                    Constants.getString("jsp.error.unable.compile"),ex);
  +            }
  +        }
  +    }
  +
  +    public boolean isReload() {
  +        return reload;
  +    }
  +
  +    // ==================== Private methods ==================== 
  +    // Mangling, etc.
  +    
  +    /**
  +     * Mangle the specified character to create a legal Java class name.
  +     */
  +    private static final String mangleChar(char ch) {
  +
  +     String s = Integer.toHexString(ch);
  +     int nzeros = 5 - s.length();
  +     char[] result = new char[6];
  +     result[0] = '_';
  +     for (int i = 1; i <= nzeros; i++) {
  +         result[i] = '0';
  +        }
  +     for (int i = nzeros+1, j = 0; i < 6; i++, j++) {
  +         result[i] = s.charAt(j);
  +        }
  +     return new String(result);
  +    }
  +
  +
   }
   
  
  
  
  1.13      +17 -367   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java
  
  Index: JspEngineContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JspEngineContext.java     3 Jun 2002 06:58:38 -0000       1.12
  +++ JspEngineContext.java     14 Jun 2002 20:39:12 -0000      1.13
  @@ -84,12 +84,12 @@
   import org.apache.jasper.Constants;
   import org.apache.jasper.JasperException;
   import org.apache.jasper.compiler.JspReader;
  -import org.apache.jasper.compiler.JspRuntimeContext;
   import org.apache.jasper.compiler.ServletWriter;
   import org.apache.jasper.compiler.Compiler;
   import org.apache.jasper.logging.Logger;
   import org.apache.jasper.servlet.JasperLoader;
   import org.apache.jasper.servlet.JspServletWrapper;
  +import org.apache.jasper.compiler.JspRuntimeContext;
   
   /**
    * The context data and methods required to compile a
  @@ -102,35 +102,14 @@
    * @author Remy Maucherat
    */
   public class JspEngineContext 
  -    implements JspCompilationContext {
  +    extends JspCompilationContext {
   
   
       // ----------------------------------------------------- Instance Variables
   
  -
  -    private JspReader reader;
  -    private ServletWriter writer;
  -    private ServletContext context;
       private URLClassLoader jspLoader;
  -    private Compiler jspCompiler;
  -    private boolean isErrPage;
  -    private String jspUri;
  -    private String jspPath;
  -    private String baseURI;
  -    private String outDir;
       private URL [] outUrls = new URL[1];
       private Class servletClass;
  -    private String servletClassName;
  -    private String classFileName;
  -    private String servletPackageName = Constants.JSP_PACKAGE_NAME;
  -    private String servletJavaFileName;
  -    private String contentType;
  -    private Options options;
  -    private JspRuntimeContext rctxt;
  -    private boolean reload = true;
  -    private int removed = 0;
  -    private JspServletWrapper jsw;
  -
   
       // ------------------------------------------------------------ Constructor
   
  @@ -140,17 +119,9 @@
                               boolean isErrPage, Options options)
           throws JasperException {
   
  -        this.rctxt = rctxt;
  -        this.context = context;
  -        this.jspUri = jspUri;
  -        this.jsw = jsw;
  -        baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
  -        this.isErrPage = isErrPage;
  -        this.options = options;
  -
  +        super( jspUri, isErrPage, options, context, jsw, rctxt );
  +        
           createOutdir();
  -        createCompiler();
  -
       }
   
   
  @@ -164,31 +135,6 @@
           return rctxt.getClassPath();
       }
   
  -
  -    /**
  -     * Get the input reader for the JSP text. 
  -     */
  -    public JspReader getReader() { 
  -        return reader;
  -    }
  -
  -
  -    /**
  -     * Where is the servlet being generated?
  -     */
  -    public ServletWriter getWriter() {
  -        return writer;
  -    }
  -
  -
  -    /**
  -     * Get the ServletContext for the JSP we're processing now. 
  -     */
  -    public ServletContext getServletContext() {
  -        return context;
  -    }
  -
  -
       /**
        * The class loader to use for loading classes while compiling
        * this JSP.
  @@ -197,203 +143,9 @@
           return rctxt.getParentClassLoader();
       }
   
  -
  -    /**
  -     * Return true if the current page is an errorpage.
  -     */
  -    public boolean isErrorPage() {
  -        return isErrPage;
  -    }
  -
  -
  -    /**
  -     * What is the scratch directory we are generating code into?
  -     */
  -    public String getOutputDir() {
  -        return outDir;
  -    }
  -
  -
  -    /**
  -     * Path of the JSP URI. Note that this is not a file name. This is
  -     * the context rooted URI of the JSP file. 
  -     */
  -    public String getJspFile() {
  -        return jspUri;
  -    }
  -
  -
  -    /**
  -     * Path of the JSP relative to the work directory.
  -     */
  -    public String getJspPath() {
  -        if (jspPath != null) {
  -            return jspPath;
  -        }
  -        String dirName = getJspFile();
  -        int pos = dirName.lastIndexOf('/');
  -        if (pos > 0) {
  -            dirName = dirName.substring(0, pos + 1);
  -        } else {
  -            dirName = "";
  -        }
  -        jspPath = dirName + getServletClassName() + ".java";
  -        if (jspPath.startsWith("/")) {
  -            jspPath = jspPath.substring(1);
  -        }
  -        return jspPath;
  -    }
  -
  -
  -    /**
  -     * Just the class name (does not include package name) of the
  -     * generated class. 
  -     */
  -    public String getServletClassName() {
  -        if (servletClassName != null) {
  -            return servletClassName;
  -        }
  -        int iSep = jspUri.lastIndexOf('/') + 1;
  -        int iEnd = jspUri.length();
  -        StringBuffer modifiedClassName = 
  -            new StringBuffer(jspUri.length() - iSep);
  -     if (!Character.isJavaIdentifierStart(jspUri.charAt(iSep))) {
  -         // If the first char is not a legal Java letter or digit,
  -         // prepend a '$'.
  -         modifiedClassName.append('$');
  -     }
  -        for (int i = iSep; i < iEnd; i++) {
  -            char ch = jspUri.charAt(i);
  -            if (Character.isLetterOrDigit(ch)) {
  -                modifiedClassName.append(ch);
  -            } else if (ch == '.') {
  -                modifiedClassName.append('$');
  -            } else {
  -                modifiedClassName.append(mangleChar(ch));
  -            }
  -        }
  -        servletClassName = modifiedClassName.toString();
  -        return servletClassName;
  -    }
  -
  -
  -    /**
  -     * Package name for the generated class.
  -     */
  -    public String getServletPackageName() {
  -        return servletPackageName;
  -    }
  -
  -
  -    /**
  -     * Full path name of the Java file into which the servlet is being
  -     * generated. 
  -     */
  -    public String getServletJavaFileName() {
  -
  -        if (servletJavaFileName != null) {
  -            return servletJavaFileName;
  -        }
  -
  -        String outputDir = getOutputDir();
  -        servletJavaFileName = getServletClassName() + ".java";
  -     if (outputDir != null && !outputDir.equals("")) {
  -         servletJavaFileName = outputDir + servletJavaFileName;
  -        }
  -     return servletJavaFileName;
  -
  -    }
  -
  -
  -    /**
  -     * Are we keeping generated code around?
  -     */
  -    public boolean keepGenerated() {
  -        return options.getKeepGenerated();
  -    }
  -
  -
  -    /**
  -     * Get the content type of this JSP.
  -     *
  -     * Content type includes content type and encoding.
  -     */
  -    public String getContentType() {
  -        return contentType;
  -    }
  -
  -
  -    /**
  -     * Get hold of the Options object for this context. 
  -     */
  -    public Options getOptions() {
  -        return options;
  -    }
  -
  -
  -    public void setContentType(String contentType) {
  -        this.contentType = contentType;
  -    }
  -
  -
  -    public void setReader(JspReader reader) {
  -        this.reader = reader;
  -    }
  -
  -
  -    public void setWriter(ServletWriter writer) {
  -        this.writer = writer;
  -    }
  -
  -
  -    public void setServletClassName(String servletClassName) {
  -        this.servletClassName = servletClassName;
  -    }
  -
  -
  -    public void setServletPackageName(String servletPackageName) {
  -        this.servletPackageName = servletPackageName;
  -    }
  -
  -
  -    public void setServletJavaFileName(String servletJavaFileName) {
  -        this.servletJavaFileName = servletJavaFileName;
  -    }
  -
  -
  -    public void setErrorPage(boolean isErrPage) {
  -        this.isErrPage = isErrPage;
  -    }
  -
  -
  -    public Compiler createCompiler() throws JasperException {
  -
  -        if (jspCompiler != null ) {
  -            return jspCompiler;
  -        }
  -
  -        jspCompiler = new Compiler(this, jsw);
  -        return jspCompiler;
  -
  -    }
  -
  -
  -    public void compile() throws JasperException, FileNotFoundException {
  -
  -        if (jspCompiler.isOutDated()) {
  -            try {
  -                jspCompiler.compile();
  -                reload = true;
  -            } catch (Exception ex) {
  -                throw new JasperException(
  -                    Constants.getString("jsp.error.unable.compile"),ex);
  -            }
  -        }
  -    }
  -
  -
       public Class load() 
  -        throws JasperException, FileNotFoundException {
  +        throws JasperException, FileNotFoundException
  +    {
   
           try {
               if (servletClass == null && !options.getDevelopment()) {
  @@ -405,6 +157,7 @@
                    rctxt.getParentClassLoader(),
                    rctxt.getPermissionCollection(),
                    rctxt.getCodeSource());
  +            
               servletClass = jspLoader.loadClass(
                    getServletPackageName() + "." + getServletClassName());
           } catch (FileNotFoundException ex) {
  @@ -425,95 +178,11 @@
       }
   
   
  -    public boolean isReload() {
  -        return reload;
  -    }
  -
  -
  -    public void incrementRemoved() {
  -        if (removed > 1) {
  -            jspCompiler.removeGeneratedFiles();
  -            rctxt.removeWrapper(jspUri);
  -        }
  -        removed++;
  -    }
  -
  -
  -    public boolean isRemoved() {
  -        if (removed > 1 ) {
  -            return true;
  -        }
  -        return false;
  -    }
  -
  -
  -    /** 
  -     * Get the full value of a URI relative to this compilations context
  -     */
  -    public String resolveRelativeUri(String uri) {
  -        if (uri.charAt(0) == '/') {
  -            return uri;
  -        }
  -        return baseURI + uri;
  -    }
  -
  -
  -    /**
  -     * Gets a resource as a stream, relative to the meanings of this
  -     * context's implementation.
  -     * @return a null if the resource cannot be found or represented 
  -     *         as an InputStream.
  -     */
  -    public java.io.InputStream getResourceAsStream(String res) {
  -        return context.getResourceAsStream(res);
  -    }
  -
  -
  -    public URL getResource(String res) throws MalformedURLException {
  -        return context.getResource(res);
  -    }
  -
  -
  -    /** 
  -     * Gets the actual path of a URI relative to the context of
  -     * the compilation.
  -     */
  -    public String getRealPath(String path) {
  -        if (context != null) {
  -            return context.getRealPath(path);
  -        }
  -        return path;
  -    }
  -
  -
  -    public String[] getTldLocation(String uri) throws JasperException {
  -     String[] location = 
  -         options.getTldLocationsCache().getLocation(uri);
  -     return location;
  -    }
  -
  -
  -    public final String getClassFileName() {
  -
  -        if (classFileName != null) {
  -            return classFileName;
  -        }
  -
  -        String outputDir = getOutputDir();
  -        classFileName = getServletClassName() + ".class";
  -     if (outputDir != null && !outputDir.equals("")) {
  -         classFileName = outputDir + File.separatorChar + classFileName;
  -        }
  -     return classFileName;
  -
  -    }
  -
  -
       // -------------------------------------------------------- Private Methods
   
   
       private void createOutdir() {
  -        File outDir = null;
  +        File outDirF = null;
           try {
               URL outURL = options.getScratchDir().toURL();
               String outURI = outURL.toString();
  @@ -525,36 +194,17 @@
                       + jspUri.substring(0,jspUri.lastIndexOf("/")+1);
               }
               outURL = new URL(outURI);
  -            outDir = new File(outURL.getFile());
  -            if (!outDir.exists()) {
  -                outDir.mkdirs();
  +            outDirF = new File(outURL.getFile());
  +            if (!outDirF.exists()) {
  +                outDirF.mkdirs();
               }
  -            this.outDir = outDir.toString() + File.separator;
  -            outUrls[0] = new URL(outDir.toURL().toString() + File.separator);
  +            this.setOutputDir(  outDirF.toString() + File.separator );
  +            
  +            outUrls[0] = new URL(outDirF.toURL().toString() + File.separator);
           } catch (Exception e) {
               throw new IllegalStateException("No output directory: " +
                                               e.getMessage());
           }
       }
  -
  -
  -    /**
  -     * Mangle the specified character to create a legal Java class name.
  -     */
  -    private static final String mangleChar(char ch) {
  -
  -     String s = Integer.toHexString(ch);
  -     int nzeros = 5 - s.length();
  -     char[] result = new char[6];
  -     result[0] = '_';
  -     for (int i = 1; i <= nzeros; i++) {
  -         result[i] = '0';
  -        }
  -     for (int i = nzeros+1, j = 0; i < 6; i++, j++) {
  -         result[i] = s.charAt(j);
  -        }
  -     return new String(result);
  -    }
  -
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to