| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <head> |
| <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>ResourceReader in Cocoon</title> |
| <link href="http://purl.org/DC/elements/1.0/" rel="schema.DC"> |
| <meta content="Bernhard Huber" name="DC.Creator"> |
| <meta content="This document describes the ResourceReader of Cocoon." name="DC.Description"> |
| </head> |
| <body> |
| |
| <h1>ResourceReader</h1> |
| |
| <table> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">NAME</td><td colspan="1" rowspan="1">resource</td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">WHAT</td><td colspan="1" rowspan="1">The <span class="codefrag">ResourceReader</span> component is used |
| to serve binary data in a sitemap pipeline. |
| </td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">TYPE</td><td colspan="1" rowspan="1">Reader, Sitemap Component</td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">BLOCK</td><td colspan="1" rowspan="1">Core</td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">CLASS</td><td colspan="1" rowspan="1">org.apache.cocoon.reading.ResourceReader</td> |
| |
| </tr> |
| <!--tr> |
| <td>DEPRECATED</td><td>Cocoon 2.0, 2.1</td> |
| </tr--> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">SINCE</td><td colspan="1" rowspan="1">Cocoon 2.0</td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="1" rowspan="1">CACHEABLE</td><td colspan="1" rowspan="1">yes</td> |
| |
| </tr> |
| |
| </table> |
| |
| |
| <h1>Description</h1> |
| |
| <p> |
| The <span class="codefrag">ResourceReader</span> component is used to serve binary data |
| in a sitemap pipeline. |
| </p> |
| |
| |
| <h1>Usage</h1> |
| |
| <p> |
| |
| </p> |
| |
| <h2>Sitemap pipeline examples</h2> |
| <p> |
| The <span class="codefrag">ResourceReader</span> is used in a pipline as shown in the |
| pipeline snippet below: |
| </p> |
| <pre class="code"> |
| <map:match pattern="*.css"> |
| <map:read type="resource" |
| src="resources/styles/{1}.css" |
| mime-type="text/css"> |
| <!-- option sitemap parameters --> |
| ... |
| </map:read> |
| </map:match> |
| </pre> |
| <p> |
| It is important to specify the <span class="codefrag">mime-type</span> attribute, |
| as it is passed to the browser as the <span class="codefrag">Content-Type</span> |
| in the <span class="codefrag">HTTP</span> response. |
| </p> |
| |
| <h2>Sitemap component configuration example</h2> |
| <p> |
| A <span class="codefrag">ResourceReader</span> is declared in the sitemap readers |
| section, as shown in the sitemap readers snippet below: |
| </p> |
| <pre class="code"> |
| <map:readers default="resource"> |
| <map:reader name="resource" |
| src="org.apache.cocoon.reading.ResourceReader" |
| logger="sitemap.reader.resource" |
| pool-max="32"/> |
| <!-- optional reader configuration --> |
| ... |
| </map:readers> |
| ... |
| </pre> |
| |
| <h2>Configuration</h2> |
| <p> |
| The <span class="codefrag">ResourceReader</span> accepts the following configuration parameters: |
| </p> |
| <table> |
| |
| <tr> |
| <th colspan="1" rowspan="1">Parametername</th><th colspan="1" rowspan="1">Type</th><th colspan="1" rowspan="1">Comment</th> |
| </tr> |
| |
| <tr> |
| <td colspan="1" rowspan="1">expires</td><td colspan="1" rowspan="1">Time in milliseconds</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">quick-modified-test</td><td colspan="1" rowspan="1">boolean</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">byte-ranges</td><td colspan="1" rowspan="1">boolean</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">buffer-size</td><td colspan="1" rowspan="1">integer</td> |
| <td colspan="1" rowspan="1"> |
| 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 <span class="codefrag">ResourceReader</span> declaration snippet |
| configures the default reader for having an expiration of |
| 1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms) |
| </p> |
| <pre class="code"> |
| <map:readers default="resource"> |
| <map:reader name="resource" |
| src="org.apache.cocoon.reading.ResourceReader" |
| logger="sitemap.reader.resource" |
| pool-max="32"/> |
| <!-- optional reader configuration --> |
| <parameter name="expires" value="86400000"/> |
| </map:readers> |
| ... |
| </pre> |
| |
| <h2>Setup</h2> |
| <p> |
| The <span class="codefrag">ResourceReader</span> accepts following sitemap |
| setup parameters that override the configuration settings: |
| </p> |
| <table> |
| |
| <tr> |
| <th colspan="1" rowspan="1">Parametername</th><th colspan="1" rowspan="1">Type</th><th colspan="1" rowspan="1">Comment</th> |
| </tr> |
| |
| <tr> |
| <td colspan="1" rowspan="1">expires</td><td colspan="1" rowspan="1">Time in milliseconds</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">quick-modified-test</td><td colspan="1" rowspan="1">boolean</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">byte-ranges</td><td colspan="1" rowspan="1">boolean</td> |
| <td colspan="1" rowspan="1"> |
| 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 colspan="1" rowspan="1">buffer-size</td><td colspan="1" rowspan="1">integer</td> |
| <td colspan="1" rowspan="1"> |
| 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 <span class="codefrag">ResourceReader</span> declaration snippet |
| parameterizes the default reader for having an expiration of |
| 1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms) |
| </p> |
| <pre class="code"> |
| <map:read src="images/picture.gif"/> |
| <map:parameter name="expires" value="86400000"/> |
| </map:read> |
| ... |
| </pre> |
| |
| <h2>Effect on Object Model and Sitemap Parameters</h2> |
| <p> |
| The <span class="codefrag">ResourceReader</span> does not change object model and sitemap parameters. |
| It only access values for reading. |
| </p> |
| |
| |
| <h1>Bugs/Caveats</h1> |
| |
| |
| <h1>History</h1> |
| |
| <p> |
| 12-25-02: Initial document creation by Bernhard Huber |
| <br> |
| 01-06-03: Added new parameters and byte range support, Torsten Curdt |
| </p> |
| |
| |
| <h1>See also</h1> |
| |
| <p> |
| <!-- Links to related components pages --> |
| |
| </p> |
| |
| |
| </body> |
| </html> |