giacomo 01/04/04 08:42:49
Modified: src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/generation Tag: xml-cocoon2
AbstractGenerator.java
src/org/apache/cocoon/sitemap Tag: xml-cocoon2
SitemapComponentSelector.java
src/org/apache/cocoon/xml Tag: xml-cocoon2
AbstractXMLProducer.java
webapp Tag: xml-cocoon2 cocoon.xconf
Added: src/org/apache/cocoon/components/pipeline Tag: xml-cocoon2
EventPipeline.java NonCachingEventPipeline.java
NonCachingStreamPipeline.java StreamPipeline.java
Removed: src/org/apache/cocoon/sitemap Tag: xml-cocoon2
ResourcePipeline.java
Log:
First stab of Content Aggregation by refactoring ResourcePipeline.
The ResourcePipeline class is split into two components classes:
org.apache.cocoon.components.pipline.EventPipeline
This interface collects all XML producing components from
the sitemap (Generator, Transformers). A concrete implementation
of this Role is
org.apache.cocoon.components.pipeline.NonCachingEventPipeline.
org.apache.cocoon.components.pipeline.StreamPipeline
This interface collects a EventPipeline and a Serializer. A
concrete implementation of this Role is
org.apache.cocoon.components.pipeline.NonCachingStreamPipeline.
The generated sitemap (by sitemap.xsl file) uses these components
to collect the sitemap components for the .
Different implementations (e.g. different caching strategies) can
inow be implemented using those interfaces and be plugged into the
system via the cocoon.xconf file (go Carsten :) (go Carsten :) (go Carsten :)
(go Carsten :) (go Carsten :) (go Carsten :) (go Carsten :) (go Carsten :) (go
Carsten :).
Revision Changes Path
No revision
No revision
1.1.2.94 +63 -40
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
retrieving revision 1.1.2.93
retrieving revision 1.1.2.94
diff -u -r1.1.2.93 -r1.1.2.94
--- sitemap.xsl 2001/03/23 19:38:04 1.1.2.93
+++ sitemap.xsl 2001/04/04 15:42:40 1.1.2.94
@@ -82,7 +82,8 @@
import org.apache.cocoon.matching.Matcher;
import org.apache.cocoon.selection.Selector;
import org.apache.cocoon.sitemap.AbstractSitemap;
- import org.apache.cocoon.sitemap.ResourcePipeline;
+ import org.apache.cocoon.components.pipeline.StreamPipeline;
+ import org.apache.cocoon.components.pipeline.EventPipeline;
import org.apache.cocoon.sitemap.Sitemap;
import org.apache.cocoon.sitemap.ErrorNotifier;
import org.apache.cocoon.sitemap.Manager;
@@ -94,7 +95,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo
Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin
Loritsch</a>
- * @version CVS $Id: sitemap.xsl,v 1.1.2.93 2001/03/23 19:38:04 dims Exp
$
+ * @version CVS $Id: sitemap.xsl,v 1.1.2.94 2001/04/04 15:42:40 giacomo
Exp $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap
{
static final String LOCATION = "<xsl:value-of
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -294,15 +295,15 @@
<xsl:for-each select="/map:sitemap/map:resources/map:resource">
/**
* This is the internal resource named "<xsl:value-of
select="@name"/>"
- * @param pipeline A <code>ResourcePipeline</code>
holding the sitemap component collected so far
+ * @param pipeline A <code>StreamPipeline</code> holding
the sitemap component collected so far
* @param listOfMaps A <code>List</code> of Maps holding
replacement values for src attributes
* @param environment The <code>Environment</code>
requesting a resource
* @param cocoon_view The view of the resource requested
* @return Wether the request has been processed or not
* @exception Exception If an error occurs during request evaluation
and production
*/
- private boolean resource_<xsl:value-of select="translate(@name, '-
', '__')"/> (ResourcePipeline pipeline,
- List listOfMaps, Environment environment, String cocoon_view)
+ private boolean resource_<xsl:value-of select="translate(@name, '-
', '__')"/> (StreamPipeline pipeline,
+ EventPipeline eventPipeline, List listOfMaps, Environment
environment, String cocoon_view)
throws Exception {
Map map = null;
Parameters param = null;
@@ -315,14 +316,14 @@
<xsl:for-each select="/map:sitemap/map:views/map:view">
/**
* This is the method to produce the "<xsl:value-of
select="@name"/>" view of the requested resource
- * @param pipeline A <code>ResourcePipeline</code>
holding the sitemap component collected so far
+ * @param pipeline A <code>StreamPipeline</code> holding
the sitemap component collected so far
* @param listOfMaps A <code>List</code> of Maps holding
replacement values for src attributes
* @param environment The <code>Environment</code>
requesting a resource
* @return Wether the request has been processed or not
* @exception Exception If an error occurs during request evaluation
and production
*/
- private boolean view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (ResourcePipeline pipeline,
- List listOfMaps, Environment environment)
+ private boolean view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (StreamPipeline pipeline,
+ EventPipeline eventPipeline, List listOfMaps, Environment
environment)
throws Exception {
Map map = null;
Parameters param = null;
@@ -369,13 +370,30 @@
/**
* Process to producing the output to the specified
<code>OutputStream</code>.
*/
- public boolean process(Environment environment)
+ public boolean process(Environment environment) throws Exception {
+ /* the <code>EventPipeline</code> is used to collect the
xml producing sitemap
+ components and the <code>StreamPipeline</code> to
produce the requested resource */
+ EventPipeline eventPipeline =
(EventPipeline)this.manager.lookup("org.apache.cocoon.components.pipeline.EventPipeline");
+ StreamPipeline pipeline =
(StreamPipeline)this.manager.lookup("org.apache.cocoon.components.pipeline.StreamPipeline");
+ pipeline.setEventPipeline(eventPipeline);
+ boolean result = false;
+ try {
+ result = process (environment, pipeline, eventPipeline);
+ } catch (Exception e) {
+ getLogger().error("processing of resource failed", e);
+ throw e;
+ } finally {
+ manager.release(eventPipeline);
+ manager.release(pipeline);
+ }
+ return result;
+ }
+
+ /**
+ * Process to producing the output to the specified
<code>OutputStream</code>.
+ */
+ private final boolean process(Environment environment, StreamPipeline
pipeline, EventPipeline eventPipeline)
throws Exception {
- /* the <code>ResourcePipeline</code> used to collect the
sitemap
- components to produce the requested resource */
- ResourcePipeline pipeline = new ResourcePipeline ();
- pipeline.setLogger(getLogger());
- pipeline.compose(this.manager);
/* the <code>List</code> objects to hold the replacement
values
delivered from matchers and selectors to replace occurences of
XPath kind expressions in values of src attribute used with
@@ -421,14 +439,23 @@
<xsl:if test="(./map:handle-errors)">
private boolean error_process_<xsl:value-of
select="$pipeline-position"/> (Environment environment, Map objectModel,
Exception e)
throws Exception {
- ResourcePipeline pipeline = new ResourcePipeline ();
- pipeline.setLogger(getLogger());
- pipeline.compose(this.manager);
- List listOfMaps = (List)(new ArrayList());
- Map map;
- Parameters param;
- pipeline.setGenerator ("!error-notifier!", e.getMessage(),
emptyParam, e);
- <xsl:apply-templates select="./map:handle-errors/*"/>
+ StreamPipeline pipeline = null;
+ EventPipeline eventPipeline = null;
+ try {
+ eventPipeline =
(EventPipeline)this.manager.lookup("org.apache.cocoon.components.pipeline.EventPipeline");
+ pipeline =
(StreamPipeline)this.manager.lookup("org.apache.cocoon.components.pipeline.StreamPipeline");
+ pipeline.setEventPipeline(eventPipeline);
+ List listOfMaps = (List)(new ArrayList());
+ Map map;
+ Parameters param;
+ eventPipeline.setGenerator ("!error-notifier!",
e.getMessage(), emptyParam, e);
+ <xsl:apply-templates select="./map:handle-errors/*"/>
+ } catch (Exception ex) {
+ getLogger().error("error notifier barfs", ex);
+ throw e;
+ } finally {
+ this.manager.release(pipeline);
+ }
return false;
}
</xsl:if>
@@ -770,7 +797,7 @@
<xsl:template match="map:generate">
<xsl:call-template name="setup-component">
<xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:generators/@default"/>
- <xsl:with-param name="method">setGenerator</xsl:with-param>
+ <xsl:with-param
name="method">eventPipeline.setGenerator</xsl:with-param>
<xsl:with-param name="prefix">generator</xsl:with-param>
</xsl:call-template>
</xsl:template> <!-- match="map:generate" -->
@@ -779,7 +806,7 @@
<xsl:template match="map:transform">
<xsl:call-template name="setup-component">
<xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:transformers/@default"/>
- <xsl:with-param name="method">addTransformer</xsl:with-param>
+ <xsl:with-param
name="method">eventPipeline.addTransformer</xsl:with-param>
<xsl:with-param name="prefix">transformer</xsl:with-param>
</xsl:call-template>
</xsl:template> <!-- match="map:transformer" -->
@@ -788,7 +815,7 @@
<xsl:template match="map:serialize">
<xsl:call-template name="setup-component">
<xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:serializers/@default"/>
- <xsl:with-param name="method">setSerializer</xsl:with-param>
+ <xsl:with-param name="method">pipeline.setSerializer</xsl:with-param>
<xsl:with-param name="prefix">serializer</xsl:with-param>
<xsl:with-param name="mime-type" select="@mime-type"/>
</xsl:call-template>
@@ -807,8 +834,6 @@
} catch (Exception pipelineException<xsl:value-of
select="generate-id(.)"/>) {
getLogger().debug("Error processing pipeline",
pipelineException<xsl:value-of select="generate-id(.)"/>);
throw pipelineException<xsl:value-of select="generate-id(.)"/>;
- } finally {
- pipeline.dispose();
}
if(true) return result;
@@ -819,7 +844,7 @@
<xsl:template match="map:read">
<xsl:call-template name="setup-component">
<xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:readers/@default"/>
- <xsl:with-param name="method">setReader</xsl:with-param>
+ <xsl:with-param name="method">pipeline.setReader</xsl:with-param>
<xsl:with-param name="prefix">reader</xsl:with-param>
<xsl:with-param name="mime-type" select="@mime-type"/>
</xsl:call-template>
@@ -833,8 +858,6 @@
} catch (Exception RpipelineException<xsl:value-of
select="generate-id(.)"/>) {
getLogger().debug("Error processing pipeline",
RpipelineException<xsl:value-of select="generate-id(.)"/>);
throw RpipelineException<xsl:value-of select="generate-id(.)"/>;
- } finally {
- pipeline.dispose();
}
if(true) return result;
@@ -872,7 +895,7 @@
<!-- redirect to a internal resource definition -->
<xsl:when test="@resource">
- if(true)return resource_<xsl:value-of select="translate(@resource,
'- ', '__')"/>(pipeline, listOfMaps, environment, cocoon_view);
+ if(true)return resource_<xsl:value-of select="translate(@resource,
'- ', '__')"/>(pipeline, eventPipeline, listOfMaps, environment, cocoon_view);
</xsl:when>
<!-- redirect to a external resource definition with optional session
mode attribute. Let the environment do the redirect -->
@@ -904,7 +927,7 @@
<xsl:template match="map:label">
<xsl:apply-templates/>
if ("<xsl:value-of select="@name"/>".equals(cocoon_view))
- return view_<xsl:value-of select="translate(@name, '- ', '__')"/>
(pipeline, listOfMaps, environment);
+ return view_<xsl:value-of select="translate(@name, '- ', '__')"/>
(pipeline, eventPipeline, listOfMaps, environment);
</xsl:template> <!-- match="map:label" -->
<!-- collect parameter definitions -->
@@ -1031,12 +1054,12 @@
<xsl:for-each select="/map:sitemap/map:views/map:[EMAIL
PROTECTED]'last']">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
getLogger().debug("View <xsl:value-of select="@name"/>");
- return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, listOfMaps, environment);
+ return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, eventPipeline, listOfMaps, environment);
}
</xsl:for-each>
// performing link translation
if (environment.getObjectModel().containsKey(Constants.LINK_OBJECT))
{
- pipeline.addTransformer ("!link-translator!", null, emptyParam);
+ eventPipeline.addTransformer ("!link-translator!", null,
emptyParam);
}
</xsl:if>
</xsl:if>
@@ -1086,12 +1109,12 @@
<xsl:choose>
<xsl:when test="$mime-type!=''">
getLogger().debug("Mime-type: <xsl:value-of
select="$mime-type"/>");
- pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
+ <xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
null, <xsl:value-of select="$component-param"/>,"<xsl:value-of
select="$mime-type"/>"
);
</xsl:when>
<xsl:otherwise>
- pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
+ <xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
null, <xsl:value-of select="$component-param"/>
);
</xsl:otherwise>
@@ -1102,12 +1125,12 @@
<xsl:choose>
<xsl:when test="$mime-type!=''">
getLogger().debug("Mime-type: <xsl:value-of
select="$mime-type"/>");
- pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
+ <xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
substitute(listOfMaps,"<xsl:value-of
select="$component-source"/>"),
<xsl:value-of select="$component-param"/>,"<xsl:value-of
select="$mime-type"/>");
</xsl:when>
<xsl:otherwise>
- pipeline.<xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
+ <xsl:value-of select="$method"/> ("<xsl:value-of
select="$component-type"/>",
substitute(listOfMaps,"<xsl:value-of
select="$component-source"/>"),
<xsl:value-of select="$component-param"/>);
</xsl:otherwise>
@@ -1128,14 +1151,14 @@
<xsl:if test="$component-label">
<xsl:for-each select="/map:sitemap/map:views/map:[EMAIL PROTECTED]">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
- return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, listOfMaps, environment);
+ return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, eventPipeline, listOfMaps, environment);
}
</xsl:for-each>
</xsl:if>
<xsl:if test="$prefix='generator'">
<xsl:for-each select="/map:sitemap/map:views/map:[EMAIL
PROTECTED]'first']">
if ("<xsl:value-of select="@name"/>".equals(cocoon_view)) {
- return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, listOfMaps, environment);
+ return view_<xsl:value-of select="translate(@name, '- ',
'__')"/> (pipeline, eventPipeline, listOfMaps, environment);
}
</xsl:for-each>
</xsl:if>
No revision
No revision
1.1.2.1 +28 -0
xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/EventPipeline.java
1.1.2.1 +249 -0
xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/NonCachingEventPipeline.java
1.1.2.1 +262 -0
xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/NonCachingStreamPipeline.java
1.1.2.1 +34 -0
xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/StreamPipeline.java
No revision
No revision
1.1.2.11 +2 -4
xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractGenerator.java
Index: AbstractGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractGenerator.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- AbstractGenerator.java 2001/03/19 21:20:31 1.1.2.10
+++ AbstractGenerator.java 2001/04/04 15:42:44 1.1.2.11
@@ -11,7 +11,6 @@
import java.io.IOException;
import org.apache.avalon.configuration.Parameters;
-import org.apache.avalon.Recyclable;
import org.apache.cocoon.xml.AbstractXMLProducer;
import org.apache.cocoon.ProcessingException;
@@ -23,10 +22,9 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/03/19 21:20:31 $
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/04 15:42:44 $
*/
-public abstract class AbstractGenerator extends AbstractXMLProducer
-implements Generator, Recyclable {
+public abstract class AbstractGenerator extends AbstractXMLProducer
implements Generator {
/** The current <code>EntityResolver</code>. */
protected EntityResolver resolver=null;
No revision
No revision
1.1.2.5 +2 -2
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponentSelector.java
Index: SitemapComponentSelector.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponentSelector.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- SitemapComponentSelector.java 2001/03/12 05:18:07 1.1.2.4
+++ SitemapComponentSelector.java 2001/04/04 15:42:46 1.1.2.5
@@ -24,7 +24,7 @@
/** Default component manager for Cocoon's sitemap components.
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Id: SitemapComponentSelector.java,v 1.1.2.4 2001/03/12
05:18:07 bloritsch Exp $
+ * @version CVS $Id: SitemapComponentSelector.java,v 1.1.2.5 2001/04/04
15:42:46 giacomo Exp $
*/
public class SitemapComponentSelector extends CocoonComponentSelector {
HashMap mime_types;
@@ -36,7 +36,7 @@
this.mime_types = new HashMap();
}
- protected String getMimeTypeForRole(String role) {
+ public String getMimeTypeForRole(String role) {
return (String) this.mime_types.get(role);
}
No revision
No revision
1.1.2.10 +6 -1
xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLProducer.java
Index: AbstractXMLProducer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLProducer.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- AbstractXMLProducer.java 2001/02/12 14:17:47 1.1.2.9
+++ AbstractXMLProducer.java 2001/04/04 15:42:47 1.1.2.10
@@ -19,10 +19,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/02/12 14:17:47 $
+ * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/04/04 15:42:47 $
*/
public abstract class AbstractXMLProducer extends AbstractLoggable
implements XMLProducer, Recyclable {
+ /** The <code>XMLConsumer</code> receiving SAX events. */
+ protected XMLConsumer xmlConsumer;
+
/** The <code>ContentHandler</code> receiving SAX events. */
protected ContentHandler contentHandler;
@@ -36,6 +39,7 @@
* and <code>setLexicalHandler(consumer)</code>.
*/
public void setConsumer(XMLConsumer consumer) {
+ this.xmlConsumer = consumer;
this.contentHandler = consumer;
this.lexicalHandler = consumer;
}
@@ -68,6 +72,7 @@
* Recycle the producer by removing references
*/
public void recycle() {
+ this.xmlConsumer = null;
this.contentHandler = null;
this.lexicalHandler = null;
}
No revision
No revision
1.1.2.27 +6 -0 xml-cocoon/webapp/Attic/cocoon.xconf
Index: cocoon.xconf
===================================================================
RCS file: /home/cvs/xml-cocoon/webapp/Attic/cocoon.xconf,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.27
diff -u -r1.1.2.26 -r1.1.2.27
--- cocoon.xconf 2001/03/12 05:18:10 1.1.2.26
+++ cocoon.xconf 2001/04/04 15:42:48 1.1.2.27
@@ -90,5 +90,11 @@
<sax-connector
class="org.apache.cocoon.components.saxconnector.NullSAXConnector"/>
+ <component role="org.apache.cocoon.components.pipeline.StreamPipeline"
+
class="org.apache.cocoon.components.pipeline.NonCachingStreamPipeline"/>
+
+ <component role="org.apache.cocoon.components.pipeline.EventPipeline"
+
class="org.apache.cocoon.components.pipeline.NonCachingEventPipeline"/>
+
<sitemap file="sitemap.xmap"/>
</cocoon>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]