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/reading ResourceReader.java
Date Wed, 04 Feb 2004 12:18:54 GMT
cziegeler    2004/02/04 04:18:54

  Modified:    .        status.xml
               src/documentation/xdocs/userdocs/readers resource-reader.xml
               src/java/org/apache/cocoon/reading ResourceReader.java
  Log:
     <action dev="CZ" type="update">
       ResourceReader: Is now configurable as well. All parameters can be defined during configuration
       of the reader. Fixed also a minor bug in the last-modified detection.
     </action>
  
  Revision  Changes    Path
  1.235     +5 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.234
  retrieving revision 1.235
  diff -u -r1.234 -r1.235
  --- status.xml	1 Feb 2004 21:37:30 -0000	1.234
  +++ status.xml	4 Feb 2004 12:18:54 -0000	1.235
  @@ -196,6 +196,10 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="CZ" type="update">
  +     ResourceReader: Is now configurable as well. All parameters can be defined during
configuration
  +     of the reader. Fixed also a minor bug in the last-modified detection.
  +   </action>
      <action dev="GP" type="add" >
        OJB-Block: Added our own OJB ConnectionFactory which uses the 
        DataSources configured in cocoon.xconf
  
  
  
  1.4       +51 -8     cocoon-2.1/src/documentation/xdocs/userdocs/readers/resource-reader.xml
  
  Index: resource-reader.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/readers/resource-reader.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- resource-reader.xml	12 Oct 2003 13:04:50 -0000	1.3
  +++ resource-reader.xml	4 Feb 2004 12:18:54 -0000	1.4
  @@ -91,13 +91,7 @@
         </s2>
         <s2 title="Configuration">
           <p>
  -          The <code>ImageReader</code> has no configuration options. 
  -        </p>
  -      </s2>
  -      <s2 title="Setup">
  -        <p>
  -          The <code>ResourceReader</code> accepts following sitemap
  -          setup parameters
  +          The <code>ResourceReader</code> accepts the following configuration
parameters:
           </p>
           <table>
             <tr><th>Parametername</th><th>Type</th><th>Comment</th></tr>
  @@ -143,8 +137,57 @@
       logger="sitemap.reader.resource" 
       pool-max="32" pool-min="1" pool-grow="4"/>
       <!-- optional reader configuration -->
  -    <map:parameter name="expires" value="86400000"/>
  +    <parameter name="expires" value="86400000"/>
     </map:readers>
  +...
  +        ]]></source>
  +      </s2>
  +      <s2 title="Setup">
  +        <p>
  +          The <code>ResourceReader</code> accepts following sitemap
  +          setup parameters that override the configuration settings:
  +        </p>
  +        <table>
  +          <tr><th>Parametername</th><th>Type</th><th>Comment</th></tr>
  +          <tr><td>expires</td><td>Time in milliseconds</td>
  +            <td>
  +              This parameter is optional. When specified it determines how long
  +              in miliseconds the resources can be cached by any proxy or browser
  +              between Cocoon2 and the requesting visitor.
  +            </td>
  +          </tr>
  +          <tr><td>quick-modified-test</td><td>boolean</td>
  +            <td>
  +              This parameter is optional. This boolean parameter controls the
  +              last modified test. If set to true (default is false), only the
  +              last modified of the current source is tested, but not if the
  +              same source is used as last time.
  +            </td>
  +          </tr>
  +          <tr><td>byte-ranges</td><td>boolean</td>
  +            <td>
  +              This parameter is optional. This boolean parameter enables or disables
  +              support for the byte ranges. 
  +              By default this parameter is set to true.
  +            </td>
  +          </tr>
  +          <tr><td>buffer-size</td><td>integer</td>
  +            <td>
  +              This parameter is optional. It specifies the buffer/block size when
  +              reading from a resource.
  +              By default this parameter is set to 8192.
  +            </td>
  +          </tr>
  +        </table>
  +        <p>
  +          The following <code>ResourceReader</code> declaration snippet
  +          parameterizes the default reader for having an expiration of
  +          1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms)
  +        </p>
  +        <source><![CDATA[
  +  <map:read src="images/picture.gif"/>
  +    <map:parameter name="expires" value="86400000"/>
  +  </map:read>
   ...
           ]]></source>
         </s2>
  
  
  
  1.4       +27 -7     cocoon-2.1/src/java/org/apache/cocoon/reading/ResourceReader.java
  
  Index: ResourceReader.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/reading/ResourceReader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceReader.java	12 Dec 2003 09:40:47 -0000	1.3
  +++ ResourceReader.java	4 Feb 2004 12:18:54 -0000	1.4
  @@ -50,6 +50,8 @@
   */
   package org.apache.cocoon.reading;
   
  +import org.apache.avalon.framework.parameters.ParameterException;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.util.ByteRange;
  @@ -96,9 +98,12 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @version CVS $Id$
    */
  -public class ResourceReader extends AbstractReader implements CacheableProcessingComponent
{
  +public class ResourceReader 
  +extends AbstractReader 
  +implements CacheableProcessingComponent, Parameterizable {
   
       /** The list of generated documents */
       private static final Map documents = new HashMap();
  @@ -114,6 +119,21 @@
       protected long expires;
       protected int bufferSize;
   
  +    protected long configuredExpires;
  +    protected boolean configuredQuickTest;
  +    protected int configuredBufferSize;
  +    protected boolean configuredByteRanges;
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
  +     */
  +    public void parameterize(Parameters parameters) throws ParameterException {
  +        this.configuredExpires = parameters.getParameterAsLong("expires", -1);
  +        this.configuredQuickTest = parameters.getParameterAsBoolean("quick-modified-test",
false);
  +        this.configuredBufferSize = parameters.getParameterAsInteger("buffer-size", 8192);
  +        this.configuredByteRanges = parameters.getParameterAsBoolean("byte-ranges", true);
  +    }
  +
       /**
        * Setup the reader.
        * The resource is opened to get an <code>InputStream</code>,
  @@ -125,11 +145,11 @@
           request = ObjectModelHelper.getRequest(objectModel);
           response = ObjectModelHelper.getResponse(objectModel);
   
  -        expires = par.getParameterAsInteger("expires", -1);
  -        bufferSize = par.getParameterAsInteger("buffer-size",8192);
  +        expires = par.getParameterAsLong("expires", this.configuredExpires);
  +        bufferSize = par.getParameterAsInteger("buffer-size", this.configuredBufferSize);
   
  -        byteRanges = par.getParameterAsBoolean("byte-ranges",true);
  -        quickTest = par.getParameterAsBoolean("quick-modified-test", false);
  +        byteRanges = par.getParameterAsBoolean("byte-ranges", this.configuredByteRanges);
  +        quickTest = par.getParameterAsBoolean("quick-modified-test", this.configuredQuickTest);
   
           try {
               inputSource = resolver.resolveURI(src);
  @@ -179,7 +199,7 @@
               return inputSource.getLastModified();
           }
           final String systemId = (String) documents.get(request.getRequestURI());
  -        if (inputSource.getURI().equals(systemId)) {
  +        if (systemId == null || inputSource.getURI().equals(systemId)) {
               return inputSource.getLastModified();
           }
           else {
  
  
  

Mime
View raw message