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/servlet JspServletWrapper.java
Date Mon, 09 Sep 2002 20:36:08 GMT
kinman      2002/09/09 13:36:07

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        TagFileProcessor.java
               jasper2/src/share/org/apache/jasper/resources
                        messages.properties
               jasper2/src/share/org/apache/jasper/servlet
                        JspServletWrapper.java
  Log:
  - Detect and flags circular dependent tag files.
  
  Revision  Changes    Path
  1.23      +21 -12    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TagFileProcessor.java	4 Sep 2002 17:59:11 -0000	1.22
  +++ TagFileProcessor.java	9 Sep 2002 20:36:07 -0000	1.23
  @@ -332,11 +332,12 @@
       /**
        * Compiles and loads a tagfile.
        */
  -    private static Class loadTagFile(JspCompilationContext ctxt,
  +    private static Class loadTagFile(Compiler compiler,
   				    String tagFilePath, TagInfo tagInfo,
   				    TagData tagData)
   	throws JasperException {
   
  +	JspCompilationContext ctxt = compiler.getCompilationContext();
   	JspRuntimeContext rctxt = ctxt.getRuntimeContext();
           JspServletWrapper wrapper =
   		(JspServletWrapper) rctxt.getWrapper(tagFilePath);
  @@ -353,7 +354,17 @@
   					    ctxt.getTagFileJars());
   	    rctxt.addWrapper(tagFilePath,wrapper);
   	}
  -	return wrapper.loadTagFile();
  +
  +	// Check to see if we have been here before but not finished
  +	// compiling/loading.
  +	if (wrapper.incTripCount() > 0) {
  +	    // Circular tag file dependencies
  +	    compiler.getErrorDispatcher().jspError("jsp.error.circular.tagfile",
  +			tagFilePath);
  +	}
  +	Class tagClass = wrapper.loadTagFile();
  +	wrapper.decTripCount();
  +	return tagClass;
       }
   
       /*
  @@ -363,12 +374,12 @@
   
       static class TagFileLoaderVisitor extends Node.Visitor {
   
  -	private JspCompilationContext ctxt;
  +	private Compiler compiler;
   	private PageInfo pageInfo;
   
  -	TagFileLoaderVisitor(JspCompilationContext ctxt, PageInfo pageInfo) {
  -	    this.ctxt = ctxt;
  -	    this.pageInfo = pageInfo;
  +	TagFileLoaderVisitor(Compiler compiler) {
  +	    this.compiler = compiler;
  +	    this.pageInfo = compiler.getPageInfo();
   	}
   
           public void visit(Node.CustomTag n) throws JasperException {
  @@ -376,7 +387,7 @@
   	    if (tagFileInfo != null) {
   		String tagFilePath = tagFileInfo.getPath();
   		pageInfo.addDependant(tagFilePath);
  -		Class c = loadTagFile(ctxt, tagFilePath, n.getTagInfo(),
  +		Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
   				      n.getTagData());
   		n.setTagHandlerClass(c);
   	    }
  @@ -393,9 +404,7 @@
       public static void loadTagFiles(Compiler compiler, Node.Nodes page)
   		throws JasperException {
   
  -	JspCompilationContext ctxt = compiler.getCompilationContext();
  -	PageInfo pageInfo = compiler.getPageInfo();
  -	page.visit(new TagFileLoaderVisitor(ctxt, pageInfo));
  +	page.visit(new TagFileLoaderVisitor(compiler));
       }
   	
   }
  
  
  
  1.36      +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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- messages.properties	29 Aug 2002 23:27:36 -0000	1.35
  +++ messages.properties	9 Sep 2002 20:36:07 -0000	1.36
  @@ -300,4 +300,4 @@
   jsp.error.duplicate.name.jspattribute=The attribute {0} specified in the standard or custom
action also appears as the value of the name attribute in the enclosed jsp:attribute
   jsp.error.not.in.template=Not allowed in a template text body.
   jsp.error.badaction=The action is not a recognizable standard action.
  -
  +jsp.error.circular.tagfile=The tag file {0} contains a circular dependency on itself. 
This is currently not implemented.
  
  
  
  1.17      +13 -3     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java
  
  Index: JspServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JspServletWrapper.java	29 Aug 2002 18:31:20 -0000	1.16
  +++ JspServletWrapper.java	9 Sep 2002 20:36:07 -0000	1.17
  @@ -114,6 +114,7 @@
       private ServletConfig config;
       private Options options;
       private boolean isTagFile;
  +    private int tripCount;
   
       /*
        * JspServletWrapper for JSP pages.
  @@ -145,6 +146,7 @@
           this.config = null;	// not used
           this.options = options;
   	this.jspUri = tagFilePath;
  +	this.tripCount = 0;
           ctxt = new JspCompilationContext(jspUri, tagInfo, tagData, options,
   					 servletContext, this, rctxt,
   					 tagFileJars);
  @@ -246,6 +248,14 @@
   
       public boolean isTagFile() {
   	return this.isTagFile;
  +    }
  +
  +    public int incTripCount() {
  +	return tripCount++;
  +    }
  +
  +    public int decTripCount() {
  +	return tripCount--;
       }
   
       public void service(HttpServletRequest request, 
  
  
  

--
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