kinman 2003/01/28 14:06:28 Modified: jasper2/src/share/org/apache/jasper/compiler Collector.java Generator.java jasper2/src/share/org/apache/jasper/runtime JspContextWrapper.java Log: - Encapsulate scope variable synchromizations in JspContextWrapper. - Aliases should not generate scripting variables. Revision Changes Path 1.8 +5 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Collector.java Index: Collector.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Collector.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Collector.java 30 Oct 2002 17:41:22 -0000 1.7 +++ Collector.java 28 Jan 2003 22:06:27 -0000 1.8 @@ -188,8 +188,9 @@ if( (n instanceof Node.CustomTag) && !hasScriptingVars) { Node.CustomTag ct = (Node.CustomTag)n; - hasScriptingVars = ct.getVariableInfos().length > 0 - || ct.getTagVariableInfos().length > 0; + hasScriptingVars = ct.getTagFileInfo() != null && + (ct.getVariableInfos().length > 0 || + ct.getTagVariableInfos().length > 0); } // Record if the tag element and its body contains any scriptlet. 1.156 +32 -18 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.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- Generator.java 28 Jan 2003 01:42:57 -0000 1.155 +++ Generator.java 28 Jan 2003 22:06:27 -0000 1.156 @@ -291,6 +291,10 @@ varName = n.getTagData().getAttributeString( tagVarInfos[i].getNameFromAttribute()); } + else if (tagVarInfos[i].getNameFromAttribute() != null) { + // alias + continue; + } String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel(); if (!vars.contains(tmpVarName)) { @@ -1793,8 +1797,7 @@ // Copy virtual page scope of tag file to page scope of invoking // page - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.NESTED);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.AT_BEGIN);"); + out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();"); // Invoke fragment String varReaderAttr = n.getTextAttribute("varReader"); @@ -1813,8 +1816,7 @@ out.pushIndent(); // Copy page scope of invoking page back to virtual page scope of // tag file - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyPageToTagScope(javax.servlet.jsp.tagext.VariableInfo.NESTED);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyPageToTagScope(javax.servlet.jsp.tagext.VariableInfo.AT_BEGIN);"); + out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncAfterInvoke();"); out.popIndent(); out.printil("}"); @@ -1841,8 +1843,7 @@ // Copy virtual page scope of tag file to page scope of invoking // page - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.NESTED);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.AT_BEGIN);"); + out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();"); // Invoke body String varReaderAttr = n.getTextAttribute("varReader"); @@ -1863,8 +1864,7 @@ out.pushIndent(); // Copy page scope of invoking page back to virtual page scope of // tag file - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyPageToTagScope(javax.servlet.jsp.tagext.VariableInfo.NESTED);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).copyPageToTagScope(javax.servlet.jsp.tagext.VariableInfo.AT_BEGIN);"); + out.printil("((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncAfterInvoke();"); out.popIndent(); out.printil("}"); @@ -2229,6 +2229,10 @@ varName = n.getTagData().getAttributeString( tagVarInfo.getNameFromAttribute()); } + else if (tagVarInfo.getNameFromAttribute() != null) { + // alias + continue; + } out.printin(tagVarInfo.getClassName()); out.print(" "); out.print(varName); @@ -2280,6 +2284,10 @@ varName = n.getTagData().getAttributeString( tagVarInfos[i].getNameFromAttribute()); } + else if (tagVarInfos[i].getNameFromAttribute() != null) { + // alias + continue; + } String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel(); out.printin(tmpVarName); @@ -2329,6 +2337,10 @@ varName = n.getTagData().getAttributeString( tagVarInfos[i].getNameFromAttribute()); } + else if (tagVarInfos[i].getNameFromAttribute() != null) { + // alias + continue; + } String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel(); out.printin(varName); @@ -2370,6 +2382,10 @@ name = n.getTagData().getAttributeString( tagVarInfos[i].getNameFromAttribute()); } + else if (tagVarInfos[i].getNameFromAttribute() != null) { + // alias + continue; + } out.printin(name); out.print(" = ("); out.print(tagVarInfos[i].getClassName()); @@ -2485,8 +2501,7 @@ private String generateAliasMap(Node.CustomTag n, String tagHandlerVar) throws JasperException { - TagInfo tagInfo = n.getTagInfo(); - TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos(); + TagVariableInfo[] tagVars = n.getTagVariableInfos(); String aliasMapVar = null; boolean aliasSeen = false; @@ -2527,7 +2542,7 @@ String aliasMapVar= generateAliasMap(n, tagHandlerVar); out.printin(tagHandlerVar); if (aliasMapVar == null) { - out.print(".setJspContext(pageContext);"); + out.println(".setJspContext(pageContext);"); } else { out.print(".setJspContext(pageContext, "); @@ -3085,9 +3100,7 @@ out.popIndent(); out.printil( "} finally {" ); out.pushIndent(); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.AT_BEGIN);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) jspContext).copyTagToPageScope(javax.servlet.jsp.tagext.VariableInfo.AT_END);"); - out.printil("((org.apache.jasper.runtime.JspContextWrapper) jspContext).restoreNestedVariables();"); + out.printil("((org.apache.jasper.runtime.JspContextWrapper) jspContext).syncEndTagFile();"); out.popIndent(); out.printil( "}" ); @@ -3188,7 +3201,8 @@ boolean aliasSeen = false; TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos(); for (int i=0; i<tagVars.length; i++) { - if (tagVars[i].getNameFromAttribute() != null) { + if (tagVars[i].getNameFromAttribute() != null && + tagVars[i].getNameGiven() != null) { aliasSeen = true; break; } 1.13 +43 -9 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java Index: JspContextWrapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- JspContextWrapper.java 28 Jan 2003 01:42:57 -0000 1.12 +++ JspContextWrapper.java 28 Jan 2003 22:06:28 -0000 1.13 @@ -133,8 +133,7 @@ if (nestedVars != null) { this.originalNestedVars = new Hashtable(nestedVars.size()); } - copyPageToTagScope(VariableInfo.AT_BEGIN); - saveNestedVariables(); + syncBeginTagFile(); } public void initialize(Servlet servlet, ServletRequest request, @@ -320,13 +319,48 @@ } /** + * Synchronize variables at begin of tag file + */ + public void syncBeginTagFile() { + copyPageToTagScope(VariableInfo.AT_BEGIN); + saveNestedVariables(); + } + + /** + * Synchronize variables before fragment invokation + */ + public void syncBeforeInvoke() { + copyTagToPageScope(VariableInfo.NESTED); + copyTagToPageScope(VariableInfo.AT_BEGIN); + } + + /** + * Synchronize variables after fragment invokation + */ + public void syncAfterInvoke() { + copyPageToTagScope(VariableInfo.NESTED); + copyPageToTagScope(VariableInfo.AT_BEGIN); + } + + /** + * Synchronize variables at end of tag file + */ + public void syncEndTagFile() { + copyTagToPageScope(VariableInfo.AT_BEGIN); + copyTagToPageScope(VariableInfo.AT_END); + restoreNestedVariables(); + } + + + + /** * Copies the variables of the given scope from the page scope of the * invoking JSP context to the virtual page scope of this JSP context * wrapper. * * @param scope variable scope (one of NESTED or AT_BEGIN) */ - public void copyPageToTagScope(int scope) { + private void copyPageToTagScope(int scope) { Iterator iter = null; switch (scope) { @@ -359,7 +393,7 @@ * * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END) */ - public void copyTagToPageScope(int scope) { + private void copyTagToPageScope(int scope) { Iterator iter = null; switch (scope) { @@ -396,7 +430,7 @@ * Saves the values of any NESTED variables that are present in * the invoking JSP context, so they can later be restored. */ - public void saveNestedVariables() { + private void saveNestedVariables() { if (nestedVars != null) { Iterator iter = nestedVars.iterator(); while (iter.hasNext()) { @@ -414,7 +448,7 @@ * Restores the values of any NESTED variables in the invoking JSP * context. */ - public void restoreNestedVariables() { + private void restoreNestedVariables() { if (nestedVars != null) { Iterator iter = nestedVars.iterator(); while (iter.hasNext()) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>