cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
Date Thu, 25 Sep 2003 16:57:44 GMT
cziegeler    2003/09/25 09:57:44

  Modified:    .        status.xml
               src/java/org/apache/cocoon/generation
                        JXTemplateGenerator.java
  Log:
     <action dev="CZ" type="add" fixes-bug="23171" due-to="Volker Schmitt" due-to-email="volker.schmitt@basf-it-services.com">
       Fixing release of Source in the JXTemplateGenerator.
     </action>
  
  Revision  Changes    Path
  1.156     +4 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.155
  retrieving revision 1.156
  diff -u -r1.155 -r1.156
  --- status.xml	25 Sep 2003 05:15:00 -0000	1.155
  +++ status.xml	25 Sep 2003 16:57:44 -0000	1.156
  @@ -191,6 +191,9 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="CZ" type="add" fixes-bug="23171" due-to="Volker Schmitt" due-to-email="volker.schmitt@basf-it-services.com">
  +     Fixing release of Source in the JXTemplateGenerator.
  +   </action>
      <action dev="AG" type="update">
        Update lib commons-lang to 2.0, iText to 1.00
      </action>
  
  
  
  1.10      +44 -43    cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JXTemplateGenerator.java	24 Sep 2003 22:04:40 -0000	1.9
  +++ JXTemplateGenerator.java	25 Sep 2003 16:57:44 -0000	1.10
  @@ -2550,13 +2550,16 @@
       }
   
       public void recycle() {
  +        if ( this.resolver != null) {
  +            this.resolver.release(this.inputSource);            
  +        }
  +        this.inputSource = null;
  +        this.consumer = null;
  +        this.jxpathContext = null;
  +        this.globalJexlContext = null;
  +        this.variables = null;
  +        this.definitions = null;
           super.recycle();
  -        consumer = null;
  -        jxpathContext = null;
  -        globalJexlContext = null;
  -        variables = null;
  -        inputSource = null;
  -        definitions = null;
       }
   
       public void setup(SourceResolver resolver, Map objectModel,
  @@ -3522,55 +3525,53 @@
                       uri = buf.toString();
                       
                   }
  -                Source input;
  +                Source input = null;
  +                StartDocument doc;
                   try {
                       input = resolver.resolveURI(uri);
  -                } catch (Exception exc) {
  -                    throw new SAXParseException(exc.getMessage(),
  -                                                ev.location,
  -                                                exc);
  -                }
  -                SourceValidity validity = null;
  -                StartDocument doc;
  -                synchronized (cache) {
  -                    doc = (StartDocument)cache.get(input.getURI());
  -                    if (doc != null) {
  -                        boolean recompile = false;
  -                        if ( doc.compileTime == null) {
  -                            recompile = true;
  -                        } else {
  -                            int valid = doc.compileTime.isValid();
  -                            if ( valid == SourceValidity.UNKNOWN ) {
  -                                validity = input.getValidity();
  -                                valid = doc.compileTime.isValid(validity);
  -                                
  -                            }
  -                            if ( valid != SourceValidity.VALID ) {
  +                
  +                    SourceValidity validity = null;
  +                    synchronized (cache) {
  +                        doc = (StartDocument)cache.get(input.getURI());
  +                        if (doc != null) {
  +                            boolean recompile = false;
  +                            if ( doc.compileTime == null) {
                                   recompile = true;
  +                            } else {
  +                                int valid = doc.compileTime.isValid();
  +                                if ( valid == SourceValidity.UNKNOWN ) {
  +                                    validity = input.getValidity();
  +                                    valid = doc.compileTime.isValid(validity);
  +                                }
  +                                if ( valid != SourceValidity.VALID ) {
  +                                    recompile = true;
  +                                }
  +                            }
  +                            if ( recompile ) {
  +                                doc = null; // recompile
                               }
  -                        }
  -                        if ( recompile ) {
  -                            doc = null; // recompile
                           }
                       }
  -                }
  -                if (doc == null) {
  -                    try {
  +                    if (doc == null) {
                           Parser parser = new Parser();
  -                        SourceUtil.parse(this.manager, input, parser);
  -                        doc = parser.getStartEvent();
  +                        // call getValidity before using the stream is faster if the source
is a SitemapSource
                           if ( validity == null ) {
                               validity = input.getValidity();
                           }
  +                        SourceUtil.parse(this.manager, input, parser);
  +                        doc = parser.getStartEvent();
                           doc.compileTime = validity;
  -                    } catch (Exception exc) {
  -                        throw new SAXParseException(exc.getMessage(),
  -                                                    ev.location,
  -                                                    exc);
  -                    }
  -                    synchronized (cache) {
  -                        cache.put(input.getURI(), doc);
  +                        synchronized (cache) {
  +                            cache.put(input.getURI(), doc);
  +                        }
                       }
  +                } catch (Exception exc) {
  +                    throw new SAXParseException(exc.getMessage(),
  +                                                ev.location,
  +                                                exc);
  +                }
  +                finally {
  +                    resolver.release(input);
                   }
                   JXPathContext selectJXPath = jxpathContext;
                   MyJexlContext selectJexl = jexlContext;
  
  
  

Mime
View raw message