You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2003/03/28 03:13:03 UTC
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Compiler.java ELFunctionMapper.java JspDocumentParser.java Node.java Parser.java TagFileProcessor.java
luehe 2003/03/27 18:13:03
Modified: jasper2/src/share/org/apache/jasper/compiler Compiler.java
ELFunctionMapper.java JspDocumentParser.java
Node.java Parser.java TagFileProcessor.java
Log:
Implemented cleaner separation of custom node construction for custom
actions implemented via tag handlers vs. custom actions implemented via
tag files
Revision Changes Path
1.61 +1 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
Index: Compiler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- Compiler.java 24 Mar 2003 21:36:05 -0000 1.60
+++ Compiler.java 28 Mar 2003 02:13:02 -0000 1.61
@@ -199,6 +199,7 @@
// Setup page info area
pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader(),
errDispatcher));
+
JspConfig jspConfig = options.getJspConfig();
JspConfig.JspProperty jspProperty =
jspConfig.findJspProperty(ctxt.getJspFile());
1.5 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ELFunctionMapper.java
Index: ELFunctionMapper.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ELFunctionMapper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ELFunctionMapper.java 25 Mar 2003 01:49:29 -0000 1.4
+++ ELFunctionMapper.java 28 Mar 2003 02:13:02 -0000 1.5
@@ -205,7 +205,7 @@
if (k != 0) {
ds.append(", ");
}
- ds.append(params[k] + ".class");
+ ds.append("Class.forName(\"" + params[k] + "\")");
}
ds.append("});\n");
// Put the current name in the global function map
1.49 +16 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java
Index: JspDocumentParser.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- JspDocumentParser.java 25 Mar 2003 00:57:46 -0000 1.48
+++ JspDocumentParser.java 28 Mar 2003 02:13:02 -0000 1.49
@@ -654,7 +654,7 @@
localName, uri));
}
Class tagHandlerClass = null;
- if (tagFileInfo == null) {
+ if (tagInfo != null) {
String handlerClassName = tagInfo.getTagClassName();
try {
tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName);
@@ -663,9 +663,7 @@
Localizer.getMessage("jsp.error.loadclass.taghandler",
handlerClassName, qName));
}
- } else {
- tagInfo = tagFileInfo.getTagInfo();
- }
+ }
String prefix = "";
int colon = qName.indexOf(':');
@@ -673,9 +671,17 @@
prefix = qName.substring(0, colon);
}
- return new Node.CustomTag(qName, prefix, localName, uri, attrs,
- xmlnsAttrs, start, parent, tagInfo,
- tagFileInfo, tagHandlerClass);
+ Node.CustomTag ret = null;
+ if (tagInfo != null) {
+ ret = new Node.CustomTag(qName, prefix, localName, uri, attrs,
+ xmlnsAttrs, start, parent, tagInfo,
+ tagHandlerClass);
+ } else {
+ ret = new Node.CustomTag(qName, prefix, localName, uri, attrs,
+ xmlnsAttrs, start, parent, tagFileInfo);
+ }
+
+ return ret;
}
/*
1.69 +55 -29 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
Index: Node.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- Node.java 25 Mar 2003 00:57:46 -0000 1.68
+++ Node.java 28 Mar 2003 02:13:02 -0000 1.69
@@ -1239,49 +1239,75 @@
private Nodes atSTag;
private Nodes atETag;
+ /*
+ * Constructor for custom action implemented by tag handler.
+ */
public CustomTag(String qName, String prefix, String localName,
String uri, Attributes attrs, Mark start, Node parent,
- TagInfo tagInfo, TagFileInfo tagFileInfo,
+ TagInfo tagInfo, Class tagHandlerClass) {
+ this(qName, prefix, localName, uri, attrs, null, start, parent,
+ tagInfo, tagHandlerClass);
+ }
+
+ /*
+ * Constructor for custom action implemented by tag handler.
+ */
+ public CustomTag(String qName, String prefix, String localName,
+ String uri, Attributes attrs, Attributes xmlnsAttrs,
+ Mark start, Node parent, TagInfo tagInfo,
Class tagHandlerClass) {
+ super(qName, localName, attrs, xmlnsAttrs, start, parent);
+
+ this.uri = uri;
+ this.prefix = prefix;
+ this.tagInfo = tagInfo;
+ this.tagHandlerClass = tagHandlerClass;
+ this.customNestingLevel = makeCustomNestingLevel();
+ this.childInfo = new ChildInfo();
+ this.implementsIterationTag =
+ IterationTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsBodyTag =
+ BodyTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsTryCatchFinally =
+ TryCatchFinally.class.isAssignableFrom(tagHandlerClass);
+ this.implementsSimpleTag =
+ SimpleTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsDynamicAttributes =
+ DynamicAttributes.class.isAssignableFrom(tagHandlerClass);
+ }
+
+ /*
+ * Constructor for custom action implemented by tag file.
+ */
+ public CustomTag(String qName, String prefix, String localName,
+ String uri, Attributes attrs, Mark start, Node parent,
+ TagFileInfo tagFileInfo) {
this(qName, prefix, localName, uri, attrs, null, start, parent,
- tagInfo, tagFileInfo, tagHandlerClass);
+ tagFileInfo);
}
+ /*
+ * Constructor for custom action implemented by tag file.
+ */
public CustomTag(String qName, String prefix, String localName,
String uri, Attributes attrs, Attributes xmlnsAttrs,
- Mark start, Node parent, TagInfo tagInfo,
- TagFileInfo tagFileInfo, Class tagHandlerClass) {
+ Mark start, Node parent, TagFileInfo tagFileInfo) {
super(qName, localName, attrs, xmlnsAttrs, start, parent);
+
this.uri = uri;
this.prefix = prefix;
- this.tagInfo = tagInfo;
this.tagFileInfo = tagFileInfo;
- this.tagHandlerClass = tagHandlerClass;
+ this.tagInfo = tagFileInfo.getTagInfo();
this.customNestingLevel = makeCustomNestingLevel();
this.childInfo = new ChildInfo();
- if (tagHandlerClass != null) {
- this.implementsIterationTag =
- IterationTag.class.isAssignableFrom(tagHandlerClass);
- this.implementsBodyTag =
- BodyTag.class.isAssignableFrom(tagHandlerClass);
- this.implementsTryCatchFinally =
- TryCatchFinally.class.isAssignableFrom(tagHandlerClass);
- this.implementsSimpleTag =
- SimpleTag.class.isAssignableFrom(tagHandlerClass);
- this.implementsDynamicAttributes =
- DynamicAttributes.class.isAssignableFrom(tagHandlerClass);
- } else if (tagFileInfo != null) {
- // get the info from tag file
- this.implementsIterationTag = false;
- this.implementsBodyTag = false;
- this.implementsTryCatchFinally = false;
- this.implementsSimpleTag = true;
- this.implementsDynamicAttributes =
- tagInfo.hasDynamicAttributes();
- }
+ this.implementsIterationTag = false;
+ this.implementsBodyTag = false;
+ this.implementsTryCatchFinally = false;
+ this.implementsSimpleTag = true;
+ this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
public void accept(Visitor v) throws JasperException {
1.70 +23 -16 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Parser.java 24 Mar 2003 21:36:05 -0000 1.69
+++ Parser.java 28 Mar 2003 02:13:02 -0000 1.70
@@ -1333,7 +1333,7 @@
err.jspError(start, "jsp.error.bad_tag", shortTagName, prefix);
}
Class tagHandlerClass = null;
- if (tagFileInfo == null) {
+ if (tagInfo != null) {
// Must be a classic tag, load it here.
// tag files will be loaded later, in TagFileProcessor
String handlerClassName = tagInfo.getTagClassName();
@@ -1343,8 +1343,6 @@
err.jspError(start, "jsp.error.loadclass.taghandler",
handlerClassName, tagName);
}
- } else {
- tagInfo = tagFileInfo.getTagInfo();
}
// Parse 'CustomActionBody' production:
@@ -1357,9 +1355,13 @@
// Parse 'CustomActionEnd' production:
if (reader.matches("/>")) {
- new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
- start, parent, tagInfo, tagFileInfo,
- tagHandlerClass);
+ if (tagInfo != null) {
+ new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
+ start, parent, tagInfo, tagHandlerClass);
+ } else {
+ new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
+ start, parent, tagFileInfo);
+ }
return true;
}
@@ -1369,19 +1371,24 @@
// Looking for a body, it still can be empty; but if there is a
// a tag body, its syntax would be dependent on the type of
- // body content declared in TLD.
+ // body content declared in the TLD.
String bc;
if (tagInfo != null) {
bc = tagInfo.getBodyContent();
- } else if (tagFileInfo != null) {
- bc = TagInfo.BODY_CONTENT_SCRIPTLESS;
} else {
- bc = TagInfo.BODY_CONTENT_EMPTY;
+ bc = tagFileInfo.getTagInfo().getBodyContent();
+ }
+
+ Node tagNode = null;
+ if (tagInfo != null) {
+ tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
+ attrs, start, parent, tagInfo,
+ tagHandlerClass);
+ } else {
+ tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
+ attrs, start, parent, tagFileInfo);
}
- Node tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
- attrs, start, parent, tagInfo,
- tagFileInfo, tagHandlerClass);
parseOptionalBody( tagNode, tagName, bc );
return true;
1.46 +23 -23 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.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- TagFileProcessor.java 26 Feb 2003 00:04:56 -0000 1.45
+++ TagFileProcessor.java 28 Mar 2003 02:13:02 -0000 1.46
@@ -134,7 +134,7 @@
private String displayName = null;
private String smallIcon = null;
private String largeIcon = null;
- private boolean dynamicAttributes = false;
+ private boolean dynamicAttrs = false;
private Vector attributeVector;
private Vector variableVector;
@@ -164,8 +164,8 @@
err.jspError(n, "jsp.error.tagdirective.badbodycontent",
bodycontent);
}
- dynamicAttributes= JspUtil.booleanValue(
- n.getAttributeValue("dynamic-attributes"));
+ dynamicAttrs = JspUtil.booleanValue(
+ n.getAttributeValue("dynamic-attributes"));
smallIcon = n.getAttributeValue("small-icon");
largeIcon = n.getAttributeValue("large-icon");
description = n.getAttributeValue("description");
@@ -304,17 +304,17 @@
attributeVector.copyInto(tagAttributeInfo);
return new TagInfo(name,
- tagClassName,
- bodycontent,
- description,
- tagLibInfo,
- tei,
- tagAttributeInfo,
- displayName,
- smallIcon,
- largeIcon,
- tagVariableInfos,
- dynamicAttributes);
+ tagClassName,
+ bodycontent,
+ description,
+ tagLibInfo,
+ tei,
+ tagAttributeInfo,
+ displayName,
+ smallIcon,
+ largeIcon,
+ tagVariableInfos,
+ dynamicAttrs);
}
}
@@ -323,6 +323,7 @@
* in it. The method is used to obtain the info on the tag file, when the
* handler that it represents is referenced. The tag file is not compiled
* here.
+ *
* @param pc the current ParserController used in this compilation
* @param name the tag name as specified in the TLD
* @param tagfile the path for the tagfile
@@ -330,9 +331,9 @@
* @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();
@@ -353,7 +354,7 @@
/*
* TODO: need to check for uniqueness of attribute name, variable
- * name-given, and vraibale alias.
+ * name-given, and variable alias.
*/
/*
@@ -475,10 +476,9 @@
/*
- * A visitor that scan the page, looking for tag handlers that are tag
- * files and compile (if necessary) and load them.
+ * Visitor which scans the page and looks for tag handlers that are tag
+ * files, compiling (if necessary) and loading them.
*/
-
private class TagFileLoaderVisitor extends Node.Visitor {
private Compiler compiler;
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org