costin      01/06/12 08:19:39

  Modified:    jasper34/generator/org/apache/jasper34/jsptree
                        JspPageInfo.java TagInfoImpl.java TagLibraries.java
  Log:
  Added the page info from JspContext into JspPageInfo.
  
  Still to do: some of the information is specific to jsp->java->class scheme,
  we may need to create another abstraction ? ( for now it's simpler this
  way, there are just few fields and we don't have other generators )
  
  Use ContainerLiaison for callbacks.
  
  Revision  Changes    Path
  1.4       +140 -27   
jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/JspPageInfo.java
  
  Index: JspPageInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/JspPageInfo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JspPageInfo.java  2001/06/09 21:23:32     1.3
  +++ JspPageInfo.java  2001/06/12 15:19:32     1.4
  @@ -72,6 +72,15 @@
   import org.apache.tomcat.util.log.*;
   import org.apache.jasper34.parser.*;
   
  +/* You need to create a pageInfo before calling compiler.
  +   You need to set:
  +      jspFile
  +      mangler
  +      containerLiaison
  +*/
  +
  +
  +
   /**
    * Internal representation of the JSP page, including all collected
    * directives and options. The data is stored in a tree of JspNodes
  @@ -88,7 +97,6 @@
    */
   public class JspPageInfo {
       // XXX public fields will be replaced with API
  -    public String servletClassName;
       
       public String jspServletBase = Constants.JSP_SERVLET_BASE;
       public String serviceMethodName = Constants.SERVICE_METHOD_NAME;
  @@ -121,7 +129,7 @@
       /* support for large files */
       public int stringId = 0;
       public Vector vector = new Vector();
  -    public String dataFile;
  +    private String dataFile;
   
       public TagLibraries libraries;
   
  @@ -134,31 +142,144 @@
       // one tag pool per tag reuse scope.
       public Vector tagPools = new Vector();
       
  -    public JspCompilationContext ctxt;
  +    public ContainerLiaison containerL;
   
  -    public JspPageInfo(JspCompilationContext ctxt) {
  -     this.beanInfo = new BeanRepository(ctxt.getClassLoader());
  -        this.libraries = new TagLibraries(ctxt);
  -        this.ctxt = ctxt;
  -
  -        // FIXME: Is this good enough? (I'm just taking the easy way out - akv)
  -        if (ctxt.getOptions().getLargeFile())
  -            dataFile = ctxt.getOutputDir() + File.separatorChar +
  -                ctxt.getServletPackageName() + "_" +
  -                ctxt.getServletClassName() + ".dat";
  +    private Mangler mangler;
  +    private Options options;
  +    
  +    public JspPageInfo(ContainerLiaison containerL, Options options,
  +                    Mangler mangler)
  +    {
  +     this.options=options;
  +     this.containerL=containerL;
  +     this.beanInfo = new BeanRepository(containerL.getClassLoader());
  +        this.libraries = new TagLibraries(containerL);
  +     this.mangler=mangler;
       }
   
  -    // -------------------- Getters --------------------
  +    // --------------------   --------------------
       // XXX remove all public fields.
   
       public Options getOptions() {
  -     return ctxt.getOptions();
  +     //return containerL.getOptions();
  +     return options;
       }
  +
  +    public Mangler getMangler() {
  +     return mangler;
  +    }
  +
  +    public ContainerLiaison getContainerLiaison() {
  +     return containerL;
  +    }
  +    
  +    // -------------------- Java class info --------------------
  +    // Refactored from JspCompilationContext
  +    // XXX Some is dependent to the Java generator
  +    
  +    boolean errorPage;
  +    String jspFile;
  +    //    String servletClassName;
  +    //    String servletPackageName;
  +    // String servletJavaFileName;
  +    String fullClassName;
  +    String javaEncoding;
       
  -    // -------------------- Setters --------------------
  +    /**
  +     * Are we processing something that has been declared as an
  +     * errorpage? 
  +     */
  +    public boolean isErrorPage() {
  +     return errorPage;
  +    }
  +    
  +    public void setErrorPage(boolean isErrPage) {
  +     errorPage=isErrPage;
  +    }
  +    
  +    /**
  +     * 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 jspFile;
  +    }
  +
  +    public void setJspFile( String s ) {
  +     this.jspFile=s;
  +    }
  +    
  +    // cache
  +    private String servletClassName;
  +    /**
  +     * Just the class name (does not include package name) of the
  +     * generated class. 
  +     */
  +    public String getServletClassName() {
  +     if ( servletClassName==null )
  +         servletClassName=mangler.getClassName(); // servletClassName;
  +     return servletClassName;
  +    }
       
  +//     public void setServletClassName(String servletClassName) {
  +//   this.servletClassName=servletClassName;
  +//     }
  +    
  +    /**
  +     * The package name into which the servlet class is generated. 
  +     */
  +    public String getServletPackageName() {
  +     return mangler.getPackageName(); //servletPackageName;
  +    }
  +
  +    //     public void setServletPackageName(String servletPackageName) {
  +    //       this.servletPackageName=servletPackageName;
  +    //     }
  +    
  +    /**
  +     * Utility method to get the full class name from the package and
  +     * class name. 
  +     */
  +    public String getFullClassName() {
  +     return fullClassName;
  +    }
  +
  +    /**
  +     * Full path name of the Java file into which the servlet is being
  +     * generated. 
  +     */
  +    public String getServletJavaFileName() {
  +     return mangler.getJavaFileName(); // servletJavaFileName;
  +    }
  +
  +    //     public void setServletJavaFileName(String servletJavaFileName) {
  +    //       this.servletJavaFileName=servletJavaFileName;
  +    //     }
  +    
  +    public String  getDataFile() {
  +        // FIXME: Is this good enough? (I'm just taking the easy way out - akv)
  +        if (! getOptions().getLargeFile())
  +         return null;
  +     if( dataFile==null ) {
  +            dataFile = containerL.getOutputDir() + File.separatorChar +
  +                getServletPackageName() + "_" +
  +                getServletClassName() + ".dat";
  +     }
  +     return dataFile;
  +    }
  +
  +    public String getJavaEncoding() {
  +     return javaEncoding;
  +    }
  +
  +    public void setJavaEncoding(String javaEncoding) {
  +     this.javaEncoding=javaEncoding;
  +    }
  +    
  +    // -------------------- JSP info --------------------
  +    
       public final void addGenerator(GeneratorBase gen) throws JasperException {
  -        gen.init(ctxt);
  +        gen.init(containerL);
           generators.addElement(gen);
       }
   
  @@ -189,15 +310,7 @@
       }
   
   
  -    public String getServletClassName() {
  -     return ctxt.getServletClassName();
  -    }
  +    // -------------------- Line number info --------------------
   
  -    public String getServletPackageName() {
  -     return ctxt.getServletPackageName();
  -    }
  -
  -    public boolean isErrorPage() {
  -     return ctxt.isErrorPage();
  -    }
  +    
   }
  
  
  
  1.2       +5 -2      
jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/TagInfoImpl.java
  
  Index: TagInfoImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/TagInfoImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TagInfoImpl.java  2001/06/06 05:53:17     1.1
  +++ TagInfoImpl.java  2001/06/12 15:19:33     1.2
  @@ -85,8 +85,10 @@
       Hashtable methodMaps;
       BeanInfo tagClassInfo;
       Class tagHandlerClass;
  +    ContainerLiaison containerL;
       
  -    public TagInfoImpl(String tagName,
  +    public TagInfoImpl(ContainerLiaison containerL,
  +                    String tagName,
                       String tagClassName,
                       String bodycontent,
                       String infoString,
  @@ -95,6 +97,7 @@
                       TagAttributeInfo[] attributeInfo) {
        super( tagName, tagClassName, bodycontent,
               infoString, taglib, tagExtraInfo, attributeInfo );
  +     this.containerL=containerL;
           this.shortTagName = tagName;
           this.methodMaps = new Hashtable();
       }
  @@ -124,7 +127,7 @@
                       addSetterMethod(pd[i].getName(), pd[i].getWriteMethod());
               }
           } catch (IntrospectionException ex) {
  -            throw new 
JasperException(Constants.getString("jsp.error.unable.to_introspect",
  +            throw new 
JasperException(containerL.getString("jsp.error.unable.to_introspect",
                                                             new Object[] {
                                                                 
tagHandlerClass.getName(),
                                                                 ex.getMessage()
  
  
  
  1.4       +9 -7      
jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/TagLibraries.java
  
  Index: TagLibraries.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/jsptree/TagLibraries.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TagLibraries.java 2001/06/07 06:59:05     1.3
  +++ TagLibraries.java 2001/06/12 15:19:34     1.4
  @@ -74,23 +74,25 @@
   
   /**
    * A container for all tag libraries that have been imported using
  - * the taglib directive. 
  + * the taglib directive.
    *
  + * One instance per web application.
  + *
    * @author Anil K. Vijendran
    * @author Mandar Raje
    */
   public class TagLibraries {
   
       private Hashtable tagLibInfos;
  -    private JspCompilationContext ctxt;
  +    ContainerLiaison containerL;
   
       // used to keep web.xml taglib-locations
       private Hashtable locations=null;
       
  -    public TagLibraries(JspCompilationContext ctxt)
  +    public TagLibraries(ContainerLiaison containerL)
       {
  +     this.containerL=containerL;
           this.tagLibInfos = new Hashtable();
  -     this.ctxt=ctxt;
       }
   
       /** Add a location mapping. The container may do so if it
  @@ -108,7 +110,7 @@
        throws IOException, JasperException
       {
        if( locations==null )
  -         ctxt.readWebXml( this );
  +         containerL.readWebXml( this );
        
        // ignorecase or toLowerCase
        return (String)locations.get( uriIn );
  @@ -130,7 +132,7 @@
   
        TagLibraryInfoImpl tl = new TagLibraryInfoImpl(prefix, uri);
   
  -     ctxt.readTLD(  this, tl, prefix, uri );
  +     containerL.readTLD(  this, tl, prefix, uri );
   
   
        addTagLibrary(prefix, tl);
  @@ -148,7 +150,7 @@
               return false;
           else if (tli.getTag(shortTagName) != null)
               return true;
  -        throw new JasperException(Constants.getString("jsp.error.bad_tag",
  +        throw new JasperException(containerL.getString("jsp.error.bad_tag",
                                                         new Object[] {
                                                             shortTagName,
                                                             prefix
  
  
  

Reply via email to