You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2002/08/02 11:21:00 UTC

cvs commit: xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination Paginator.java

stephan     2002/08/02 02:21:00

  Modified:    src/scratchpad/src/org/apache/cocoon/acting
                        CookieValidatorAction.java
                        DatabaseCookieAuthenticatorAction.java
               src/scratchpad/src/org/apache/cocoon/callback XMLSource.java
               src/scratchpad/src/org/apache/cocoon/components/repository/impl
                        SlideRepository.java
               src/scratchpad/src/org/apache/cocoon/generation
                        XPathDirectoryGenerator.java
               src/scratchpad/src/org/apache/cocoon/precept
                        InstanceTransformer.java
               src/scratchpad/src/org/apache/cocoon/reading
                        ByteRangeResourceReader.java
                        DirectoryZipArchiver.java ImageReader.java
               src/scratchpad/src/org/apache/cocoon/taglib/core
                        SourceTag.java
               src/scratchpad/src/org/apache/cocoon/transformation
                        CastorTransformer.java XMLDBTransformer.java
               src/scratchpad/src/org/apache/cocoon/transformation/pagination
                        Paginator.java
  Log:
  Removed deprecated methods
  
  Revision  Changes    Path
  1.8       +2 -1      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/CookieValidatorAction.java
  
  Index: CookieValidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/CookieValidatorAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CookieValidatorAction.java	31 Jul 2002 13:13:32 -0000	1.7
  +++ CookieValidatorAction.java	2 Aug 2002 09:21:00 -0000	1.8
  @@ -140,6 +140,7 @@
           try {
               Configuration conf = this.getConfiguration(
                       parameters.getParameter("descriptor", (String) this.settings.get("descriptor")),
  +                    resolver,
                       parameters.getParameterAsBoolean("reloadable", reloadable)
                       );
               valstr = parameters.getParameter("validate", valstr);
  
  
  
  1.7       +2 -1      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java
  
  Index: DatabaseCookieAuthenticatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DatabaseCookieAuthenticatorAction.java	22 Feb 2002 06:58:02 -0000	1.6
  +++ DatabaseCookieAuthenticatorAction.java	2 Aug 2002 09:21:00 -0000	1.7
  @@ -136,6 +136,7 @@
           try {
               Configuration conf = this.getConfiguration(
                       parameters.getParameter("descriptor", (String) this.settings.get("descriptor")),
  +                    resolver,
                       parameters.getParameterAsBoolean("reloadable", reloadable));
               boolean cs = true;
               boolean as = false;
  
  
  
  1.5       +3 -2      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/callback/XMLSource.java
  
  Index: XMLSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/callback/XMLSource.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLSource.java	6 Apr 2002 06:36:53 -0000	1.4
  +++ XMLSource.java	2 Aug 2002 09:21:00 -0000	1.5
  @@ -50,7 +50,8 @@
   */
   package org.apache.cocoon.callback;
   
  -import org.apache.cocoon.environment.Source;
  +import org.apache.excalibur.source.Source;
  +
   import org.xml.sax.ContentHandler;
   
   /**
  
  
  
  1.3       +4 -1      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/repository/impl/SlideRepository.java
  
  Index: SlideRepository.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/repository/impl/SlideRepository.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SlideRepository.java	18 Jul 2002 22:25:35 -0000	1.2
  +++ SlideRepository.java	2 Aug 2002 09:21:00 -0000	1.3
  @@ -111,6 +111,9 @@
        */
       public void enableLogging(Logger logger) {
           this.logger = logger;
  +
  +        // FIXME Could not remove deprecated method, because some important 
  +        // messages were thrown over the domain logger
           domain.setLogger(new SlideLoggerAdapter(this.logger));
       }
   
  
  
  
  1.5       +10 -4     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/XPathDirectoryGenerator.java
  
  Index: XPathDirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/XPathDirectoryGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XPathDirectoryGenerator.java	22 Feb 2002 06:58:03 -0000	1.4
  +++ XPathDirectoryGenerator.java	2 Aug 2002 09:21:00 -0000	1.5
  @@ -53,20 +53,26 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.parameters.Parameters;
  +
  +import org.apache.avalon.excalibur.xml.Parser;
   import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
  +
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.xml.dom.DOMStreamer;
  +
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
  +
   import org.w3c.dom.Document;
   import org.w3c.dom.NodeList;
  +
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  +
   import java.io.File;
   import java.io.IOException;
   import java.net.URL;
  @@ -193,7 +199,7 @@
         doc = null;
         try {
           doc = parser.parseDocument(
  -          resolver.resolve(in.toURL().toExternalForm()).getInputSource());
  +          SourceUtil.getInputSource(resolver.resolveURI(in.toURL().toExternalForm())));
         } catch (SAXException se) {
            this.getLogger().error("Warning:" + in.getName()
             + " is not a valid XML file. Ignoring");
  
  
  
  1.7       +25 -41    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/precept/InstanceTransformer.java
  
  Index: InstanceTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/precept/InstanceTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InstanceTransformer.java	2 Aug 2002 07:06:20 -0000	1.6
  +++ InstanceTransformer.java	2 Aug 2002 09:21:00 -0000	1.7
  @@ -102,61 +102,37 @@
   
   package org.apache.cocoon.precept;
   
  -
  -
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.cocoon.ProcessingException;
  -
   import org.apache.cocoon.precept.acting.AbstractPreceptorAction;
  -
  -import org.apache.cocoon.caching.CacheValidity;
  -
  -import org.apache.cocoon.caching.NOPCacheValidity;
  -
   import org.apache.cocoon.environment.ObjectModelHelper;
  -
   import org.apache.cocoon.environment.Request;
  -
   import org.apache.cocoon.environment.Session;
  -
   import org.apache.cocoon.environment.SourceResolver;
  -
   import org.apache.cocoon.transformation.AbstractTransformer;
   
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   
   import org.xml.sax.Attributes;
  -
   import org.xml.sax.SAXException;
  -
   import org.xml.sax.helpers.AttributesImpl;
   
  -
  -
   import java.io.IOException;
  +import java.io.Serializable;
   
   import java.util.Map;
  -
   import java.util.List;
  -
   import java.util.Iterator;
  -
   import java.util.Collection;
   
  -
  -
   /*
  -
    * @author Torsten Curdt <tc...@dff.st>
  -
    */
  -
   public class InstanceTransformer extends AbstractTransformer {
  -
     //implements Cacheable {
   
  -
  -
     public final static String NS = "http://www.dff.st/ns/desire/instance/1.0";
   
   
  @@ -567,21 +543,29 @@
   
     }
   
  +    /**
  +     * Generate the unique key.
  +     * This key must be unique inside the space of this component.
  +     * This method must be invoked before the generateValidity() method.
  +     *
  +     * @return The generated key or <code>null</code> if the component
  +     *              is currently not cacheable.
  +     */
  +    public Serializable generateKey() {
  +        return NOPValidity.SHARED_INSTANCE.toString();
  +    }
   
  -
  -  public long generateKey() {
  -
  -    return (1);
  -
  -  }
  -
  -
  -
  -  public CacheValidity generateValidity() {
  -
  -    return (new NOPCacheValidity());
  -
  -  }
  +    /**
  +     * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
  +     *
  +     * @return The generated validity object or <code>null</code> if the
  +     *         component is currently not cacheable.
  +     */
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
  +    }
   
   }
   
  
  
  
  1.2       +50 -37    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/ByteRangeResourceReader.java
  
  Index: ByteRangeResourceReader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/ByteRangeResourceReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByteRangeResourceReader.java	12 Jun 2002 17:25:23 -0000	1.1
  +++ ByteRangeResourceReader.java	2 Aug 2002 09:21:00 -0000	1.2
  @@ -51,23 +51,27 @@
   package org.apache.cocoon.reading;
   
   import org.apache.avalon.framework.parameters.Parameters;
  +
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
  -import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.environment.http.HttpResponse;
   import org.apache.cocoon.util.ByteRange;
   import org.apache.cocoon.util.HashUtil;
  +
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
  +
   import org.xml.sax.SAXException;
   
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.Serializable;
   import java.util.Date;
   import java.util.Map;
   import java.util.StringTokenizer;
  @@ -94,7 +98,7 @@
    */
   public class ByteRangeResourceReader
     extends AbstractReader
  -  implements Cacheable {
  +  implements CacheableProcessingComponent {
   
       private final static int BUFFER_SIZE = 8192;
         
  @@ -110,41 +114,44 @@
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
       throws ProcessingException, SAXException, IOException {
           super.setup(resolver, objectModel, src, par);
  -        this.inputSource = this.resolver.resolve(super.source);
  +
  +        try {
  +            this.inputSource = this.resolver.resolveURI(super.source);
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Could not retrieve source '"+super.source+"'", se);
  +        }
       }
   
       public void recycle() {
  -        super.recycle();
           if (this.inputSource != null) {
  -            this.inputSource.recycle();
  +            this.resolver.release(this.inputSource);
               this.inputSource = null;
           }
  +        super.recycle();
       }
   
       /**
        * Generate the unique key.
        * This key must be unique inside the space of this component.
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return The generated key hashes the src
  +     * @return The generated key or <code>null</code> if the component
  +     *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        if (this.inputSource.getLastModified() != 0) {
  -            return HashUtil.hash(this.inputSource.getSystemId());
  -        }
  -        return 0;
  +    public Serializable generateKey() {
  +        return this.inputSource.getSystemId();
       }
   
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        if (getLastModified() != 0) {
  -            return new TimeStampCacheValidity(this.inputSource.getLastModified());
  -        }
  -        return null;
  +    public SourceValidity generateValidity() {
  +        return this.inputSource.getValidity();
       }
   
       /**
  @@ -218,26 +225,32 @@
               
               byte[] buffer = new byte[BUFFER_SIZE];
               int length = -1;
  -            InputStream inputStream = this.inputSource.getInputStream();
  -            if (byteRange == null) {
  -                while ((length = inputStream.read(buffer)) > -1) {
  -                    out.write(buffer, 0, length);
  -                }
  -            } else {
  -                int pos = 0;
  -                int posEnd;
  -                while ((length = inputStream.read(buffer)) > -1) {
  -                    posEnd = pos + length - 1;
  -                    ByteRange intersection = byteRange.intersection(new ByteRange(pos, posEnd));
  -                    if (intersection != null) {
  -                        out.write(buffer, (int) intersection.getStart() - pos, (int) intersection.length());
  +
  +            try {
  +                InputStream inputStream = this.inputSource.getInputStream();
  +                if (byteRange == null) {
  +                    while ((length = inputStream.read(buffer)) > -1) {
  +                        out.write(buffer, 0, length);
  +                    }
  +                } else {
  +                    int pos = 0;
  +                    int posEnd;
  +                    while ((length = inputStream.read(buffer)) > -1) {
  +                        posEnd = pos + length - 1;
  +                        ByteRange intersection = byteRange.intersection(new ByteRange(pos, posEnd));
  +                        if (intersection != null) {
  +                            out.write(buffer, (int) intersection.getStart() - pos, (int) intersection.length());
  +                        }
  +                        pos += length;
                       }
  -                    pos += length;
                   }
  +                inputStream.close();
  +                inputStream = null;
  +            } catch (SourceException se) {
  +                throw new ProcessingException("Could not read source '"+super.source+"'", se);
  +            } finally {
  +                out.flush();
               }
  -            inputStream.close();
  -            inputStream = null;
  -            out.flush();
           } catch (IOException ioe) {
               getLogger().debug("Received an IOException, assuming client severed connection on purpose");
           }
  
  
  
  1.5       +9 -3      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/DirectoryZipArchiver.java
  
  Index: DirectoryZipArchiver.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/DirectoryZipArchiver.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DirectoryZipArchiver.java	11 Jun 2002 23:54:54 -0000	1.4
  +++ DirectoryZipArchiver.java	2 Aug 2002 09:21:00 -0000	1.5
  @@ -57,9 +57,11 @@
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
  -import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +
   import org.xml.sax.SAXException;
   
   import java.io.File;
  @@ -98,7 +100,11 @@
           this.request = ObjectModelHelper.getRequest(objectModel);
           this.response = ObjectModelHelper.getResponse(objectModel);
   
  -        this.inputSource = this.resolver.resolve(super.source);
  +        try {
  +            this.inputSource = this.resolver.resolveURI(super.source);
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Could not retrieve source '"+super.source+"'", se);
  +        }
   
           String systemId = inputSource.getSystemId();
           if (!systemId.startsWith("file:")) {
  
  
  
  1.5       +35 -19    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/ImageReader.java
  
  Index: ImageReader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/ImageReader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ImageReader.java	11 Jun 2002 23:54:54 -0000	1.4
  +++ ImageReader.java	2 Aug 2002 09:21:00 -0000	1.5
  @@ -55,17 +55,18 @@
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
  -import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.HashUtil;
   
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
  +
   import com.sun.image.codec.jpeg.ImageFormatException;
   import com.sun.image.codec.jpeg.JPEGCodec;
   import com.sun.image.codec.jpeg.JPEGDecodeParam;
  @@ -81,6 +82,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.io.Serializable;
   import java.util.Date;
   import java.util.Map;
   
  @@ -103,10 +105,11 @@
    *   </dl>
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version CVS $Revision$ $Date$
    */
    
  -public class ImageReader extends AbstractReader implements Composable, Cacheable {
  +public class ImageReader extends AbstractReader implements Composable, CacheableProcessingComponent {
   
       private ComponentManager manager;
   
  @@ -131,27 +134,36 @@
           this.height = par.getParameterAsInteger("height", 0);
           this.expireTime = par.getParameterAsInteger("expire-time", -1);
           getLogger().debug("Image data: [" + this.width + "x" + this.height + "] Expire Time: " + expireTime);
  -        this.inputSource = this.resolver.resolve(super.source);
  +
  +        try {
  +            this.inputSource = this.resolver.resolveURI(super.source);
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Could not retrieve source '"+super.source+"'", se);
  +        }
       }
   
       /**
        * Generate the unique key.
        * This key must be unique inside the space of this component.
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return The generated key hashes the src
  +     * @return The generated key or <code>null</code> if the component
  +     *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        return HashUtil.hash(this.inputSource.getSystemId() + ":" + width + height);
  +    public Serializable generateKey() { 
  +       return this.inputSource.getSystemId() + ":" + width + height;
       }
   
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return new TimeStampCacheValidity(this.inputSource.getLastModified());
  +    public SourceValidity generateValidity() {
  +        return this.inputSource.getValidity();
       }
   
       /**
  @@ -169,13 +181,17 @@
           if (expireTime > 0) {
               response.setDateHeader("Expires", new Date().getTime() + expireTime);
           }
  -
  -        InputStream in = this.inputSource.getInputStream();
  -        
  -        if ((width == 0) && (height == 0)) {
  -            read(in, out);
  -        } else {
  -            convert(in, width, height, out);
  +    
  +        try {
  +            InputStream in = this.inputSource.getInputStream();
  +
  +            if ((width == 0) && (height == 0)) {
  +                read(in, out);
  +            } else {
  +                convert(in, width, height, out);
  +            }
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Could not read source '"+super.source+"'", se);
           }
       }
       
  
  
  
  1.2       +24 -6     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/taglib/core/SourceTag.java
  
  Index: SourceTag.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/taglib/core/SourceTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceTag.java	12 Jun 2002 16:48:42 -0000	1.1
  +++ SourceTag.java	2 Aug 2002 09:21:00 -0000	1.2
  @@ -50,19 +50,37 @@
   */
   package org.apache.cocoon.taglib.core;
   
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Composable;
  +
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.taglib.XMLProducerTagSupport;
   import org.apache.cocoon.xml.EmbeddedXMLPipe;
  +
  +import org.apache.excalibur.source.Source;
  +
   import org.xml.sax.SAXException;
   
   /**
    * @author: <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a> 
    */
  -public class SourceTag extends XMLProducerTagSupport {
  +public class SourceTag extends XMLProducerTagSupport implements Composable {
       private String src;
       private EmbeddedXMLPipe embeddedXMLPipe = new EmbeddedXMLPipe(null);
   
  +    /** The component manager instance */
  +    private ComponentManager manager = null;
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composable</code>.
  +     */
  +    public void compose(ComponentManager manager) throws ComponentException {
  +        this.manager = manager;
  +    }
  +
       public void setSrc(String src) {
           this.src = src;
       }
  @@ -74,8 +92,8 @@
           Source source = null;
           try {
               embeddedXMLPipe.setConsumer(this.xmlConsumer);
  -            source = resolver.resolve(src);
  -            source.toSAX(embeddedXMLPipe);
  +            source = resolver.resolveURI(src);
  +            SourceUtil.toSAX(source, this.embeddedXMLPipe, this.manager);
           } catch (Exception e) {
               if (e instanceof ProcessingException) {
                   ProcessingException pe = (ProcessingException) e;
  @@ -87,7 +105,7 @@
           } finally {
               embeddedXMLPipe.setConsumer(null);
               if (source != null)
  -                source.recycle();
  +                resolver.release(source);
           }
           return EVAL_PAGE;
       }
  @@ -99,4 +117,4 @@
           this.src = null;
           super.recycle();
       }
  -}
  \ No newline at end of file
  +}
  
  
  
  1.3       +1 -1      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/CastorTransformer.java
  
  Index: CastorTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/CastorTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CastorTransformer.java	11 Jun 2002 23:54:54 -0000	1.2
  +++ CastorTransformer.java	2 Aug 2002 09:21:00 -0000	1.3
  @@ -251,7 +251,7 @@
   
     public  String getFile(SourceResolver sr, String FileName) {
       try{
  -		String path = sr.resolve(FileName).getSystemId();
  +		String path = sr.resolveURI(FileName).getSystemId();
   		if(path.startsWith(FILE_PREFIX)){
   		   path = path.substring(FILE_PREFIX.length());
   		}
  
  
  
  1.8       +20 -8     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/XMLDBTransformer.java
  
  Index: XMLDBTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/XMLDBTransformer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLDBTransformer.java	10 Jun 2002 03:37:39 -0000	1.7
  +++ XMLDBTransformer.java	2 Aug 2002 09:21:00 -0000	1.8
  @@ -56,15 +56,21 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +
   import org.apache.cocoon.util.TraxErrorHandler;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  +//import org.apache.cocoon.caching.CacheValidity;
  +//import org.apache.cocoon.caching.Cacheable;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  +
  +import org.apache.excalibur.source.SourceValidity;
  +
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  +
   import org.xmldb.api.base.Database;
   import org.xmldb.api.base.Resource;
   import org.xmldb.api.base.Collection;
  @@ -78,7 +84,9 @@
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.TransformerConfigurationException;
  +
   import java.io.IOException;
  +import java.io.Serializable;
   import java.io.StringWriter;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -152,7 +160,7 @@
    * @version CVS $Id$
    */
   public class XMLDBTransformer extends AbstractTransformer
  -    implements Disposable, Cacheable, Configurable, Initializable {
  +    implements Disposable, CacheableProcessingComponent, Configurable, Initializable {
   
       private static String XMLDB_URI = "http://apache.org/cocoon/xmldb/1.0";
       private static String XMLDB_QUERY_ELEMENT = "query";
  @@ -250,20 +258,24 @@
       /**
        * Generate the unique key.
        * This key must be unique inside the space of this component.
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return The generated key hashes the src
  +     * @return The generated key or <code>null</code> if the component
  +     *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        return 1;
  +    public Serializable generateKey() {
  +        return null;
       }
   
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           return null;
       }
   
  
  
  
  1.13      +65 -53    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Paginator.java
  
  Index: Paginator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Paginator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Paginator.java	27 Jun 2002 17:52:29 -0000	1.12
  +++ Paginator.java	2 Aug 2002 09:21:00 -0000	1.13
  @@ -52,37 +52,40 @@
   package org.apache.cocoon.transformation.pagination;
   
   import java.io.IOException;
  +import java.io.Serializable;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
   
  +import org.apache.avalon.excalibur.xml.Parser;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.excalibur.pool.Poolable;
  -import org.apache.excalibur.store.Store;
   
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CompositeCacheValidity;
  -import org.apache.cocoon.caching.ParametersCacheValidity;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  -import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
  -import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.transformation.AbstractTransformer;
   
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.AggregatedValidity;
  +import org.apache.excalibur.source.impl.validity.TimeStampValidity;
  +import org.apache.excalibur.store.Store;
  +
   import org.xml.sax.Attributes;
  +import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.DefaultHandler;
   import org.xml.sax.helpers.AttributesImpl;
  @@ -91,10 +94,11 @@
    * A paginating transformer.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version CVS $Revision$ $Date$
    */
   public class Paginator extends AbstractTransformer
  -    implements Composable, Disposable, Cacheable {
  +    implements Composable, Disposable, CacheableProcessingComponent {
   
       public static final String PAGINATE_URI = "http://apache.org/cocoon/paginate/1.0";
       public static final String PAGINATE_PREFIX = "page";
  @@ -158,67 +162,75 @@
               throw new ProcessingException("I need the paginate instructions (pagesheet) to continue. Set the 'src' attribute.");
           }
   
  -        this.level = 0;
  -        this.prefixMapping = false;
  -        this.par = par;
  -        this.objectModel = objectModel;
  -        this.inputSource = resolver.resolve(src);
  -        this.resolver = resolver;
  -        getLogger().debug("Using pagesheet: '" + this.inputSource.getSystemId() + "' in " + this + ", last modified: " + this.inputSource.getLastModified());
  -        this.page = par.getParameterAsInteger("page", 1);
  -        this.item = par.getParameterAsInteger("item", 0);
  -        this.itemGroup = par.getParameter("item-group", "");
  -        getLogger().debug("Paginating with [page = " + this.page + ", item = " + this.item + ", item-group = " + this.itemGroup + "]");
  -
  -        this.request = ObjectModelHelper.getRequest(objectModel);
  -        this.requestURI = request.getRequestURI();
  -
  -        // Get the pagesheet factory from the Store if available,
  -        // otherwise load it and put it into the store for further request
  -        if (store != null) {
  -            pagesheet = (Pagesheet) store.get(src);
  -        }
  -
  -        // If not in the store or if pagesheet has changed, loads and stores it
  -        if (pagesheet == null || pagesheet.modifiedSince(inputSource.getLastModified())) {
  -            pagesheet = new Pagesheet();
  -            parser.setContentHandler(pagesheet);
  -            pagesheet.setLastModified(inputSource.getLastModified());
  -            parser.parse(inputSource.getInputSource());
  -            if (store != null) store.store(src,pagesheet);
  -        }
  -
  -        // Clone it in order to avoid concurrency collisions since the
  -        // implementation is not reentrant.
  -        this.pagesheet = (Pagesheet) this.pagesheet.clone();
  +        try {
  +            this.level = 0;
  +            this.prefixMapping = false;
  +            this.par = par;
  +            this.objectModel = objectModel;
  +            this.inputSource = resolver.resolveURI(src);
  +            this.resolver = resolver;
  +            getLogger().debug("Using pagesheet: '" + this.inputSource.getSystemId() + "' in " + this + ", last modified: " + 
  +                              this.inputSource.getLastModified());
  +            this.page = par.getParameterAsInteger("page", 1);
  +            this.item = par.getParameterAsInteger("item", 0);
  +            this.itemGroup = par.getParameter("item-group", "");
  +            getLogger().debug("Paginating with [page = " + this.page + ", item = " + this.item + ", item-group = " + this.itemGroup + "]");
  +
  +            this.request = ObjectModelHelper.getRequest(objectModel);
  +            this.requestURI = request.getRequestURI();
  +
  +            // Get the pagesheet factory from the Store if available,
  +            // otherwise load it and put it into the store for further request
  +            if (store != null) {
  +                pagesheet = (Pagesheet) store.get(src);
  +            }
  +
  +            // If not in the store or if pagesheet has changed, loads and stores it
  +            if (pagesheet == null || pagesheet.modifiedSince(inputSource.getLastModified())) {
  +                pagesheet = new Pagesheet();
  +                pagesheet.setLastModified(inputSource.getLastModified());
  +                parser.parse(new InputSource(inputSource.getInputStream()), pagesheet);
  +                if (store != null) store.store(src,pagesheet);
  +            }
  +
  +            // Clone it in order to avoid concurrency collisions since the
  +            // implementation is not reentrant.
  +            this.pagesheet = (Pagesheet) this.pagesheet.clone();
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Could not retrieve source '"+src+"'", se);
  +        }
       }
   
       /**
        * Generate the unique key.
        * This key must be unique inside the space of this component.
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return The generated key hashes the src
  +     * @return The generated key or <code>null</code> if the component
  +     *              is currently not cacheable.
        */
  -    public long generateKey() {
  +    public Serializable generateKey() {
           if (this.inputSource.getLastModified() != 0) {
  -            return HashUtil.hash(this.inputSource.getSystemId() + page);
  +            return this.inputSource.getSystemId() + page;
           } else {
  -            return 0;
  +            return null;
           }
       }
   
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           if (this.inputSource.getLastModified() != 0) {
  -            return new CompositeCacheValidity(
  -                            new TimeStampCacheValidity(page),
  -                            new TimeStampCacheValidity(this.inputSource.getLastModified())
  -                       );
  +            AggregatedValidity validity = new AggregatedValidity();
  +            validity.add(new TimeStampValidity(page));
  +            validity.add(this.inputSource.getValidity());
  +            return validity;
           } else {
               return null;
           }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org