You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2002/09/09 14:00:42 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap AggregateNode.java GenerateNode.java HandleErrorsNode.java SerializeNode.java TransformNode.java
sylvain 2002/09/09 05:00:42
Modified: src/java/org/apache/cocoon/components/pipeline
AbstractProcessingPipeline.java
ProcessingPipeline.java
src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
CachingPointProcessingPipeline.java
src/java/org/apache/cocoon/components/profiler
ProfilingCachingProcessingPipeline.java
ProfilingNonCachingProcessingPipeline.java
src/java/org/apache/cocoon/components/treeprocessor
DefaultTreeBuilder.java
PipelineEventComponentProcessingNode.java
src/java/org/apache/cocoon/components/treeprocessor/sitemap
AggregateNode.java GenerateNode.java
HandleErrorsNode.java SerializeNode.java
TransformNode.java
Log:
Apply patch #12227 (pipeline hints)
Submitted by Michael Melhem <mi...@fztig938.bank.dresdner.net>
Revision Changes Path
1.21 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- AbstractProcessingPipeline.java 13 Aug 2002 12:49:22 -0000 1.20
+++ AbstractProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.21
@@ -222,7 +222,7 @@
* @param param the parameters for the generator.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void setGenerator (String role, String source, Parameters param)
+ public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
if (this.generator != null) {
throw new ProcessingException ("Generator already set. You can only select one Generator (" + role + ")");
@@ -256,7 +256,7 @@
* @param param the parameters for the transfomer.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void addTransformer (String role, String source, Parameters param)
+ public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
if (this.reader != null) {
throw new ProcessingException ("Reader already set. You cannot use a transformer with a reader.");
@@ -284,7 +284,7 @@
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- public void setSerializer (String role, String source, Parameters param, String mimeType)
+ public void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException {
if (this.serializer != null) {
throw new ProcessingException ("Serializer already set. You can only select one Serializer (" + role + ")");
1.11 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Index: ProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProcessingPipeline.java 9 Aug 2002 07:47:16 -0000 1.10
+++ ProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.11
@@ -112,7 +112,7 @@
* @param param the parameters for the generator.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- void setGenerator (String role, String source, Parameters param)
+ void setGenerator (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException;
/**
@@ -137,14 +137,14 @@
* @param param the parameters for the transfomer.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- void addTransformer (String role, String source, Parameters param)
+ void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException;
/**
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- void setSerializer (String role, String source, Parameters param, String mimeType)
+ void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException;
/**
1.6 +7 -7 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Index: AbstractCachingProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractCachingProcessingPipeline.java 13 Aug 2002 12:49:22 -0000 1.5
+++ AbstractCachingProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.6
@@ -161,18 +161,18 @@
/**
* Set the generator.
*/
- public void setGenerator (String role, String source, Parameters param)
+ public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.setGenerator(role, source, param);
+ super.setGenerator(role, source, param, hintParam);
this.generatorRole = role;
}
/**
* Add a transformer.
*/
- public void addTransformer (String role, String source, Parameters param)
+ public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.addTransformer(role, source, param);
+ super.addTransformer(role, source, param, hintParam);
this.transformerRoles.add(role);
}
@@ -180,9 +180,9 @@
/**
* Set the serializer.
*/
- public void setSerializer (String role, String source, Parameters param, String mimeType)
+ public void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException {
- super.setSerializer(role, source, param, mimeType);
+ super.setSerializer(role, source, param, hintParam, mimeType);
this.serializerRole = role;
}
1.4 +48 -9 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
Index: CachingPointProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CachingPointProcessingPipeline.java 13 Aug 2002 09:58:30 -0000 1.3
+++ CachingPointProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.4
@@ -123,22 +123,61 @@
}
}
+ /**
+ * Set the generator.
+ */
+ public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
+ throws ProcessingException {
+ super.setGenerator(role, source, param, hintParam);
+
+ // check the hint param for a "caching-point" hint
+ String pipelinehint = null;
+ try {
+ pipelinehint = hintParam.getParameter("hint");
+ getLogger().debug("pipeline-hint is: " + pipelinehint);
+ }
+ catch (Exception ex)
+ {
+ getLogger().warn("pipeline-hint Exception, pipeline-hint ignored: " + ex);
+ }
+
+ // if this generator is manually set to "caching-point" (via pipeline-hint)
+ // then ensure the next component is caching.
+ if ((pipelinehint != null) && pipelinehint.equals("caching-point")) {
+ this.nextIsCachePoint=true;
+ }
+
+ }
+
/**
* Add a transformer.
*/
- public void addTransformer (String role, String source, Parameters param)
+ public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.addTransformer(role, source, param);
+ super.addTransformer(role, source, param, hintParam);
+ // check the hint param for a "caching-point" hint
+ String pipelinehint = null;
+ try {
+ pipelinehint = hintParam.getParameter("hint");
+ getLogger().debug("pipeline-hint is: " + pipelinehint);
+ }
+ catch (Exception ex)
+ {
+ getLogger().warn("pipeline-hint Exception, pipeline-hint ignored: " + ex);
+ }
+
// add caching point flag
// default value is false
this.isCachePoint.add(new Boolean(this.nextIsCachePoint));
this.nextIsCachePoint = false;
- //REVISIT: Alter the interface to pass an extra "pipeline-hint" paramater
- // and add pipeline-hint check for manual "caching-point"
-
+ // if this transformer is manually set to "caching-point" (via pipeline-hint)
+ // then ensure the next component is caching.
+ if ((pipelinehint != null) && pipelinehint.equals("caching-point")) {
+ this.nextIsCachePoint=true;
+ }
}
@@ -179,11 +218,11 @@
this.cache.store(environment.getObjectModel(),
this.pipelineCacheKey.copy(),
response);
- //
+ //
// Scan back along the pipelineCacheKey for
// for any cachepoint(s)
- //
- this.pipelineCacheKey.removeUntilCachePoint();
+ //
+ this.pipelineCacheKey.removeUntilCachePoint();
//
// adjust the validities object
1.7 +7 -7 xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java
Index: ProfilingCachingProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProfilingCachingProcessingPipeline.java 3 Sep 2002 07:44:31 -0000 1.6
+++ ProfilingCachingProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.7
@@ -118,10 +118,10 @@
* @param param the parameters for the generator.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void setGenerator (String role, String source, Parameters param)
+ public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.setGenerator(role, source, param);
+ super.setGenerator(role, source, param, hintParam);
if(this.data == null)
this.data = new ProfilerData();
@@ -140,10 +140,10 @@
* @param param the parameters for the transfomer.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void addTransformer (String role, String source, Parameters param)
+ public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.addTransformer(role, source, param);
+ super.addTransformer(role, source, param, hintParam);
if(this.data == null)
this.data = new ProfilerData();
@@ -154,10 +154,10 @@
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- public void setSerializer (String role, String source, Parameters param, String mimeType)
+ public void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException {
- super.setSerializer(role, source, param, mimeType);
+ super.setSerializer(role, source, param, hintParam, mimeType);
if(this.data == null)
this.data = new ProfilerData();
1.7 +7 -7 xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java
Index: ProfilingNonCachingProcessingPipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ProfilingNonCachingProcessingPipeline.java 3 Sep 2002 07:44:31 -0000 1.6
+++ ProfilingNonCachingProcessingPipeline.java 9 Sep 2002 12:00:41 -0000 1.7
@@ -122,10 +122,10 @@
* @param param the parameters for the generator.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void setGenerator (String role, String source, Parameters param)
+ public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.setGenerator(role, source, param);
+ super.setGenerator(role, source, param, hintParam);
if(this.data == null)
this.data = new ProfilerData();
@@ -144,10 +144,10 @@
* @param param the parameters for the transfomer.
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void addTransformer (String role, String source, Parameters param)
+ public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
throws ProcessingException {
- super.addTransformer(role, source, param);
+ super.addTransformer(role, source, param, hintParam);
if(this.data == null)
this.data = new ProfilerData();
@@ -158,10 +158,10 @@
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- public void setSerializer (String role, String source, Parameters param, String mimeType)
+ public void setSerializer (String role, String source, Parameters param, Parameters hintParam, String mimeType)
throws ProcessingException {
- super.setSerializer(role, source, param, mimeType);
+ super.setSerializer(role, source, param, hintParam, mimeType);
if(this.data == null)
this.data = new ProfilerData();
1.12 +47 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
Index: DefaultTreeBuilder.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DefaultTreeBuilder.java 31 Jul 2002 13:13:26 -0000 1.11
+++ DefaultTreeBuilder.java 9 Sep 2002 12:00:41 -0000 1.12
@@ -476,6 +476,12 @@
((ParameterizableProcessingNode)node).setParameters(params);
}
+ if (node instanceof PipelineEventComponentProcessingNode) {
+ Map params = getHintParameters(config);
+ ((PipelineEventComponentProcessingNode)node).setPipelineHints(params);
+ }
+
+
if (node instanceof Initializable) {
this.initializableNodes.add(node);
}
@@ -486,6 +492,46 @@
return node;
}
+
+ /**
+ * Method to extract pieline-hint parameters from the hint attribute
+ */
+ protected Map getHintParameters(Configuration config) throws ConfigurationException {
+ String expression = config.getAttribute("hint",null);
+
+ if (expression == null)
+ return null;
+
+ Map params = new HashMap();
+
+ try {
+ // REVIST: hint needs to be parsed into name value pairs.
+ // At the moment hint value is simply passed through
+ // as a whole and not parsed!
+ //
+ // Syntax for pipeline hints (as Proposed by Sylvain Wallez):
+ // A hints attribute has one or more comma separated hints
+ // hints-attr :: hint [ ',' hint ]*
+ // A hint is a name and an optional value
+ // If there is no value, it is considered as a boolean "true"
+ // hint :: litteral [ '=' litteral ]
+ // litteral :: <a character string where ',' and '=' must be escaped with '\'>
+ //
+ // This allows the following :
+ // pipeline-hint="caching-point, connector=profiling"
+ params.put( VariableResolverFactory.getResolver("hint", this.manager),
+ VariableResolverFactory.getResolver(expression, this.manager));
+ }
+ catch(PatternException pe) {
+ String msg = "Invalid pattern '" + expression + "' at " + config.getLocation();
+ getLogger().error(msg, pe);
+ throw new ConfigurationException(msg, pe);
+ }
+
+ return params;
+
+ }
+
/**
* Get <xxx:parameter> elements as a <code>Map</code> of </code>ListOfMapResolver</code>s,
1.2 +7 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/PipelineEventComponentProcessingNode.java
Index: PipelineEventComponentProcessingNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/PipelineEventComponentProcessingNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PipelineEventComponentProcessingNode.java 9 Aug 2002 07:47:17 -0000 1.1
+++ PipelineEventComponentProcessingNode.java 9 Sep 2002 12:00:41 -0000 1.2
@@ -63,9 +63,15 @@
public abstract class PipelineEventComponentProcessingNode extends AbstractProcessingNode {
protected Map views;
+ protected Map pipelineHints;
public void setViews(Map views) {
this.views = views;
+ }
+
+ // Set any pipeline-hint parameters
+ public void setPipelineHints(Map parameterMap) {
+ this.pipelineHints = parameterMap;
}
public boolean hasViews() {
1.7 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java
Index: AggregateNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AggregateNode.java 8 Aug 2002 03:21:28 -0000 1.6
+++ AggregateNode.java 9 Sep 2002 12:00:42 -0000 1.7
@@ -126,7 +126,7 @@
// Setup aggregator
ProcessingPipeline processingPipeline = context.getProcessingPipeline();
- processingPipeline.setGenerator("<aggregator>", null, Parameters.EMPTY_PARAMETERS);
+ processingPipeline.setGenerator("<aggregator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
ContentAggregator aggregator = (ContentAggregator)processingPipeline.getGenerator();
aggregator.setRootElement(
1.7 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java
Index: GenerateNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GenerateNode.java 9 Aug 2002 07:47:17 -0000 1.6
+++ GenerateNode.java 9 Sep 2002 12:00:42 -0000 1.7
@@ -99,7 +99,8 @@
context.getProcessingPipeline().setGenerator(
this.generatorName,
source.resolve(mapStack, objectModel),
- VariableResolver.buildParameters(this.parameters, mapStack, objectModel)
+ VariableResolver.buildParameters(this.parameters, mapStack, objectModel),
+ VariableResolver.buildParameters(this.pipelineHints, mapStack, objectModel)
);
1.4 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
Index: HandleErrorsNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HandleErrorsNode.java 8 Aug 2002 03:21:28 -0000 1.3
+++ HandleErrorsNode.java 9 Sep 2002 12:00:42 -0000 1.4
@@ -96,7 +96,7 @@
getLogger().info("Processing handle-errors at " + getLocation());
}
- context.getProcessingPipeline().setGenerator("<notifier>", "", Parameters.EMPTY_PARAMETERS);
+ context.getProcessingPipeline().setGenerator("<notifier>", "", Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
return invokeNodes(this.children, env, context);
}
1.6 +7 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java
Index: SerializeNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SerializeNode.java 9 Aug 2002 07:47:17 -0000 1.5
+++ SerializeNode.java 9 Sep 2002 12:00:42 -0000 1.6
@@ -61,6 +61,7 @@
import org.apache.cocoon.components.treeprocessor.InvokeContext;
import org.apache.cocoon.components.treeprocessor.PipelineEventComponentProcessingNode;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
import java.util.*;
/**
@@ -119,16 +120,20 @@
// Perform link translation if requested
if (env.getObjectModel().containsKey(Constants.LINK_OBJECT)) {
context.getProcessingPipeline().addTransformer(
- "<translator>", null, Parameters.EMPTY_PARAMETERS
+ "<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS
);
}
ProcessingPipeline pipeline = context.getProcessingPipeline();
+ List mapStack = context.getMapStack();
+ Map objectModel = env.getObjectModel();
+
pipeline.setSerializer(
this.serializerName,
null,
Parameters.EMPTY_PARAMETERS, // No parameters on serializers
+ VariableResolver.buildParameters(this.pipelineHints, mapStack, objectModel),
this.mimeType
);
1.6 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNode.java
Index: TransformNode.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNode.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TransformNode.java 9 Aug 2002 07:47:17 -0000 1.5
+++ TransformNode.java 9 Sep 2002 12:00:42 -0000 1.6
@@ -96,7 +96,8 @@
context.getProcessingPipeline().addTransformer(
this.transformerName,
source.resolve(mapStack, objectModel),
- VariableResolver.buildParameters(this.parameters, mapStack, objectModel)
+ VariableResolver.buildParameters(this.parameters, mapStack, objectModel),
+ VariableResolver.buildParameters(this.pipelineHints, mapStack, objectModel)
);
// Check view
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org