ResourceReader in Cocoon
http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Main
User Documentation

Readers
Overview

Default
Resource Reader

Core

Optional
Database Reader
JSP Reader

Scratchpad
AxisRPC Reader
Byte Range Resource Reader
Directory ZIP Archiver
Image Reader

ResourceReader
NAMEresource
WHATThe ResourceReader component is used to serve binary data in a sitemap pipeline.
TYPEReader, Sitemap Component
BLOCKCore
CLASSorg.apache.cocoon.reading.ResourceReader
SINCECocoon 2.0
CACHEABLEyes
Description

The ResourceReader component is used to serve binary data in a sitemap pipeline.

Usage

Sitemap pipeline examples

The ResourceReader is used in a pipline as shown in the pipeline snippet below:

<map:match pattern="*.css">
  <map:read type="resource" 
    src="resources/styles/{1}.css" 
    mime-type="text/css">
    <!-- option sitemap parameters -->
    ...
  </map:read>
</map:match>

It is important to specify the mime-type attribute, as it is passed to the browser as the Content-Type in the HTTP response.

Sitemap component configuration example

A ResourceReader is declared in the sitemap readers section, as shown in the sitemap readers snippet below:

<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>
...
        
Configuration

The ImageReader has no configuration options.

Setup

The ResourceReader accepts following sitemap setup parameters

ParameternameTypeComment
expiresTime in milliseconds 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.
quick-modified-testboolean This parameter is optional. This boolean parameter controlls 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.

The following ResourceReader declaration snippet configures the default reader for having an expiration of 1 day (ie. 24 * 60 * 60 * 1000 ms = 86400000 ms)

<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:parameter name="expires" value="86400000"/>
  </map:readers>
...
        
Effect on Object Model and Sitemap Parameters

The ResourceReader does not change object model and sitemap parameters. It only access values for reading.

Bugs/Caveats

The ResourceReader does not support HTTP ranges, thus it sets Accept-Ranges to none.

History

12-25-02: Initial document creation by Bernhard Huber

Copyright

Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.

See also

Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.