kinman 02/04/24 14:12:53
Modified: jasper2/src/share/org/apache/jasper/compiler Node.java
PageDataImpl.java
Log:
- Removed the static field in Node.java, because it is not thread safe.
Instead rely on traversing the nodes to find the page root.
Revision Changes Path
1.7 +20 -35
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Node.java 19 Apr 2002 20:35:01 -0000 1.6
+++ Node.java 24 Apr 2002 21:12:52 -0000 1.7
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
1.6 2002/04/19 20:35:01 kinman Exp $
- * $Revision: 1.6 $
- * $Date: 2002/04/19 20:35:01 $
+ * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
1.7 2002/04/24 21:12:52 kinman Exp $
+ * $Revision: 1.7 $
+ * $Date: 2002/04/24 21:12:52 $
*
* ====================================================================
*
@@ -85,11 +85,6 @@
protected Node parent;
/**
- * The root node of this page.
- */
- private static Root currentRoot;
-
- /**
* Constructor.
* @param start The location of the jsp page
* @param parent The enclosing node
@@ -155,10 +150,6 @@
return parent;
}
- public Node getCurrentRoot() {
- return currentRoot;
- }
-
public int getBeginJavaLine() {
return beginJavaLine;
}
@@ -176,25 +167,17 @@
}
/**
- * Warning: This method is valid only when used from the correct context,
- * namely when the Root node for the current page has been visited first,
- * and the proper bookkeeping (<tt>pushCurrentRoot/popCurrentRoot</tt>)
- * has been performed.
- *
* @return true if the current page is in xml syntax, false otherwise.
*/
public boolean isXmlSyntax() {
- return currentRoot.isXmlSyntax();
- }
-
- public static void pushCurrentRoot(Root root) {
- root.setParentRoot(currentRoot);
- currentRoot = root;
- }
+ Node r = this;
+ while (!(r instanceof Node.Root)) {
+ r = r.getParent();
+ if (r == null)
+ return false;
+ }
- public static Root popCurrentRoot() {
- currentRoot = currentRoot.getParentRoot();
- return currentRoot;
+ return r.isXmlSyntax();
}
/**
@@ -237,6 +220,12 @@
Root(Attributes attrs, Mark start, Node parent) {
super(attrs, start, parent);
+
+ // Figure out and set the parent root
+ Node r = parent;
+ while ((r != null) && !(r instanceof Node.Root))
+ r = r.getParent();
+ parentRoot = (Node.Root) r;
}
public void accept(Visitor v) throws JasperException {
@@ -247,13 +236,13 @@
return false;
}
+ /**
+ * @ return The enclosing root to this root. Usually represents the
+ * page that includes this one.
+ */
public Root getParentRoot() {
return parentRoot;
}
-
- public void setParentRoot(Root root) {
- parentRoot = root;
- }
}
/**
@@ -860,17 +849,13 @@
}
public void visit(Root n) throws JasperException {
- Node.pushCurrentRoot(n);
doVisit(n);
visitBody(n);
- Node.popCurrentRoot();
}
public void visit(JspRoot n) throws JasperException {
- Node.pushCurrentRoot(n);
doVisit(n);
visitBody(n);
- Node.popCurrentRoot();
}
public void visit(PageDirective n) throws JasperException {
1.2 +4 -9
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java
Index: PageDataImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PageDataImpl.java 28 Mar 2002 18:46:16 -0000 1.1
+++ PageDataImpl.java 24 Apr 2002 21:12:52 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
1.1 2002/03/28 18:46:16 kinman Exp $
- * $Revision: 1.1 $
- * $Date: 2002/03/28 18:46:16 $
+ * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
1.2 2002/04/24 21:12:52 kinman Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/04/24 21:12:52 $
*
* ====================================================================
*
@@ -184,7 +184,6 @@
}
public void visit(Node.JspRoot n) throws JasperException {
- Node.pushCurrentRoot(n);
Attributes attrs = n.getAttributes();
if (attrs == null) {
throw new JasperException("Missing attributes in jsp:root");
@@ -203,7 +202,7 @@
attrs.getValue(i));
}
visitBody(n);
- if (Node.popCurrentRoot() == this.root) {
+ if (n == this.root) {
// top-level jsp:root element
root.setAttributes(rootAttrs);
}
@@ -249,9 +248,7 @@
* Visits root node of JSP page in JSP syntax.
*/
public void visit(Node.Root n) throws JasperException {
- Node.pushCurrentRoot(n);
appendTag(JSP_ROOT_TAG, n.getAttributes(), n.getBody());
- Node.popCurrentRoot();
}
/*
@@ -261,14 +258,12 @@
* include directive) are ignored.
*/
public void visit(Node.JspRoot n) throws JasperException {
- Node.pushCurrentRoot(n);
if (n == this.root) {
// top-level jsp:root element
appendTag(JSP_ROOT_TAG, n.getAttributes(), n.getBody());
} else {
visitBody(n);
}
- Node.popCurrentRoot();
}
public void visit(Node.PageDirective n) throws JasperException {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>