The fix looks OK, except that you still need to put the call to
incTripCount in a synchronized block.  Of course that won't
be necessary for JSPC.

There may better solutions to this problem, and I'll look into that.
I'll also make sure that there won't be problems using jspc on tag
files.


> Date: Wed, 19 Feb 2003 07:03:46 +0000
> From: [EMAIL PROTECTED]
> Subject: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
TagFileProcessor.java
> To: [EMAIL PROTECTED]
> 
> billbarker    2003/02/18 23:03:45
> 
>   Modified:    jasper2/src/share/org/apache/jasper
>                         JspCompilationContext.java
>                jasper2/src/share/org/apache/jasper/compiler
>                         TagFileProcessor.java
>   Log:
>   Fix for most of the pre-compile problems with TC-5.
>   
>   The basic problem is that with Jspc, there is no 'RuntimeContext'.  I've 
patched around the worst parts of it, but I'm the first to admit that I don't 
know Jasper down to this sort of level.
>   
>   Jan, Kin-Man, please review (and feel free to -1 if I've broken something).
>   
>   Revision  Changes    Path
>   1.32      +5 -3      
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/JspCompilati
onContext.java,v
>   retrieving revision 1.31
>   retrieving revision 1.32
>   diff -u -r1.31 -r1.32
>   --- JspCompilationContext.java      12 Feb 2003 16:37:11 -0000      1.31
>   +++ JspCompilationContext.java      19 Feb 2003 07:03:44 -0000      1.32
>   @@ -201,6 +201,8 @@
>        public ClassLoader getClassLoader() {
>            if( loader != null )
>                return loader;
>   +   if( rctxt == null) 
>   +       return getClass().getClassLoader();
>            return rctxt.getParentClassLoader();
>        }
>    
>   
>   
>   
>   1.40      +62 -49    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProces
sor.java
>   
>   Index: TagFileProcessor.java
>   ===================================================================
>   RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Tag
FileProcessor.java,v
>   retrieving revision 1.39
>   retrieving revision 1.40
>   diff -u -r1.39 -r1.40
>   --- TagFileProcessor.java   5 Feb 2003 23:35:21 -0000       1.39
>   +++ TagFileProcessor.java   19 Feb 2003 07:03:45 -0000      1.40
>   @@ -412,60 +412,73 @@
>    
>       JspCompilationContext ctxt = compiler.getCompilationContext();
>       JspRuntimeContext rctxt = ctxt.getRuntimeContext();
>   -        JspServletWrapper wrapper =
>   +   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);
>   +       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.
>   +   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();
>   +           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();
>           }
>   -
>   -       // 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());
>   -           }
>   +   } 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;
>       }
>   +   
>   +   return tagClazz;
>        }
>   +
>    
>        /*
>         * A visitor that scan the page, looking for tag handlers that are tag
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to