billbarker 2003/02/18 23:39:49 Modified: jasper2/src/share/org/apache/jasper JspCompilationContext.java jasper2/src/share/org/apache/jasper/compiler TagFileProcessor.java Log: Avoid the Tab-Police. (no functional changes) Revision Changes Path 1.33 +105 -105 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.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- JspCompilationContext.java 19 Feb 2003 07:03:44 -0000 1.32 +++ JspCompilationContext.java 19 Feb 2003 07:39:49 -0000 1.33 @@ -127,10 +127,10 @@ // jspURI _must_ be relative to the context public JspCompilationContext(String jspUri, - boolean isErrPage, - Options options, + boolean isErrPage, + Options options, ServletContext context, - JspServletWrapper jsw, + JspServletWrapper jsw, JspRuntimeContext rctxt) { this.jspUri = canonicalURI(jspUri); @@ -153,25 +153,25 @@ } this.rctxt = rctxt; - this.tagFileJars = new Hashtable(); + this.tagFileJars = new Hashtable(); this.servletPackageName = Constants.JSP_PACKAGE_NAME; - this.outUrls = new URL[2]; + this.outUrls = new URL[2]; } public JspCompilationContext(String tagfile, - TagInfo tagInfo, + TagInfo tagInfo, Options options, ServletContext context, - JspServletWrapper jsw, + JspServletWrapper jsw, JspRuntimeContext rctxt, - JarFile tagFileJar) { + JarFile tagFileJar) { this(tagfile, false, options, context, jsw, rctxt); this.isTagFile = true; this.tagInfo = tagInfo; - this.tagFileJar = tagFileJar; - if (tagFileJar != null) { - isPackagedTagFile = true; - } + this.tagFileJar = tagFileJar; + if (tagFileJar != null) { + isPackagedTagFile = true; + } } /* ==================== Methods to override ==================== */ @@ -201,13 +201,13 @@ public ClassLoader getClassLoader() { if( loader != null ) return loader; - if( rctxt == null) - return getClass().getClassLoader(); + if( rctxt == null) + return getClass().getClassLoader(); return rctxt.getParentClassLoader(); } public void setClassLoader(URLClassLoader loader) { - this.loader = loader; + this.loader = loader; } /** ---------- Input/Output ---------- */ @@ -237,7 +237,7 @@ } public Compiler getCompiler() { - return jspCompiler; + return jspCompiler; } /** ---------- Access resources in the webapp ---------- */ @@ -295,7 +295,7 @@ * of any imported taglibs. */ public Hashtable getTagFileJars() { - return this.tagFileJars; + return this.tagFileJars; } /** @@ -305,7 +305,7 @@ * corresponding tag file is not packaged in a JAR. */ public JarFile getTagFileJar() { - return this.tagFileJar; + return this.tagFileJar; } /* ==================== Common implementation ==================== */ @@ -320,35 +320,35 @@ return className; } - if (isTagFile) { - className = tagInfo.getTagClassName(); - int lastIndex = className.lastIndexOf('.'); - if (lastIndex != -1) { - className = className.substring(lastIndex + 1); - } - } else { - int iSep = jspUri.lastIndexOf('/') + 1; - int iEnd = jspUri.length(); - StringBuffer modifiedClassName = - new StringBuffer(jspUri.length() - iSep); - if (!Character.isJavaIdentifierStart(jspUri.charAt(iSep)) || - jspUri.charAt(iSep) == '_' ) { - // If the first char is not a start of Java identifier or is _ - // prepend a '_'. - modifiedClassName.append('_'); - } - for (int i = iSep; i < iEnd; i++) { - char ch = jspUri.charAt(i); - if (Character.isJavaIdentifierPart(ch)) { - modifiedClassName.append(ch); - } else if (ch == '.') { - modifiedClassName.append('_'); - } else { - modifiedClassName.append(mangleChar(ch)); - } - } - className = modifiedClassName.toString(); - } + if (isTagFile) { + className = tagInfo.getTagClassName(); + int lastIndex = className.lastIndexOf('.'); + if (lastIndex != -1) { + className = className.substring(lastIndex + 1); + } + } else { + int iSep = jspUri.lastIndexOf('/') + 1; + int iEnd = jspUri.length(); + StringBuffer modifiedClassName = + new StringBuffer(jspUri.length() - iSep); + if (!Character.isJavaIdentifierStart(jspUri.charAt(iSep)) || + jspUri.charAt(iSep) == '_' ) { + // If the first char is not a start of Java identifier or is _ + // prepend a '_'. + modifiedClassName.append('_'); + } + for (int i = iSep; i < iEnd; i++) { + char ch = jspUri.charAt(i); + if (Character.isJavaIdentifierPart(ch)) { + modifiedClassName.append(ch); + } else if (ch == '.') { + modifiedClassName.append('_'); + } else { + modifiedClassName.append(mangleChar(ch)); + } + } + className = modifiedClassName.toString(); + } return className; } @@ -378,11 +378,11 @@ } public boolean isTagFile() { - return isTagFile; + return isTagFile; } public TagInfo getTagInfo() { - return tagInfo; + return tagInfo; } /** @@ -390,11 +390,11 @@ * Generate codes with class for the tag handler with empty method bodies. */ public boolean isPrototypeMode() { - return protoTypeMode; + return protoTypeMode; } public void setPrototypeMode(boolean pm) { - protoTypeMode = pm; + protoTypeMode = pm; } /** @@ -423,14 +423,14 @@ String outputDir = getOutputDir(); servletJavaFileName = getServletClassName() + ".java"; - if (outputDir != null && !outputDir.equals("")) { + if (outputDir != null && !outputDir.equals("")) { if( outputDir.endsWith("/" ) ) { servletJavaFileName = outputDir + servletJavaFileName; } else { servletJavaFileName = outputDir + "/" + servletJavaFileName; } } - return servletJavaFileName; + return servletJavaFileName; } public void setServletJavaFileName(String servletJavaFileName) { @@ -445,11 +445,11 @@ } public ServletContext getServletContext() { - return context; + return context; } public JspRuntimeContext getRuntimeContext() { - return rctxt; + return rctxt; } /** @@ -460,23 +460,23 @@ return jspPath; } - if (isTagFile) { - jspPath = "tags/" - + tagInfo.getTagClassName().replace('.', '/') - + ".java"; - } else { - 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); - } - } + if (isTagFile) { + jspPath = "tags/" + + tagInfo.getTagClassName().replace('.', '/') + + ".java"; + } else { + 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; } @@ -488,10 +488,10 @@ String outputDir = getOutputDir(); classFileName = getServletClassName() + ".class"; - if (outputDir != null && !outputDir.equals("")) { - classFileName = outputDir + File.separatorChar + classFileName; + if (outputDir != null && !outputDir.equals("")) { + classFileName = outputDir + File.separatorChar + classFileName; } - return classFileName; + return classFileName; } /** @@ -533,9 +533,9 @@ * of a taglib deployed in a jar file (WEB-INF/lib). */ public String[] getTldLocation(String uri) throws JasperException { - String[] location = - getOptions().getTldLocationsCache().getLocation(uri); - return location; + String[] location = + getOptions().getTldLocationsCache().getLocation(uri); + return location; } /** @@ -568,7 +568,7 @@ public void compile() throws JasperException, FileNotFoundException { createCompiler(); - if (isPackagedTagFile || jspCompiler.isOutDated()) { + if (isPackagedTagFile || jspCompiler.isOutDated()) { try { jspCompiler.compile(); jsw.setReload(true); @@ -577,9 +577,9 @@ } catch (Exception ex) { ex.printStackTrace(); throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), - ex); + ex); } - } + } } // ==================== Manipulating the class ==================== @@ -605,10 +605,10 @@ servletClass = jspLoader.loadClass(name); } catch (ClassNotFoundException cex) { throw new JasperException(Localizer.getMessage("jsp.error.unable.load"), - cex); + cex); } catch (Exception ex) { throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), - ex); + ex); } removed = 0; return servletClass; @@ -617,15 +617,15 @@ public void createOutdir(String dirPath) { try { - // Append servlet or tag handler path to scratch dir + // Append servlet or tag handler path to scratch dir URL outUrl = options.getScratchDir().toURL(); String outUrlString = outUrl.toString(); if (outUrlString.endsWith("/")) { outUrlString += dirPath.substring(1, - dirPath.lastIndexOf("/")+1); + dirPath.lastIndexOf("/")+1); } else { outUrlString += dirPath.substring(0, - dirPath.lastIndexOf("/")+1); + dirPath.lastIndexOf("/")+1); } outUrl = new URL(outUrlString); File outDirFile = new File(outUrl.getFile()); @@ -634,15 +634,15 @@ } this.outputDir = outDirFile.toString() + File.separator; - // Populate the URL array with the URLs from which to load the - // generated servlet and tag handler classes. The URL array is - // passed to our org.apache.jasper.servlet.JasperLoader, which - // extends URLClassLoader + // Populate the URL array with the URLs from which to load the + // generated servlet and tag handler classes. The URL array is + // passed to our org.apache.jasper.servlet.JasperLoader, which + // extends URLClassLoader outUrls[0] = new URL(outDirFile.toURL().toString() - + File.separator); + + File.separator); outUrls[1] = new URL("file:" + options.getScratchDir() - + File.separator + "tags" - + File.separator); + + File.separator + "tags" + + File.separator); } catch (Exception e) { throw new IllegalStateException("No output directory: " + e.getMessage()); @@ -657,17 +657,17 @@ */ 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'; + 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); + for (int i = nzeros+1, j = 0; i < 6; i++, j++) { + result[i] = s.charAt(j); } - return new String(result); + return new String(result); } private static final boolean isPathSeparator(char c) { 1.41 +256 -256 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java Index: TagFileProcessor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- TagFileProcessor.java 19 Feb 2003 07:03:45 -0000 1.40 +++ TagFileProcessor.java 19 Feb 2003 07:39:49 -0000 1.41 @@ -103,30 +103,30 @@ new JspUtil.ValidAttribute("import"), new JspUtil.ValidAttribute("isELIgnored") }; - private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs = { - new JspUtil.ValidAttribute("name", true), - new JspUtil.ValidAttribute("required"), - new JspUtil.ValidAttribute("fragment"), - new JspUtil.ValidAttribute("rtexprvalue"), - new JspUtil.ValidAttribute("type"), - new JspUtil.ValidAttribute("description") - }; - - private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = { - new JspUtil.ValidAttribute("name-given"), - new JspUtil.ValidAttribute("name-from-attribute"), - new JspUtil.ValidAttribute("alias"), - new JspUtil.ValidAttribute("variable-class"), - new JspUtil.ValidAttribute("scope"), - new JspUtil.ValidAttribute("declare"), - new JspUtil.ValidAttribute("description") - }; + private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs = { + new JspUtil.ValidAttribute("name", true), + new JspUtil.ValidAttribute("required"), + new JspUtil.ValidAttribute("fragment"), + new JspUtil.ValidAttribute("rtexprvalue"), + new JspUtil.ValidAttribute("type"), + new JspUtil.ValidAttribute("description") + }; + + private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = { + new JspUtil.ValidAttribute("name-given"), + new JspUtil.ValidAttribute("name-from-attribute"), + new JspUtil.ValidAttribute("alias"), + new JspUtil.ValidAttribute("variable-class"), + new JspUtil.ValidAttribute("scope"), + new JspUtil.ValidAttribute("declare"), + new JspUtil.ValidAttribute("description") + }; private ErrorDispatcher err; - private TagLibraryInfo tagLibInfo; + private TagLibraryInfo tagLibInfo; private String name = null; - private String path = null; + private String path = null; private TagExtraInfo tei = null; private String bodycontent = null; private String description = null; @@ -134,26 +134,26 @@ private String smallIcon = null; private String largeIcon = null; private boolean dynamicAttributes = false; - + private Vector attributeVector; private Vector variableVector; public TagFileDirectiveVisitor(Compiler compiler, - TagLibraryInfo tagLibInfo, - String name, - String path) { + TagLibraryInfo tagLibInfo, + String name, + String path) { err = compiler.getErrorDispatcher(); - this.tagLibInfo = tagLibInfo; - this.name = name; - this.path = path; - attributeVector = new Vector(); - variableVector = new Vector(); + this.tagLibInfo = tagLibInfo; + this.name = name; + this.path = path; + attributeVector = new Vector(); + variableVector = new Vector(); } public void visit(Node.TagDirective n) throws JasperException { JspUtil.checkAttributes("Tag directive", n, tagDirectiveAttrs, - err); + err); bodycontent = n.getAttributeValue("body-content"); if (bodycontent != null && @@ -164,7 +164,7 @@ bodycontent); } dynamicAttributes= JspUtil.booleanValue( - n.getAttributeValue("dynamic-attributes")); + n.getAttributeValue("dynamic-attributes")); smallIcon = n.getAttributeValue("small-icon"); largeIcon = n.getAttributeValue("large-icon"); description = n.getAttributeValue("description"); @@ -178,15 +178,15 @@ String attrName = n.getAttributeValue("name"); boolean required = JspUtil.booleanValue( - n.getAttributeValue("required")); + n.getAttributeValue("required")); boolean rtexprvalue = true; String rtexprvalueString = n.getAttributeValue("rtexprvalue"); - if (rtexprvalueString != null) { - rtexprvalue = JspUtil.booleanValue( rtexprvalueString ); - } + if (rtexprvalueString != null) { + rtexprvalue = JspUtil.booleanValue( rtexprvalueString ); + } boolean fragment = JspUtil.booleanValue( - n.getAttributeValue("fragment")); - String type = n.getAttributeValue("type"); + n.getAttributeValue("fragment")); + String type = n.getAttributeValue("type"); if (fragment) { // type is fixed to "JspFragment" and a translation error // must occur if specified. @@ -202,11 +202,11 @@ } else { if (type == null) type = "java.lang.String"; - } + } - attributeVector.addElement( + attributeVector.addElement( new TagAttributeInfo(attrName, required, type, rtexprvalue, - fragment)); + fragment)); } public void visit(Node.VariableDirective n) throws JasperException { @@ -216,19 +216,19 @@ String nameGiven = n.getAttributeValue("name-given"); String nameFromAttribute = n.getAttributeValue("name-from-attribute"); - if (nameGiven == null && nameFromAttribute == null) { - err.jspError("jsp.variable.either.name"); - } - - if (nameGiven != null && nameFromAttribute != null) { - err.jspError("jsp.variable.both.name"); - } - - String alias = n.getAttributeValue("alias"); - if (nameFromAttribute != null && alias == null || - nameFromAttribute == null && alias != null) { - err.jspError("jsp.variable.alias"); - } + if (nameGiven == null && nameFromAttribute == null) { + err.jspError("jsp.variable.either.name"); + } + + if (nameGiven != null && nameFromAttribute != null) { + err.jspError("jsp.variable.both.name"); + } + + String alias = n.getAttributeValue("alias"); + if (nameFromAttribute != null && alias == null || + nameFromAttribute == null && alias != null) { + err.jspError("jsp.variable.alias"); + } String className = n.getAttributeValue("variable-class"); if (className == null) @@ -251,42 +251,42 @@ } } - if (nameFromAttribute != null) { - // An alias has been specified. We use nameGiven to - // hold the value of alias, and nameFromAttribute to - // hold what its alias - nameGiven = alias; - } - - variableVector.addElement(new TagVariableInfo( - nameGiven, - nameFromAttribute, - className, - declare, - scope)); - } - - /* - * Returns the vector of attributes corresponding to attribute - * directives. - */ - public Vector getAttributesVector() { - return attributeVector; - } - - /* - * Returns the vector of variables corresponding to variable - * directives. - */ - public Vector getVariablesVector() { - return variableVector; - } + if (nameFromAttribute != null) { + // An alias has been specified. We use nameGiven to + // hold the value of alias, and nameFromAttribute to + // hold what its alias + nameGiven = alias; + } + + variableVector.addElement(new TagVariableInfo( + nameGiven, + nameFromAttribute, + className, + declare, + scope)); + } + + /* + * Returns the vector of attributes corresponding to attribute + * directives. + */ + public Vector getAttributesVector() { + return attributeVector; + } + + /* + * Returns the vector of variables corresponding to variable + * directives. + */ + public Vector getVariablesVector() { + return variableVector; + } public TagInfo getTagInfo() throws JasperException { if (name == null) { // XXX Get it from tag file name - } + } if (bodycontent == null) { bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS; @@ -295,18 +295,18 @@ String tagClassName = JspUtil.getTagHandlerClassName(path, err); TagVariableInfo[] tagVariableInfos - = new TagVariableInfo[variableVector.size()]; - variableVector.copyInto(tagVariableInfos); + = new TagVariableInfo[variableVector.size()]; + variableVector.copyInto(tagVariableInfos); TagAttributeInfo[] tagAttributeInfo - = new TagAttributeInfo[attributeVector.size()]; - attributeVector.copyInto(tagAttributeInfo); + = new TagAttributeInfo[attributeVector.size()]; + attributeVector.copyInto(tagAttributeInfo); return new TagInfo(name, - tagClassName, - bodycontent, + tagClassName, + bodycontent, description, - tagLibInfo, + tagLibInfo, tei, tagAttributeInfo, displayName, @@ -314,7 +314,7 @@ largeIcon, tagVariableInfos, dynamicAttributes); - } + } } /** @@ -329,75 +329,75 @@ * @return a TagInfo object assembled from the directives in the tag file. */ public static TagInfo parseTagFileDirectives(ParserController pc, - String name, - String path, - TagLibraryInfo tagLibInfo) + String name, + String path, + TagLibraryInfo tagLibInfo) throws JasperException { - ErrorDispatcher err = pc.getCompiler().getErrorDispatcher(); + ErrorDispatcher err = pc.getCompiler().getErrorDispatcher(); Node.Nodes page = null; - try { - page = pc.parseTagFileDirectives(path); - } catch (FileNotFoundException e) { - err.jspError("jsp.error.file.not.found", path); - } catch (IOException e) { - err.jspError("jsp.error.file.not.found", path); - } + try { + page = pc.parseTagFileDirectives(path); + } catch (FileNotFoundException e) { + err.jspError("jsp.error.file.not.found", path); + } catch (IOException e) { + err.jspError("jsp.error.file.not.found", path); + } TagFileDirectiveVisitor tagFileVisitor - = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name, - path); + = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name, + path); page.visit(tagFileVisitor); - /* - * TODO: need to check for uniqueness of attribute name, variable - * name-given, and vraibale alias. - */ + /* + * TODO: need to check for uniqueness of attribute name, variable + * name-given, and vraibale alias. + */ - /* - * It is illegal to have a variable.name-given or variable.alias equal + /* + * It is illegal to have a variable.name-given or variable.alias equal * to an attribute.name in the same tag file translation unit. - */ - Iterator attrsIter = tagFileVisitor.getAttributesVector().iterator(); - while (attrsIter.hasNext()) { - TagAttributeInfo attrInfo = (TagAttributeInfo) attrsIter.next(); - Iterator varsIter = tagFileVisitor.getVariablesVector().iterator(); - while (varsIter.hasNext()) { - TagVariableInfo varInfo = (TagVariableInfo) varsIter.next(); - String attrName = attrInfo.getName(); - if (attrName.equals(varInfo.getNameGiven())) { - err.jspError("jsp.error.tagfile.var_name_given_equals_attr_name", - path, attrName); - } - } - } - /* - * It is illegal to have a variable.name-given equal another - * variable.alias the same tag file translation unit. - */ - Iterator varsIter = tagFileVisitor.getVariablesVector().iterator(); - while (varsIter.hasNext()) { - TagVariableInfo varsInfo = (TagVariableInfo) varsIter.next(); - if (varsInfo.getNameFromAttribute() == null) { - // Only interested in aliases. - continue; - } - String nameGiven = varsInfo.getNameGiven(); - - Iterator varsIter2 = tagFileVisitor.getVariablesVector().iterator(); - while (varsIter2.hasNext()) { - TagVariableInfo varsInfo2 = (TagVariableInfo) varsIter2.next(); - if (varsInfo2.getNameFromAttribute() != null) { - // Only interest in non-aliases - continue; - } - if (nameGiven.equals(varsInfo2.getNameGiven())) { - err.jspError("jsp.error.tagfile.nameGiven_equals.alias", - path, nameGiven); - } - } - } + */ + Iterator attrsIter = tagFileVisitor.getAttributesVector().iterator(); + while (attrsIter.hasNext()) { + TagAttributeInfo attrInfo = (TagAttributeInfo) attrsIter.next(); + Iterator varsIter = tagFileVisitor.getVariablesVector().iterator(); + while (varsIter.hasNext()) { + TagVariableInfo varInfo = (TagVariableInfo) varsIter.next(); + String attrName = attrInfo.getName(); + if (attrName.equals(varInfo.getNameGiven())) { + err.jspError("jsp.error.tagfile.var_name_given_equals_attr_name", + path, attrName); + } + } + } + /* + * It is illegal to have a variable.name-given equal another + * variable.alias the same tag file translation unit. + */ + Iterator varsIter = tagFileVisitor.getVariablesVector().iterator(); + while (varsIter.hasNext()) { + TagVariableInfo varsInfo = (TagVariableInfo) varsIter.next(); + if (varsInfo.getNameFromAttribute() == null) { + // Only interested in aliases. + continue; + } + String nameGiven = varsInfo.getNameGiven(); + + Iterator varsIter2 = tagFileVisitor.getVariablesVector().iterator(); + while (varsIter2.hasNext()) { + TagVariableInfo varsInfo2 = (TagVariableInfo) varsIter2.next(); + if (varsInfo2.getNameFromAttribute() != null) { + // Only interest in non-aliases + continue; + } + if (nameGiven.equals(varsInfo2.getNameGiven())) { + err.jspError("jsp.error.tagfile.nameGiven_equals.alias", + path, nameGiven); + } + } + } return tagFileVisitor.getTagInfo(); } @@ -406,77 +406,77 @@ * Compiles and loads a tagfile. */ private Class loadTagFile(Compiler compiler, - String tagFilePath, TagInfo tagInfo, - PageInfo parentPageInfo) - throws JasperException { - - JspCompilationContext ctxt = compiler.getCompilationContext(); - JspRuntimeContext rctxt = ctxt.getRuntimeContext(); - JspServletWrapper wrapper = null; - if( rctxt != null ) { - wrapper = - (JspServletWrapper) rctxt.getWrapper(tagFilePath); - - synchronized(rctxt) { - if (wrapper == null) { - wrapper = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile) ctxt.getTagFileJars().get(tagFilePath)); - rctxt.addWrapper(tagFilePath,wrapper); - } - } - } else { - wrapper = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile)ctxt.getTagFileJars().get(tagFilePath) - ); - } - - - Class tagClazz; - int tripCount = wrapper.incTripCount(); - try { - if (tripCount > 0) { - // When tripCount is greater than zero, a circular - // dependency exists. The circularily dependant tag - // file is compiled in prototype mode, to avoid infinite - // recursion. - - JspServletWrapper tempWrapper - = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile) ctxt.getTagFileJars().get(tagFilePath)); - tagClazz = tempWrapper.loadTagFilePrototype(); - tempVector.add( - tempWrapper.getJspEngineContext().getCompiler()); - } else { - tagClazz = wrapper.loadTagFile(); - } - } finally { - wrapper.decTripCount(); - } - - // Add the dependants for this tag file to its parent's - // dependant list. - PageInfo pageInfo = wrapper.getJspEngineContext().getCompiler(). - getPageInfo(); - if (pageInfo != null) { - Iterator iter = pageInfo.getDependants().iterator(); - if (iter.hasNext()) { - parentPageInfo.addDependant((String)iter.next()); - } - } - - return tagClazz; + String tagFilePath, TagInfo tagInfo, + PageInfo parentPageInfo) + throws JasperException { + + JspCompilationContext ctxt = compiler.getCompilationContext(); + JspRuntimeContext rctxt = ctxt.getRuntimeContext(); + JspServletWrapper wrapper = null; + if( rctxt != null ) { + wrapper = + (JspServletWrapper) rctxt.getWrapper(tagFilePath); + + synchronized(rctxt) { + if (wrapper == null) { + wrapper = new JspServletWrapper(ctxt.getServletContext(), + ctxt.getOptions(), + tagFilePath, + tagInfo, + ctxt.getRuntimeContext(), + (JarFile) ctxt.getTagFileJars().get(tagFilePath)); + rctxt.addWrapper(tagFilePath,wrapper); + } + } + } else { + wrapper = new JspServletWrapper(ctxt.getServletContext(), + ctxt.getOptions(), + tagFilePath, + tagInfo, + ctxt.getRuntimeContext(), + (JarFile)ctxt.getTagFileJars().get(tagFilePath) + ); + } + + + Class tagClazz; + int tripCount = wrapper.incTripCount(); + try { + if (tripCount > 0) { + // When tripCount is greater than zero, a circular + // dependency exists. The circularily dependant tag + // file is compiled in prototype mode, to avoid infinite + // recursion. + + JspServletWrapper tempWrapper + = new JspServletWrapper(ctxt.getServletContext(), + ctxt.getOptions(), + tagFilePath, + tagInfo, + ctxt.getRuntimeContext(), + (JarFile) ctxt.getTagFileJars().get(tagFilePath)); + tagClazz = tempWrapper.loadTagFilePrototype(); + tempVector.add( + tempWrapper.getJspEngineContext().getCompiler()); + } else { + tagClazz = wrapper.loadTagFile(); + } + } finally { + wrapper.decTripCount(); + } + + // Add the dependants for this tag file to its parent's + // dependant list. + PageInfo pageInfo = wrapper.getJspEngineContext().getCompiler(). + getPageInfo(); + if (pageInfo != null) { + Iterator iter = pageInfo.getDependants().iterator(); + if (iter.hasNext()) { + parentPageInfo.addDependant((String)iter.next()); + } + } + + return tagClazz; } @@ -487,26 +487,26 @@ private class TagFileLoaderVisitor extends Node.Visitor { - private Compiler compiler; - private PageInfo pageInfo; + private Compiler compiler; + private PageInfo pageInfo; - TagFileLoaderVisitor(Compiler compiler) { - - this.compiler = compiler; - this.pageInfo = compiler.getPageInfo(); - } + TagFileLoaderVisitor(Compiler compiler) { + + this.compiler = compiler; + this.pageInfo = compiler.getPageInfo(); + } public void visit(Node.CustomTag n) throws JasperException { - TagFileInfo tagFileInfo = n.getTagFileInfo(); - if (tagFileInfo != null) { - String tagFilePath = tagFileInfo.getPath(); - pageInfo.addDependant(tagFilePath); - Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), - pageInfo); - n.setTagHandlerClass(c); - } - visitBody(n); - } + TagFileInfo tagFileInfo = n.getTagFileInfo(); + if (tagFileInfo != null) { + String tagFilePath = tagFileInfo.getPath(); + pageInfo.addDependant(tagFilePath); + Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), + pageInfo); + n.setTagHandlerClass(c); + } + visitBody(n); + } } /** @@ -516,10 +516,10 @@ * in the CustomTag nodes. */ public void loadTagFiles(Compiler compiler, Node.Nodes page) - throws JasperException { + throws JasperException { - tempVector = new Vector(); - page.visit(new TagFileLoaderVisitor(compiler)); + tempVector = new Vector(); + page.visit(new TagFileLoaderVisitor(compiler)); } /** @@ -529,18 +529,18 @@ * with this name. */ public void removeProtoTypeFiles(String classFileName) { - Iterator iter = tempVector.iterator(); - while (iter.hasNext()) { - Compiler c = (Compiler) iter.next(); - if (classFileName == null) { - c.removeGeneratedClassFiles(); - } else if (classFileName.equals( - c.getCompilationContext().getClassFileName())) { - c.removeGeneratedClassFiles(); - tempVector.remove(c); - return; - } - } + Iterator iter = tempVector.iterator(); + while (iter.hasNext()) { + Compiler c = (Compiler) iter.next(); + if (classFileName == null) { + c.removeGeneratedClassFiles(); + } else if (classFileName.equals( + c.getCompilationContext().getClassFileName())) { + c.removeGeneratedClassFiles(); + tempVector.remove(c); + return; + } + } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]