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/resources messages.properties
Date Fri, 24 May 2002 23:57:42 GMT
kinman      02/05/24 16:57:42

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
               jasper2/src/share/org/apache/jasper/resources
                        messages.properties
  Log:
  - Thanks Jan Luehe for the patch.
  
  According to JSP.7.4 ("The Tag Library Descriptor Format"), it is
  illegal for a tag to define scripting variables in both its TLD and
  TagExtraInfo class.
  
  Jasper already enforces this, but its code generator makes separate
  method calls for declaring/synchronizing scripting variables from a
  TLD and those from the TagExtraInfo class, like this:
  
    // Update AT_BEGIN variables
    updateVariableInfos(varInfos, VariableInfo.AT_BEGIN, false);
    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  
  This can be simplified, since if "varInfos" is non-null, "tagVarInfos"
  must be null, and vice-versa.
  
  The proposed patch collapses the above method calls into one.
  
  Also, the code generator makes separate method calls to declare
  AT_BEGIN scripting variables outside the try-finally block, and then
  synchronizing them inside the try-finally block.
  
  Now that try-finally has been flattened, no separate declaration of
  AT_BEGIN variables is required, that is, AT_BEGIN variables can be
  declared when they are first synchronized (after a call to
  doStartTag()), just as NESTED and AT_END variables. This makes
  declareVariableInfos() and declareTagVariableInfos() redundant
  
  As a summary, the attached patch replaces
  
    declareVariableInfos(),
    declareTagVariableInfos(),
    updateVariableInfos(), and
    updateTagVariableInfos()
  
  with a single
  
    syncScriptingVariables().
  
  Revision  Changes    Path
  1.16      +47 -94    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Generator.java	24 May 2002 00:35:41 -0000	1.15
  +++ Generator.java	24 May 2002 23:57:42 -0000	1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
1.15 2002/05/24 00:35:41 kinman Exp $
  - * $Revision: 1.15 $
  - * $Date: 2002/05/24 00:35:41 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
1.16 2002/05/24 23:57:42 kinman Exp $
  + * $Revision: 1.16 $
  + * $Date: 2002/05/24 23:57:42 $
    *
    * ====================================================================
    * 
  @@ -981,11 +981,6 @@
   	    out.println("();");
   	    generateSetters(n, tagHandlerVar, handlerInfo);
   	    
  -	    // Declare AT_BEGIN variables
  -	    declareVariableInfos(varInfos, VariableInfo.AT_BEGIN);
  -	    declareTagVariableInfos(tagVarInfos, n.getTagData(),
  -				    VariableInfo.AT_BEGIN);
  -	    
               if (implementsTryCatchFinally) {
                   out.printil("try {");
                   out.pushIndent();
  @@ -1004,11 +999,10 @@
   	    boolean isBodyTag
   		= BodyTag.class.isAssignableFrom(tagHandlerClass);
   
  -	    // Update AT_BEGIN variables
  -	    updateVariableInfos(varInfos, VariableInfo.AT_BEGIN, false);
  -	    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  -				   VariableInfo.AT_BEGIN, false);
  -
  +	    // Declare and synchronize AT_BEGIN scripting variables
  +	    syncScriptingVariables(varInfos, tagVarInfos, n.getTagData(),
  +				   VariableInfo.AT_BEGIN, true);
  + 
   	    if (n.getBody() != null) {
   		out.printin("if (");
   		out.print(tagEvalVar);
  @@ -1042,14 +1036,13 @@
   		}
   	    }
   
  -	    // Declare and update NESTED variables
  -	    updateVariableInfos(varInfos, VariableInfo.NESTED, true);
  -	    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  -				   VariableInfo.NESTED, true);
  -
  -	    // Update AT_BEGIN variables
  -	    updateVariableInfos(varInfos, VariableInfo.AT_BEGIN, false);
  -	    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  +
  +	    // Declare and synchronize NESTED scripting variables
  +	    syncScriptingVariables(varInfos, tagVarInfos, n.getTagData(),
  + 				   VariableInfo.NESTED, true);
  +
  +	    // Synchronize AT_BEGIN scripting variables
  +	    syncScriptingVariables(varInfos, tagVarInfos, n.getTagData(),
   				   VariableInfo.AT_BEGIN, false);
   	};
   	
  @@ -1074,9 +1067,8 @@
   		out.println(".doAfterBody() == javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN);");
   	    }
   
  -	    // Update AT_BEGIN variables
  -	    updateVariableInfos(varInfos, VariableInfo.AT_BEGIN, false);
  -	    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  +	    // Synchronize AT_BEGIN scripting variables
  +	    syncScriptingVariables(varInfos, tagVarInfos, n.getTagData(),
   				   VariableInfo.AT_BEGIN, false);
   
   	    if (n.getBody() != null) {
  @@ -1125,85 +1117,46 @@
                   out.println(".release();");
   	    }
   
  -	    // Declare and update AT_END variables
  -	    updateVariableInfos(varInfos, VariableInfo.AT_END, true);
  -	    updateTagVariableInfos(tagVarInfos, n.getTagData(),
  +	    // Declare and synchronize AT_END variables
  +	    syncScriptingVariables(varInfos, tagVarInfos, n.getTagData(),
   				   VariableInfo.AT_END, true);
   
   	    n.setEndJavaLine(out.getJavaLine());
   	}
   
  -	private void declareVariableInfos(VariableInfo[] varInfos, int scope) {
  -	    if (varInfos == null)
  +	private void syncScriptingVariables(VariableInfo[] varInfos,
  +					    TagVariableInfo[] tagVarInfos,
  +					    TagData tagData,
  +					    int scope,
  +					    boolean declare) {
  +	    if ((varInfos == null) && (tagVarInfos == null)) {
   		return;
  -	    
  -	    for (int i=0; i<varInfos.length; i++) {
  -		if ((varInfos[i].getScope() == scope)
  -		        && varInfos[i].getDeclare()) {
  -		    out.printin(varInfos[i].getClassName());
  -		    out.print(" ");
  -		    out.print(varInfos[i].getVarName());
  -		    out.println(" = null;");
  -		}
   	    }
  -	}
  -
  -	private void updateVariableInfos(VariableInfo[] varInfos, int scope,
  -					 boolean declare) {
  -	    if (varInfos == null)
  -		return;
  -
  -	    for (int i=0; i<varInfos.length; i++) {
  -		if (varInfos[i].getScope() == scope) {
  -		    if (declare && varInfos[i].getDeclare()) {
  -			out.printin(varInfos[i].getClassName() + " ");
  +	    if (varInfos != null) {
  +		for (int i=0; i<varInfos.length; i++) {
  +		    if (varInfos[i].getScope() == scope) {
  +			if (declare && varInfos[i].getDeclare()) {
  +			    out.printin(varInfos[i].getClassName() + " ");
  +			}
  +			out.printin(varInfos[i].getVarName());
  +			out.print(" = (");
  +			out.print(varInfos[i].getClassName());
  +			out.print(") pageContext.findAttribute(");
  +			out.print(quote(varInfos[i].getVarName()));
  +			out.println(");");
   		    }
  -		    out.printin(varInfos[i].getVarName());
  -		    out.print(" = (");
  -		    out.print(varInfos[i].getClassName());
  -		    out.print(") pageContext.findAttribute(");
  -		    out.print(quote(varInfos[i].getVarName()));
  -		    out.println(");");
   		}
  -	    }		    
  -	}
  -
  -	private void declareTagVariableInfos(TagVariableInfo[] tagVarInfos,
  -					     TagData tagData, int scope) {
  -	    if (tagVarInfos == null)
  -		return;
  -
  -            for (int i=0; i<tagVarInfos.length; i++) {
  -		String name = tagVarInfos[i].getNameGiven();
  -		if (name == null) {
  -		    name = tagData.getAttributeString(
  -                                    tagVarInfos[i].getNameFromAttribute());
  -		}
  -                if ((tagVarInfos[i].getScope() == scope)
  -                        && tagVarInfos[i].getDeclare()) {
  -		    out.printin(tagVarInfos[i].getClassName());
  -		    out.print(" ");
  -		    out.print(name);
  -		    out.println(" = null;");
  -		}
  -	    }
  -	}
  -
  -	private void updateTagVariableInfos(TagVariableInfo[] tagVarInfos,
  -					    TagData tagData, int scope,
  -					    boolean declare) {
  -	    if (tagVarInfos == null)
  -		return;
  -
  -            for (int i=0; i<tagVarInfos.length; i++) {
  -		String name = tagVarInfos[i].getNameGiven();
  -		if (name == null) {
  -		    name = tagData.getAttributeString(
  -                                    tagVarInfos[i].getNameFromAttribute());
  -		}
  -                if (tagVarInfos[i].getScope() == scope) {
  -		    if (declare && tagVarInfos[i].getDeclare()) {
  -			out.printin(tagVarInfos[i].getClassName() + " ");
  +	    } else {
  +		for (int i=0; i<tagVarInfos.length; i++) {
  +		    String name = tagVarInfos[i].getNameGiven();
  +		    if (name == null) {
  +			name = tagData.getAttributeString(
  +                                        tagVarInfos[i].getNameFromAttribute());
  +		    }
  +		    if (tagVarInfos[i].getScope() == scope) {
  +			if (declare && tagVarInfos[i].getDeclare()) {
  +			    out.printin(tagVarInfos[i].getClassName() + " ");
  +			}
   		    }
   		    out.printin(name);
   		    out.print(" = (");
  
  
  
  1.7       +2 -2      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- messages.properties	16 May 2002 20:59:21 -0000	1.6
  +++ messages.properties	24 May 2002 23:57:42 -0000	1.7
  @@ -1,4 +1,4 @@
  -# $Id: messages.properties,v 1.6 2002/05/16 20:59:21 kinman Exp $
  +# $Id: messages.properties,v 1.7 2002/05/24 23:57:42 kinman Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is en_US
  @@ -127,7 +127,7 @@
   jsp.warning.unknown.element.in.attribute=Warning: Unknown element {0} in attribute
   jsp.error.more.than.one.taglib=More than one taglib in the TLD: {0}
   jsp.warning.teiclass.is.null=Could not load TagExtraInfo class {0}: {1}
  -jsp.warning.teiclass.is.nonnull=variable susbelement defined in tld when TagExtraInfo class
{0} is non-null
  +jsp.warning.teiclass.is.nonnull=variable subelement defined in tld when TagExtraInfo class
{0} is non-null
   jsp.error.parse.error.in.TLD=Parse Error in the tag library descriptor: {0}
   jsp.error.unable.to.open.TLD=Unable to open the tag library descriptor: {0}
   jsp.buffer.size.zero=Buffer size <= 0
  
  
  

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


Mime
View raw message