vgritsenko 2004/06/23 12:14:34
Modified: . status.xml
src/java/org/apache/cocoon/reading ResourceReader.java
src/webapp sitemap.xmap
Log:
Apply patch from bug #25712 (byte ranges support).
Add support for configuration elements.
Fix recycle.
Revision Changes Path
1.371 +9 -2 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.370
retrieving revision 1.371
diff -u -r1.370 -r1.371
--- status.xml 20 Jun 2004 23:46:54 -0000 1.370
+++ status.xml 23 Jun 2004 19:14:34 -0000 1.371
@@ -204,7 +204,14 @@
<changes>
<release version="@version@" date="@date@">
- <action dev="AG" type="update">
+ <action dev="VG" type="update">
+ ResourceReader can now take configuration elements, parameters
+ are deprecated.
+ </action>
+ <action dev="VG" type="fix" fixes-bug="25712" due-to="Litrik De Roy">
+ Fix byte ranges support in ResourceReader.
+ </action>
+ <action dev="AG" type="update">
Deprecate methods implementsInterface(String, String),
implementsInterface(Class, Class), lastModified(Class)
and which(Class) in org.apache.cocoon.util.ClassUtils
1.7 +128 -90
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ResourceReader.java 11 Mar 2004 18:46:31 -0000 1.6
+++ ResourceReader.java 23 Jun 2004 19:14:34 -0000 1.7
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,11 +15,13 @@
*/
package org.apache.cocoon.reading;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
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;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.Context;
@@ -28,6 +30,8 @@
import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.http.HttpResponse;
+import org.apache.cocoon.util.ByteRange;
+
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceValidity;
@@ -39,64 +43,91 @@
import java.util.Map;
/**
- *
- *
* The <code>ResourceReader</code> component is used to serve binary data
* in a sitemap pipeline. It makes use of HTTP Headers to determine if
* the requested resource should be written to the <code>OutputStream</code>
* or if it can signal that it hasn't changed.
*
- * Parameters:
- * <dl>
- * <dt><expires></dt>
- * <dd>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.
- * </dd>
- * <dt><quick-modified-test></dt>
- * <dd>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. (see
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102921894301915&w=2 )
- * </dd>
- * </dl>
+ * <p>Configuration:
+ * <dl>
+ * <dt><expires></dt>
+ * <dd>This parameter is optional. When specified it determines how long
+ * in miliseconds the resources can be cached by any proxy or browser
+ * between Cocoon and the requesting visitor. Defaults to -1.
+ * </dd>
+ * <dt><quick-modified-test></dt>
+ * <dd>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
+ * (see
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102921894301915 )
+ * </dd>
+ * <dt><byte-ranges></dt>
+ * <dd>This parameter is optional. This boolean parameter controls whether
+ * Cocoon should support byterange requests (to allow clients to resume
+ * broken/interrupted downloads).
+ * Defaults to true.
+ * </dl>
+ *
+ * <p>Default configuration:
+ * <pre>
+ * <expires>-1</expires>
+ * <quick-modified-test>false</quick-modified-test>
+ * <byte-ranges>true</byte-ranges>
+ * </pre>
+ *
+ * <p>In addition to reader configuration, above parameters can be passed
+ * to the reader at the time when it is used.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Id$
*/
-public class ResourceReader
-extends AbstractReader
-implements CacheableProcessingComponent, Parameterizable {
+public class ResourceReader extends AbstractReader
+ implements CacheableProcessingComponent,
Configurable {
- /** The list of generated documents */
+ /**
+ * The list of generated documents
+ */
private static final Map documents = new HashMap();
- protected Source inputSource;
- protected InputStream inputStream;
+ protected long configuredExpires;
+ protected boolean configuredQuickTest;
+ protected int configuredBufferSize;
+ protected boolean configuredByteRanges;
+ protected long expires;
protected boolean quickTest;
+ protected int bufferSize;
protected boolean byteRanges;
protected Response response;
protected Request request;
- protected long expires;
- protected int bufferSize;
+ protected Source inputSource;
- 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)
+ /**
+ * Read reader configuration
*/
- public void parameterize(Parameters parameters) throws
ParameterException {
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ // VG Parameters are deprecated as of 2.2.0-Dev/2.1.6-Dev
+ final Parameters parameters =
Parameters.fromConfiguration(configuration);
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);
+
+ // Configuration has precedence over parameters.
+ this.configuredExpires =
configuration.getChild("expires").getValueAsLong(configuredExpires);
+ this.configuredQuickTest =
configuration.getChild("quick-modified-test").getValueAsBoolean(configuredQuickTest);
+ this.configuredBufferSize =
configuration.getChild("buffer-size").getValueAsInteger(configuredBufferSize);
+ this.configuredByteRanges =
configuration.getChild("byte-ranges").getValueAsBoolean(configuredByteRanges);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(Parameters)
+ */
+ public void parameterize(Parameters parameters) throws
ParameterException {
}
/**
@@ -104,23 +135,22 @@
* The resource is opened to get an <code>InputStream</code>,
* the length and the last modification date
*/
- public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par) throws ProcessingException, SAXException, IOException {
+ public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
+ throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
- request = ObjectModelHelper.getRequest(objectModel);
- response = ObjectModelHelper.getResponse(objectModel);
-
- expires = par.getParameterAsLong("expires", this.configuredExpires);
- bufferSize = par.getParameterAsInteger("buffer-size",
this.configuredBufferSize);
+ this.request = ObjectModelHelper.getRequest(objectModel);
+ this.response = ObjectModelHelper.getResponse(objectModel);
- byteRanges = par.getParameterAsBoolean("byte-ranges",
this.configuredByteRanges);
- quickTest = par.getParameterAsBoolean("quick-modified-test",
this.configuredQuickTest);
+ this.expires = par.getParameterAsLong("expires",
this.configuredExpires);
+ this.quickTest = par.getParameterAsBoolean("quick-modified-test",
this.configuredQuickTest);
+ this.bufferSize = par.getParameterAsInteger("buffer-size",
this.configuredBufferSize);
+ this.byteRanges = par.getParameterAsBoolean("byte-ranges",
this.configuredByteRanges);
try {
- inputSource = resolver.resolveURI(src);
- }
- catch (SourceException se) {
- throw SourceUtil.handle("Error during resolving of '" + src +
"'.", se);
+ this.inputSource = resolver.resolveURI(src);
+ } catch (SourceException e) {
+ throw SourceUtil.handle("Error during resolving of '" + src +
"'.", e);
}
}
@@ -128,9 +158,11 @@
* Recyclable
*/
public void recycle() {
- if (inputSource != null) {
- super.resolver.release(inputSource);
- inputSource = null;
+ this.request = null;
+ this.response = null;
+ if (this.inputSource != null) {
+ super.resolver.release(this.inputSource);
+ this.inputSource = null;
}
super.recycle();
}
@@ -152,7 +184,12 @@
* component is currently not cacheable.
*/
public SourceValidity getValidity() {
- return inputSource.getValidity();
+ if(request.getHeader("Range") != null) {
+ // This is a byte range request so we can't use the cache,
return null.
+ return null;
+ } else {
+ return inputSource.getValidity();
+ }
}
/**
@@ -160,23 +197,36 @@
* possible to detect
*/
public long getLastModified() {
+ if(request.getHeader("Range") != null) {
+ // This is a byte range request so we can't use the cache,
return null.
+ return 0;
+ }
+
if (quickTest) {
return inputSource.getLastModified();
}
+
final String systemId = (String)
documents.get(request.getRequestURI());
if (systemId == null || inputSource.getURI().equals(systemId)) {
return inputSource.getLastModified();
}
- else {
- documents.remove(request.getRequestURI());
- return 0;
- }
+
+ documents.remove(request.getRequestURI());
+ return 0;
}
- protected void processStream() throws IOException, ProcessingException {
+ protected void processStream(InputStream inputStream)
+ throws IOException, ProcessingException {
byte[] buffer = new byte[bufferSize];
int length = -1;
+ // tell the client whether we support byte range requests or not
+ if(byteRanges) {
+ response.setHeader("Accept-Ranges", "bytes");
+ } else {
+ response.setHeader("Accept-Ranges", "none");
+ }
+
String ranges = request.getHeader("Ranges");
ByteRange byteRange;
@@ -196,8 +246,7 @@
}
}
}
- }
- else {
+ } else {
byteRange = null;
}
@@ -221,8 +270,6 @@
((HttpResponse)response).setStatus(206);
}
- response.setHeader("Accept-Ranges", "bytes");
-
int pos = 0;
int posEnd;
while ((length = inputStream.read(buffer)) > -1) {
@@ -233,15 +280,11 @@
}
pos += length;
}
- }
- else {
+ } else {
if (contentLength != -1) {
response.setHeader("Content-Length",
Long.toString(contentLength));
}
- // Bug #9539: This resource reader does not support ranges
- response.setHeader("Accept-Ranges", "none");
-
while ((length = inputStream.read(buffer)) > -1) {
out.write(buffer, 0, length);
}
@@ -253,12 +296,13 @@
/**
* Generates the requested resource.
*/
- public void generate() throws IOException, ProcessingException {
+ public void generate()
+ throws IOException, ProcessingException {
try {
if (expires > 0) {
response.setDateHeader("Expires", System.currentTimeMillis()
+ expires);
- }
- else {
+ } else {
+ // See Bug #14048
response.addHeader("Vary", "Host");
}
@@ -267,18 +311,18 @@
response.setDateHeader("Last-Modified", lastModified);
}
+ InputStream inputStream;
try {
inputStream = inputSource.getInputStream();
- }
- catch (SourceException se) {
- throw SourceUtil.handle("Error during resolving of the input
stream", se);
+ } catch (SourceException e) {
+ throw SourceUtil.handle("Error during resolving of the input
stream", e);
}
- // Bugzilla Bug 25069, close inputStream in finally block
- // this will close inputStream even if processStream throws
+ // Bugzilla Bug #25069, close inputStream in finally block.
+ // This will close inputStream even if processStream throws
// an exception
try {
- processStream();
+ processStream(inputStream);
} finally {
if (inputStream != null) {
inputStream.close();
@@ -287,11 +331,10 @@
if (!quickTest) {
// if everything is ok, add this to the list of generated
documents
- // (see
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102921894301915&w=2 )
+ // (see
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102921894301915 )
documents.put(request.getRequestURI(), inputSource.getURI());
}
- }
- catch (IOException e) {
+ } catch (IOException e) {
getLogger().debug("Received an IOException, assuming client
severed connection on purpose");
}
}
@@ -301,18 +344,13 @@
*/
public String getMimeType() {
Context ctx = ObjectModelHelper.getContext(objectModel);
-
if (ctx != null) {
- if (ctx.getMimeType(source) != null) {
- return ctx.getMimeType(source);
+ final String mimeType = ctx.getMimeType(source);
+ if (mimeType != null) {
+ return mimeType;
}
- else {
- return inputSource.getMimeType();
- }
- }
- else {
- return inputSource.getMimeType();
}
- }
+ return inputSource.getMimeType();
+ }
}
1.52 +69 -51 cocoon-2.1/src/webapp/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/webapp/sitemap.xmap,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- sitemap.xmap 11 Jun 2004 21:38:10 -0000 1.51
+++ sitemap.xmap 23 Jun 2004 19:14:34 -0000 1.52
@@ -16,53 +16,52 @@
-->
<!--+
- | This is the 'heart' of Cocoon. The sitemap maps URI space to
+ | This is the 'heart' of Cocoon. The sitemap maps URI space to
| resources. It consists basicaly of two parts: components and
| pipelines. Pipelines are made out of components. There is such a
| vast number of components available that it would be impossible to
| describe them here, please refer to the accompanying
| documentation. For specific components, have a look also at the
| javadocs for them. Most pipelines are present to demonstrate some
- | feature or technique, often they are explained in more detail in
+ | feature or technique, often they are explained in more detail in
| the accompanying documentation. The sitemaps which come with each
| sample and each block will help to explain.
|
| CVS $Id$
+-->
-
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components ================================
-->
-
+
<map:components>
<!--+
| All pipelines consist at least of two components: a generator, that
| produces the content, and a serialiser, that delivers the content to
| the client.
- |
+ |
| More precisely: a generator generates SAX events and a serializer
| consumes these events and produces a byte stream.
- |
+ |
| Some things to note here: each generator has a unique name, this
| name is mapped to a java class, one name is declared as the default
| generator. Each generator may have additional configurations as
| child elements.
- |
+ |
| Additional attributes are targeted at the component manager. The
optional
| "label" attribute is relevant for the view concept below. The
optional
| "logger" attribute defines the logging category where messages
produced
| by a component should go. If there's no "logger" attribute, the
category
| used is the one defined for the "sitemap" component in cocoon.xconf.
- |
+ |
| We have chosen in this sitemap to use a different logging category
| for each component, which allows fine-grained classification of log
| messages. But you are free to use any category you want.
- |
+ |
| It is possible to have the same java class declared as different
| generators by using different names. No configuration options are
| shared between these instances, however.
- |
+ |
| All components follow this scheme.
+-->
<map:generators default="file">
@@ -80,6 +79,7 @@
<map:generator name="notifying"
src="org.apache.cocoon.sitemap.NotifyingGenerator"/>
</map:generators>
+
<!--+
| Transformers can be placed inside the pipeline between the generator
| and the serializer. You may have as many transformers as you
@@ -130,6 +130,7 @@
<map:transformer logger="sitemap.transformer.paginate" name="paginate"
src="org.apache.cocoon.transformation.pagination.Paginator"/>
</map:transformers>
+
<!--+
| Serializers consume SAX events and produce a character stream. Every
| pipeline needs to be terminated by a serializer.
@@ -137,26 +138,32 @@
<map:serializers default="html">
<map:serializer logger="sitemap.serializer.links" name="links"
src="org.apache.cocoon.serialization.LinkSerializer"/>
<map:serializer logger="sitemap.serializer.xml" mime-type="text/xml"
name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
+
<map:serializer logger="sitemap.serializer.html" mime-type="text/html"
name="html" pool-grow="4" pool-max="32" pool-min="4"
src="org.apache.cocoon.serialization.HTMLSerializer">
<doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
</map:serializer>
+
<map:serializer logger="sitemap.serializer.wml"
mime-type="text/vnd.wap.wml" name="wml"
src="org.apache.cocoon.serialization.XMLSerializer">
<doctype-public>-//WAPFORUM//DTD WML 1.1//EN</doctype-public>
<doctype-system>http://www.wapforum.org/DTD/wml_1.1.xml</doctype-system>
<encoding>ASCII</encoding>
<omit-xml-declaration>yes</omit-xml-declaration>
</map:serializer>
+
<map:serializer logger="sitemap.serializer.chtml" mime-type="text/html"
name="chtml" src="org.apache.cocoon.serialization.HTMLSerializer">
- <!--+ Compact HTML for Small Information Appliances,
+ <!--+
+ | Compact HTML for Small Information Appliances,
| based on http://www.w3.org/TR/1998/NOTE-compactHTML-19980209/
+ -->
<doctype-public>-//W3C//DTD Compact HTML 1.0 Draft//EN</doctype-public>
</map:serializer>
+
<map:serializer logger="sitemap.serializer.svgxml"
mime-type="image/svg+xml" name="svgxml"
src="org.apache.cocoon.serialization.XMLSerializer">
<doctype-public>-//W3C//DTD SVG 1.0//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd</doctype-system>
</map:serializer>
+
<map:serializer logger="sitemap.serializer.xhtml" mime-type="text/html"
name="xhtml" pool-grow="2" pool-max="64" pool-min="2"
src="org.apache.cocoon.serialization.XMLSerializer">
<!--+
| You can choose from Strict, Transitional, or Frameset XHTML.
@@ -177,11 +184,13 @@
<doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system>
<encoding>UTF-8</encoding>
</map:serializer>
+
<map:serializer logger="sitemap.serializer.xhtml"
mime-type="application/xhtml+xml" name="xhtml11" pool-grow="2" pool-max="64"
pool-min="2" src="org.apache.cocoon.serialization.XMLSerializer">
<doctype-public>-//W3C//DTD XHTML 1.1//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</doctype-system>
<encoding>UTF-8</encoding>
- </map:serializer>
+ </map:serializer>
+
<map:serializer logger="sitemap.serializer.text" mime-type="text/plain"
name="text" src="org.apache.cocoon.serialization.TextSerializer"/>
<map:serializer logger="sitemap.serializer.vrml" mime-type="model/vrml"
name="vrml" src="org.apache.cocoon.serialization.TextSerializer"/>
<map:serializer logger="sitemap.serializer.zip"
mime-type="application/zip" name="zip"
src="org.apache.cocoon.serialization.ZipArchiveSerializer"/>
@@ -191,6 +200,7 @@
<map:serializer logger="sitemap.serializer.sxi"
mime-type="application/vnd.sun.xml.impress" name="sxi"
src="org.apache.cocoon.serialization.ZipArchiveSerializer"/>
</map:serializers>
+
<!--+
| Readers circumvent the XML oriented SAX pipeline model, think of a
reader
| being a generator and a serializer at once thus a pipeline may not
@@ -198,7 +208,14 @@
| reader. They are useful for delivering binary content like images.
+-->
<map:readers default="resource">
- <map:reader logger="sitemap.reader.resource" name="resource"
pool-max="32" src="org.apache.cocoon.reading.ResourceReader"/>
+ <map:reader logger="sitemap.reader.resource" name="resource"
pool-max="32" src="org.apache.cocoon.reading.ResourceReader">
+ <!--+
+ | Resource reader has three configuration parameters:
+ <expires>-1</expires>
+ <quick-modified-test>false</quick-modified-test>
+ <byte-ranges>true</byte-ranges>
+ +-->
+ </map:reader>
<map:reader logger="sitemap.reader.image" name="image"
src="org.apache.cocoon.reading.ImageReader"/>
</map:readers>
@@ -255,7 +272,7 @@
<browser name="mozilla5" useragent="Netscape6/"/>
<browser name="netscape" useragent="Mozilla"/>
</map:selector>
-
+
<!--+
| Exception selector : used in <map:handle> errors to build different
pipelines
| depending on the error that occured.
@@ -273,10 +290,11 @@
<map:selector logger="sitemap.selector.request-method"
name="request-method" src="org.apache.cocoon.selection.RequestMethodSelector"/>
<map:selector logger="sitemap.selector.resource-exists"
name="resource-exists"
src="org.apache.cocoon.selection.ResourceExistsSelector"/>
<map:selector logger="sitemap.selector.request-parameter"
name="request-parameter"
src="org.apache.cocoon.selection.RequestParameterSelector">
- <!-- Define now which request parameter to use; or do it later,
- when using this selector, via "parameter-name" parameter.
- <parameter-name>myparam</parameter-name>
- -->
+ <!--+
+ | Define now which request parameter to use; or do it later,
+ | when using this selector, via "parameter-name" parameter.
+ <parameter-name>myparam</parameter-name>
+ +-->
</map:selector>
<map:selector logger="sitemap.selector.request-attribute"
name="request-attribute"
src="org.apache.cocoon.selection.RequestAttributeSelector">
<!-- <attribute-name>myparam</attribute-name> -->
@@ -295,9 +313,9 @@
<!--+
| Actions are executed during pipeline setup. Their purpose is to
| execute some code that doesn't involve touching the stream of
- | pipeline events. Example usage is to update databases, check
external
- | resources, etc.. The execution may fail or complete successfully.
Only
- | if the execution of the action was successful, the pipeline fragment
+ | pipeline events. Example usage is to update databases, check external
+ | resources, etc.. The execution may fail or complete successfully.
Only
+ | if the execution of the action was successful, the pipeline fragment
| nested inside the action element is executed, otherwise, it's skipped
| entirely and execution proceeds from the element right below the
action.
+-->
@@ -318,37 +336,37 @@
<!--+
| The different pipe implementations
- |
+ |
| NON-CACHING:
| The non caching implementation of cocoon pipelines.
- |
+ |
| CACHING:
| Traditional longest cacheable key caching.
- |
+ |
| CACHING-POINT:
- | The caching-point pipeline implements an extended
- | caching algorithm which is of particular benefit for use with
- | those pipelines that utilise cocoon-views and/or provide
- | drill-down functionality.
- |
+ | The caching-point pipeline implements an extended
+ | caching algorithm which is of particular benefit for use with
+ | those pipelines that utilise cocoon-views and/or provide
+ | drill-down functionality.
+ |
| The autoCachingPoint algorithim (if enabled) will automatically
| cache common elements of the pipeline currently being processed - as
well
| as the entire cacheable pipeline according to the "longest cacheable
key"
| algorithm.
- |
+ |
| Consider the following simple pipeline, where generator G is
labelled with
- | a cocoon-view enabling the pipeline to serialize data to either html
or pdf
+ | a cocoon-view enabling the pipeline to serialize data to either html
or pdf
| depending on the value of cocoon-view (as provided by the request):
| G - T - S(html)
| |__ T - S(pdf)
- |
- | If cocoon-view=html, then the caching-point algorithm will not only
cache
+ |
+ | If cocoon-view=html, then the caching-point algorithm will not only
cache
| the longest cacheable path, which would be GTS(html) but also the
| *common element* which in this case would be the results from G. If
the
| next request to this pipeline was cocoon-view=pdf, then there would
be no
| need to invoke the generator a second time, as it's value has
already been
| cached (provided G generates the same cache key)
- |
+ |
| Also note: One can switch "Off" autoCachingPoint and use
"pipeline-hints" to
| manually indicate that certain pipeline-components should be
considered as
| cache points.
@@ -361,7 +379,7 @@
| before sending it to the client. This has the advantage that in
case
| an error occurs during the processing of the SAX-pipeline,
Cocoon is still
| able to reset the response and send an error page instead.
Otherwise the
- | error page will be appended to the output already send to the
client.
+ | error page will be appended to the output already send to the
client.
| If you are generating larger pages, it might be benificial to
enable
| this parameter, so that output is gradually send to the client
as it
| is being generated.
@@ -387,7 +405,7 @@
| Views provide different, well, views to resources. Views are
| orthogonal to pipelines. Please refer to the docs.
|
- | It would be wise to disable any unneeded views in a
+ | It would be wise to disable any unneeded views in a
| production environment in order to avoid exposing data
| that you may not necessarily wish to.
+-->
@@ -472,17 +490,17 @@
<!-- welcome page -->
<map:match pattern="">
-
+
<!--+
| Start generating SAX events inside the pipeline. In this case,
| since no "type" attribute is specified, the default generator
| is used and this is a regular XML parser that reads the
- | given file from the URL included in the "src" attribute and
- | sends the events produced by the parser down the pipeline to
+ | given file from the URL included in the "src" attribute and
+ | sends the events produced by the parser down the pipeline to
| be processed by the next stage.
+-->
<map:generate src="welcome.xml"/>
-
+
<!--+
| This transformer gets the input SAX events and transforms them
| using the default transformer (the XSLT transformer) thus
@@ -493,12 +511,12 @@
<map:transform src="welcome.xslt">
<map:parameter name="contextPath" value="{request:contextPath}"/>
</map:transform>
-
+
<!--+
| The serializer concludes the SAX events journey into the pipeline
| since it serializes the events it receives into a representation
| depending on the serializer type. Here we choose the "XHMTL"
- | serializer, which will produce an XHTML representation of the
+ | serializer, which will produce an XHTML representation of the
| SAX stream.
+-->
<map:serialize type="xhtml"/>
@@ -506,9 +524,9 @@
<!--+
| The default matching is also capable of matching more than a
- | single request by the use of 'wildcards'. There are two kinds of
+ | single request by the use of 'wildcards'. There are two kinds of
| wildcards:
- |
+ |
| "*" means "anything that does not contain a path separator"
| "**" means "anything including path separators"
|
@@ -517,12 +535,12 @@
| inside the attributes. The URI-matching tokens are associated to
| numbered variables, as shown in the following match that processes
all
| the GIF images that are located in the 'images/' URL space but
- | not in any deeper levels. Note how requesting "images/logo.gif"
+ | not in any deeper levels. Note how requesting "images/logo.gif"
| triggers the matcher to create the token {1} = 'logo' which is
later
- | expanded into the src="" attribute of the reader, indicating
- | what file it has to read.
+ | expanded into the src="" attribute of the reader, indicating
+ | what file it has to read.
+-->
-
+
<!-- images -->
<map:match pattern="images/*.gif">
<map:read src="resources/images/{1}.gif" mime-type="images/gif"/>
@@ -537,7 +555,7 @@
<map:match pattern="scripts/*.js">
<map:read src="resources/scripts/{1}.js" mime-type="text/javascript"/>
</map:match>
-
+
<!-- favicon -->
<map:match pattern="**favicon.ico">
<map:read mime-type="image/x-icon" src="resources/icons/cocoon.ico"/>
@@ -560,7 +578,7 @@
<!-- win32 -->
<!--map:mount check-reload="yes" src="/Documents and Settings/{1}/My
Documents/My Website/" uri-prefix="~{1}"/-->
</map:match>
-
+
<!--+
| Redirect to the user directory if the ending slash is missing
| Cocoon doesn't do automatic translation of URLs because we
consider it