You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/03/18 09:00:20 UTC

cvs commit: cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers DefaultIncludeCacheManager.java

cziegeler    2004/03/18 00:00:20

  Modified:    src/java/org/apache/cocoon/transformation
                        XIncludeTransformer.java AugmentTransformer.java
                        JXTemplateTransformer.java FilterTransformer.java
                        AbstractExtractionTransformer.java
                        TraxTransformer.java
               src/java/org/apache/cocoon/transformation/helpers
                        DefaultIncludeCacheManager.java
  Log:
     <action dev="CZ" type="fix" fixes-bug="27764" due-to="Corin Moss" due-to-email="cmoss@tvnz.co.nz">
       DefaultIncludeCacheManager did not release xml-serializer under some circumstances.
     </action>
  And syncing transformation package with 2.1 except i18n
  
  Revision  Changes    Path
  1.16      +25 -26    cocoon-2.2/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
  
  Index: XIncludeTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XIncludeTransformer.java	8 Mar 2004 14:03:31 -0000	1.15
  +++ XIncludeTransformer.java	18 Mar 2004 08:00:19 -0000	1.16
  @@ -51,9 +51,9 @@
   
   /**
    * Implementation of an XInclude transformer. It supports xml:base attributes,
  - * xpointer fragment identifiers (see the xpointer package to see what exactly is supported),
  - * fallback elements, and does xinclude processing on the included content and on the content
  - * of fallback elements (with loop inclusion detection).
  + * XPointer fragment identifiers (see the xpointer package to see what exactly is
  + * supported), fallback elements, and does xinclude processing on the included content
  + * and on the content of fallback elements (with loop inclusion detection).
    *
    * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a> (wrote the original version)
    * @version CVS $Id$
  @@ -151,32 +151,32 @@
           }
   
           public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException {
  -            if (uri.equals(XINCLUDE_NAMESPACE_URI)) {
  -                if (xIncludeLevel == 1 && useFallback && name.equals(XINCLUDE_FALLBACK_ELEMENT)) {
  -                    fallbackLevel++;
  -    
  -                    // don't need these anymore
  -                    useFallback = false;
  -                    fallBackException = null;
  -    
  -                    return;
  -                } else if (xIncludeLevel > 0 && fallbackLevel < 1) {
  -                    xIncludeLevel++;
  -                    return;
  -                }
  -    
  -                xmlBaseSupport.startElement(uri, name, raw, attr);
  +            if (xIncludeLevel == 1 && useFallback && XINCLUDE_NAMESPACE_URI.equals(uri) && XINCLUDE_FALLBACK_ELEMENT.equals(name)) {
  +                fallbackLevel++;
  +
  +                // don't need these anymore
  +                useFallback = false;
  +                fallBackException = null;
  +
  +                return;
  +            } else if (xIncludeLevel > 0 && fallbackLevel < 1) {
  +                xIncludeLevel++;
  +                return;
  +            }
  +
  +            xmlBaseSupport.startElement(uri, name, raw, attr);
  +            if (XINCLUDE_NAMESPACE_URI.equals(uri)) {
                   if (XINCLUDE_INCLUDE_ELEMENT.equals(name)) {
                       String href = attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
                       if (href == null) {
                           throw new SAXException(raw + " must have a 'href' attribute at " + getLocation());
                       }
  -                    
  +
                       String parse = attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
  -    
  +
                       if (null == parse) parse="xml";
                       xIncludeLevel++;
  -    
  +
                       try {
                           processXIncludeElement(href, parse);
                       } catch (ProcessingException e) {
  @@ -188,11 +188,10 @@
                       }
                       return;
                   }
  -                
  +
                   throw new SAXException("Unknown XInclude element " + raw + " at " + getLocation());
  -                
  +
               } else {
  -                xmlBaseSupport.startElement(uri, name, raw, attr);
                   super.startElement(uri,name,raw,attr);
               }
           }
  @@ -209,7 +208,7 @@
                       fallBackException = null;
                       fallbackLevel = 0;
                       getLogger().error("Exception occured during xinclude processing, and did not find a fallback element.", localFallBackException);
  -                    throw new SAXException("Exception occured during xinclude processing, and did not find a fallback element: " + localFallBackException.getMessage());
  +                    throw new SAXException("Exception occured during xinclude processing, and did not find a fallback element.", localFallBackException);
                   }
                   return;
               }
  
  
  
  1.7       +16 -1     cocoon-2.2/src/java/org/apache/cocoon/transformation/AugmentTransformer.java
  
  Index: AugmentTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/AugmentTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AugmentTransformer.java	6 Dec 2003 21:22:07 -0000	1.6
  +++ AugmentTransformer.java	18 Mar 2004 08:00:19 -0000	1.7
  @@ -1,3 +1,18 @@
  +/*
  +* Copyright 1999-2004 The Apache Software Foundation
  +*
  +* Licensed under the Apache License, Version 2.0 (the "License");
  +* you may not use this file except in compliance with the License.
  +* You may obtain a copy of the License at
  +*
  +*     http://www.apache.org/licenses/LICENSE-2.0
  +*
  +* Unless required by applicable law or agreed to in writing, software
  +* distributed under the License is distributed on an "AS IS" BASIS,
  +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +* See the License for the specific language governing permissions and
  +* limitations under the License.
  +*/
   package org.apache.cocoon.transformation;
   
   import org.apache.avalon.framework.parameters.Parameters;
  
  
  
  1.2       +15 -0     cocoon-2.2/src/java/org/apache/cocoon/transformation/JXTemplateTransformer.java
  
  Index: JXTemplateTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/JXTemplateTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JXTemplateTransformer.java	8 Jul 2003 05:48:53 -0000	1.1
  +++ JXTemplateTransformer.java	18 Mar 2004 08:00:19 -0000	1.2
  @@ -1,3 +1,18 @@
  +/*
  +* Copyright 1999-2004 The Apache Software Foundation
  +*
  +* Licensed under the Apache License, Version 2.0 (the "License");
  +* you may not use this file except in compliance with the License.
  +* You may obtain a copy of the License at
  +*
  +*     http://www.apache.org/licenses/LICENSE-2.0
  +*
  +* Unless required by applicable law or agreed to in writing, software
  +* distributed under the License is distributed on an "AS IS" BASIS,
  +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +* See the License for the specific language governing permissions and
  +* limitations under the License.
  +*/
   package org.apache.cocoon.transformation;
   
   import org.apache.cocoon.generation.JXTemplateGenerator;
  
  
  
  1.5       +3 -3      cocoon-2.2/src/java/org/apache/cocoon/transformation/FilterTransformer.java
  
  Index: FilterTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/FilterTransformer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FilterTransformer.java	9 Mar 2004 00:57:27 -0000	1.4
  +++ FilterTransformer.java	18 Mar 2004 08:00:19 -0000	1.5
  @@ -132,10 +132,10 @@
                       super.contentHandler.startElement("", BLOCK, BLOCK, attr);
                   } else  {
                       // fix Bugzilla Bug 13904, check if counter == 1
  -                    // in this case there is no startElement( uri, BLOCK, BLOCK)
  +                    // in this case there is no startElement("", BLOCK, BLOCK)
                       // written, yet
                       if (this.counter > 1) {
  -                        super.contentHandler.endElement(uri, BLOCK, BLOCK);
  +                        super.contentHandler.endElement("", BLOCK, BLOCK);
                       }
                       super.contentHandler.startElement("", BLOCK, BLOCK, attr);
                   }
  
  
  
  1.6       +6 -4      cocoon-2.2/src/java/org/apache/cocoon/transformation/AbstractExtractionTransformer.java
  
  Index: AbstractExtractionTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/AbstractExtractionTransformer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractExtractionTransformer.java	8 Mar 2004 14:03:31 -0000	1.5
  +++ AbstractExtractionTransformer.java	18 Mar 2004 08:00:19 -0000	1.6
  @@ -56,10 +56,10 @@
       }
   
       public void recycle() {
  -        super.recycle();
           this.extractLevel = 0;
           this.currentBuilder = null;
           this.prefixMap = null;
  +        super.recycle();
       }
   
   
  @@ -393,7 +393,7 @@
       /**
        * Receive notification of the beginning of the extracted Document. Per default send
        * startElement message to document builder. Override if necessary. Must override 
  -     * {@link #endExtractingDocument} as well. 
  +     * {@link #endExtractingDocument(String, String, String)} as well. 
        *
        * @param uri The Namespace URI, or the empty string if the element has no
        *            Namespace URI or if Namespace
  @@ -425,7 +425,9 @@
       /**
        * Receive notification of the end of the extracted Document. Per default, 
        * send endElement message to document builder. Override if necessary.
  -     * Must override {@link #startExtractingDocument} as well.
  +     * Must override
  +     * {@link #startExtractingDocument(String, String, String, Attributes)}
  +     * as well.
        *
        * @param uri The Namespace URI, or the empty string if the element has no
        *            Namespace URI or if Namespace
  
  
  
  1.15      +6 -5      cocoon-2.2/src/java/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TraxTransformer.java	8 Mar 2004 14:03:31 -0000	1.14
  +++ TraxTransformer.java	18 Mar 2004 08:00:19 -0000	1.15
  @@ -500,11 +500,12 @@
        * Disposable
        */
       public void dispose() {
  -        this.manager.release(this.xsltProcessor);
  -        this.xsltProcessor = null;
  -        this.manager = null;
  +        if ( this.manager != null ) {
  +            this.manager.release(this.xsltProcessor);
  +            this.xsltProcessor = null;
  +            this.manager = null;
  +        }
       }
  -
   
       /**
        * Recyclable
  
  
  
  1.10      +17 -12    cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java
  
  Index: DefaultIncludeCacheManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers/DefaultIncludeCacheManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultIncludeCacheManager.java	8 Mar 2004 14:03:31 -0000	1.9
  +++ DefaultIncludeCacheManager.java	18 Mar 2004 08:00:19 -0000	1.10
  @@ -360,6 +360,8 @@
               throw new SAXException("ProcessingException", pe);
           } catch (ServiceException e) {
               throw new SAXException("Unable to lookup xml serializer.", e);
  +        } finally {
  +            this.manager.release(serializer);
           }
       }
   
  @@ -374,6 +376,14 @@
       }
   
       /**
  +     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
  +     */
  +    public void service(ServiceManager manager) throws ServiceException {
  +        this.manager = manager;
  +        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
  +    }
  +
  +    /**
        * @see org.apache.avalon.framework.activity.Disposable#dispose()
        */
       public void dispose() {
  @@ -407,14 +417,6 @@
           this.defaultCacheStorage = new StoreIncludeCacheStorageProxy(this.store, this.getLogger());
       }
   
  -    /* (non-Javadoc)
  -     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
  -     */
  -    public void service(ServiceManager manager) throws ServiceException {
  -        this.manager = manager;
  -        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
  -    }
  -
   }
   
   final class LoaderThread implements Runnable {
  @@ -424,13 +426,15 @@
       boolean  finished;
       Exception exception;
       byte[]    content;
  -
  +    ServiceManager manager;
  +    
       public LoaderThread(Source source, 
  -                         XMLSerializer serializer, 
  -                         ServiceManager manager) {
  +                        XMLSerializer serializer,
  +                        ServiceManager manager) {
           this.source = source;
           this.serializer = serializer;
           this.finished = false;
  +        this.manager = manager;
       }
       
       public void run() {
  @@ -440,6 +444,7 @@
           } catch (Exception local) {
               this.exception = local;
           } finally {
  +            this.manager.release( this.serializer );
               this.finished = true;
           }
       }