blob: 23e1303245d856e89f88337176e195a84cdd6e64 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
<document>
<header>
<title>ResourceReader in Cocoon</title>
<version>0.9</version>
<type>Technical document</type>
<authors>
<person name="Bernhard Huber" email="huber@apache.org"/>
</authors>
<abstract>This document describes the ResourceReader of Cocoon.</abstract>
</header>
<body>
<s1 title="ResourceReader">
<table>
<tr>
<td>NAME</td><td>resource</td>
</tr>
<tr>
<td>WHAT</td><td>The <code>ResourceReader</code> component is used
to serve binary data in a sitemap pipeline.
</td>
</tr>
<tr>
<td>TYPE</td><td>Reader, Sitemap Component</td>
</tr>
<tr>
<td>BLOCK</td><td>Core</td>
</tr>
<tr>
<td>CLASS</td><td>org.apache.cocoon.reading.ResourceReader</td>
</tr>
<!--tr>
<td>DEPRECATED</td><td>Cocoon 2.0, 2.1</td>
</tr-->
<tr>
<td>SINCE</td><td>Cocoon 2.0</td>
</tr>
<tr>
<td>CACHEABLE</td><td>yes</td>
</tr>
</table>
</s1>
<s1 title="Description">
<p>
The <code>ResourceReader</code> component is used to serve binary data
in a sitemap pipeline.
</p>
</s1>
<s1 title="Usage">
<p>
</p>
<s2 title="Sitemap pipeline examples">
<p>
The <code>ResourceReader</code> is used in a pipline as shown in the
pipeline snippet below:
</p>
<source><![CDATA[
<map:match pattern="*.css">
<map:read type="resource"
src="resources/styles/{1}.css"
mime-type="text/css">
<!-- option sitemap parameters -->
...
</map:read>
</map:match>
]]></source>
<p>
It is important to specify the <code>mime-type</code> attribute,
as it is passed to the browser as the <code>Content-Type</code>
in the <code>HTTP</code> response.
</p>
</s2>
<s2 title="Sitemap component configuration example">
<p>
A <code>ResourceReader</code> is declared in the sitemap readers
section, as shown in the sitemap readers snippet below:
</p>
<source><![CDATA[
<map:readers default="resource">
<map:reader name="resource"
src="org.apache.cocoon.reading.ResourceReader"
logger="sitemap.reader.resource"
pool-max="32" pool-min="1" pool-grow="4"/>
<!-- optional reader configuration -->
...
</map:readers>
...
]]></source>
</s2>
<s2 title="Configuration">
<p>
The <code>ResourceReader</code> accepts the following configuration parameters:
</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
configures the default reader for having an expiration of
1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms)
</p>
<source><![CDATA[
<map:readers default="resource">
<map:reader name="resource"
src="org.apache.cocoon.reading.ResourceReader"
logger="sitemap.reader.resource"
pool-max="32" pool-min="1" pool-grow="4"/>
<!-- optional reader configuration -->
<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>
<s2 title="Effect on Object Model and Sitemap Parameters">
<p>
The <code>ResourceReader</code> does not change object model and sitemap parameters.
It only access values for reading.
</p>
</s2>
</s1>
<s1 title="Bugs/Caveats">
</s1>
<s1 title="History">
<p>
12-25-02: Initial document creation by Bernhard Huber
<br/>
01-06-03: Added new parameters and byte range support, Torsten Curdt
</p>
</s1>
<s1 title="Copyright">
<p>
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
</p>
</s1>
<s1 title="See also">
<p>
<!-- Links to related components pages -->
</p>
</s1>
</body>
</document>