tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime TagHandlerPool.java
Date Fri, 31 Jan 2003 03:34:45 GMT
kinman      2003/01/30 19:34:45

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
               jasper2/src/share/org/apache/jasper/runtime
                        TagHandlerPool.java
  Log:
  - Fixed 16572, caused by recent change in tag pooling.  Make sure that
    tag pooling works for custom tags used in tag files also.
  
  Revision  Changes    Path
  1.158     +47 -26    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- Generator.java	30 Jan 2003 20:30:51 -0000	1.157
  +++ Generator.java	31 Jan 2003 03:34:44 -0000	1.158
  @@ -318,12 +318,41 @@
       }
   
       /**
  +     * Generates the _jspInit() method for instantiating the tag handler pools.
  +     * For tag file, _jspInit has to be invoked manually, and the ServletConfig
  +     * object explicitly passed.
  +     */
  +    private void generateInit() {
  +
  +        if (ctxt.isTagFile()) {
  +            out.printil("private void _jspInit(ServletConfig config) {");
  +	}
  +	else {
  +            out.printil("public void _jspInit() {");
  +	}
  +
  +        out.pushIndent();
  +        for (int i=0; i<tagHandlerPoolNames.size(); i++) {
  +            out.printin((String) tagHandlerPoolNames.elementAt(i));
  +            out.print(" = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(");
  +            if (ctxt.isTagFile()) {
  +                out.print("config");
  +            }
  +            else {
  +                out.print("getServletConfig()");
  +            }
  +            out.println(");");
  +        }
  +        out.popIndent();
  +        out.printil("}");
  +        out.println();
  +    }
  +
  +    /**
        * Generates the _jspDestroy() method which is responsible for calling the
        * release() method on every tag handler in any of the tag handler pools.
        */
       private void generateDestroy() {
  -	if (tagHandlerPoolNames.size() <= 0)
  -	    return;
   
   	out.printil("public void _jspDestroy() {");
   	out.pushIndent();
  @@ -415,12 +444,6 @@
   	    }
               out.println();
   	}
  - 
  -	// Constructor
  -	if (ctxt.getOptions().isPoolingEnabled()
  -	        && !tagHandlerPoolNames.isEmpty()) {
  -	    generateConstructor(className);
  -	}
       }
   
       /**
  @@ -440,6 +463,7 @@
   
   	if (ctxt.getOptions().isPoolingEnabled()
   	        && !tagHandlerPoolNames.isEmpty()) {
  +	    generateInit();
   	    generateDestroy();
   	}
       }
  @@ -484,6 +508,9 @@
    	// Class variable declarations
           genPreambleClassVariableDeclarations( servletClassName );
    
  +	// Constructor
  +//	generateConstructor(className);
  + 
   	// Methods here
           genPreambleMethods();
    
  @@ -663,19 +690,6 @@
   	out.printil("public " + className + "() {");
   	out.printil("}");
   	out.println();
  -
  -        out.printil("public void _jspInit() {");
  -        out.pushIndent();
  -        for (int i=0; i<tagHandlerPoolNames.size(); i++) {
  -            out.printin((String) tagHandlerPoolNames.elementAt(i));
  -            out.print(" = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(");
  -            out.print("this");
  -            out.println(");");
  -        }
  -        out.popIndent();
  -        out.printil("}");
  -        out.println();
  -
       }
   
       /**
  @@ -2971,7 +2985,7 @@
   					       gen.fragmentHelperClass,
   					       gen.ctxt.getClassLoader(),
   					       tagInfo));
  -	    gen.generateTagHandlerPostamble(  tagInfo );
  +	    gen.generateTagHandlerPostamble(tagInfo);
   	} else {
   	    gen.generatePreamble(page);
   	    gen.generateXmlDeclaration(page);
  @@ -3078,8 +3092,11 @@
               "pageContext.getServletContext();" );
   	out.printil("javax.servlet.ServletConfig config = " +
               "pageContext.getServletConfig();");
  -        
   	out.printil("javax.servlet.jsp.JspWriter out = jspContext.getOut();");
  +	if (ctxt.getOptions().isPoolingEnabled()
  +                && !tagHandlerPoolNames.isEmpty()) {
  +	    out.printil("_jspInit(config);");
  +	}
   	generatePageScopedVariables(tagInfo);
           
        	// Number of tag object that need to be popped
  @@ -3111,6 +3128,10 @@
           out.printil( "} finally {" );
           out.pushIndent();
   	out.printil("((org.apache.jasper.runtime.JspContextWrapper) jspContext).syncEndTagFile();");
  +	if (ctxt.getOptions().isPoolingEnabled()
  +                && !tagHandlerPoolNames.isEmpty()) {
  +	    out.printil("_jspDestroy();");
  +	}
           out.popIndent();
           out.printil( "}" );
   
  
  
  
  1.7       +14 -15    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/TagHandlerPool.java
  
  Index: TagHandlerPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/TagHandlerPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TagHandlerPool.java	22 Jan 2003 20:43:06 -0000	1.6
  +++ TagHandlerPool.java	31 Jan 2003 03:34:45 -0000	1.7
  @@ -63,7 +63,7 @@
   
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.tagext.Tag;
  -import javax.servlet.Servlet;
  +import javax.servlet.ServletConfig;
   import org.apache.jasper.Constants;
   
   /**
  @@ -81,10 +81,10 @@
       // index of next available tag handler
       private int current;
   
  -    public static TagHandlerPool getTagHandlerPool( Servlet jspServlet) {
  +    public static TagHandlerPool getTagHandlerPool( ServletConfig config) {
           TagHandlerPool result=null;
   
  -        String tpClassName=getOption( jspServlet, OPTION_TAGPOOL, null);
  +        String tpClassName=getOption( config, OPTION_TAGPOOL, null);
           if( tpClassName != null ) {
               try {
                   Class c=Class.forName( tpClassName );
  @@ -95,14 +95,14 @@
               }
           }
           if( result==null ) result=new TagHandlerPool();
  -        result.init(jspServlet);
  +        result.init(config);
   
           return result;
       }
   
  -    protected void init( Servlet servlet ) {
  +    protected void init( ServletConfig config ) {
           int maxSize=-1;
  -        String maxSizeS=getOption(servlet, OPTION_MAXSIZE, null);
  +        String maxSizeS=getOption(config, OPTION_MAXSIZE, null);
           if( maxSizeS != null ) {
               try {
                   maxSize=Integer.parseInt(maxSizeS);
  @@ -192,15 +192,14 @@
   	}
       }
   
  -    protected static String getOption( Servlet servlet, String name, String defaultV) {
  -        if( servlet==null ) return defaultV;
  -        if( servlet.getServletConfig() == null ) return defaultV;
  +    protected static String getOption( ServletConfig config, String name, String defaultV)
{
  +        if( config == null ) return defaultV;
   
  -        String value=servlet.getServletConfig().getInitParameter(name);
  +        String value=config.getInitParameter(name);
           if( value != null ) return value;
  -        if( servlet.getServletConfig().getServletContext() ==null )
  +        if( config.getServletContext() ==null )
               return defaultV;
  -        value=servlet.getServletConfig().getServletContext().getInitParameter(name);
  +        value=config.getServletContext().getInitParameter(name);
           if( value!=null ) return value;
           return defaultV;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message