unico 2004/02/22 07:07:58
Modified: src/java/org/apache/cocoon/components/cprocessor/sitemap
SerializeNode.java GenerateNode.java
TransformNode.java ReadNode.java
src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
src/java/org/apache/cocoon/components/pipeline
AbstractProcessingPipeline.java
Log:
use 'hint' instead of 'role' for component lookups
Revision Changes Path
1.5 +3 -13
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/SerializeNode.java
Index: SerializeNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/SerializeNode.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SerializeNode.java 28 Jan 2004 17:25:30 -0000 1.4
+++ SerializeNode.java 22 Feb 2004 15:07:57 -0000 1.5
@@ -81,7 +81,6 @@
private VariableResolver m_mimeType;
private int m_statusCode;
- private String m_serializerRole;
public SerializeNode() {
}
@@ -97,16 +96,7 @@
}
m_statusCode = config.getAttributeAsInteger("status-code",-1);
}
-
- public void initialize() throws Exception {
- super.initialize();
- m_serializerRole = Serializer.ROLE;
- String hint = m_component.getComponentHint();
- if (hint != null) {
- m_serializerRole += "/" + hint;
- }
- }
-
+
public final boolean invoke(Environment env, InvokeContext context)
throws Exception {
//inform the pipeline that we have a branch point
@@ -147,7 +137,7 @@
}
pipeline.setSerializer(
- m_serializerRole,
+ m_component.getComponentHint(),
null,
VariableResolver.buildParameters(m_parameters, context,
objectModel),
super.m_pipelineHints == null
1.6 +2 -12
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/GenerateNode.java
Index: GenerateNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/GenerateNode.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GenerateNode.java 28 Jan 2004 17:25:30 -0000 1.5
+++ GenerateNode.java 22 Feb 2004 15:07:57 -0000 1.6
@@ -79,7 +79,6 @@
implements ProcessingNode {
private VariableResolver m_src;
- private String m_generatorRole;
public GenerateNode() {
}
@@ -96,21 +95,12 @@
super.m_labels.add(ViewNode.FIRST_POS_LABEL);
}
- public void initialize() throws Exception {
- super.initialize();
- m_generatorRole = Generator.ROLE;
- String hint = m_component.getComponentHint();
- if (hint != null) {
- m_generatorRole += "/" + hint;
- }
- }
-
public final boolean invoke(Environment env, InvokeContext context)
throws Exception {
Map objectModel = env.getObjectModel();
context.getProcessingPipeline().setGenerator(
- m_generatorRole,
+ super.m_component.getComponentHint(),
m_src.resolve(context, objectModel),
VariableResolver.buildParameters(super.m_parameters, context,
objectModel),
super.m_pipelineHints == null
1.4 +2 -12
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/TransformNode.java
Index: TransformNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/TransformNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformNode.java 28 Jan 2004 17:25:30 -0000 1.3
+++ TransformNode.java 22 Feb 2004 15:07:57 -0000 1.4
@@ -77,7 +77,6 @@
public class TransformNode extends ViewablePipelineComponentNode {
private VariableResolver m_src;
- private String m_transformerRole;
public TransformNode() {
}
@@ -93,21 +92,12 @@
}
}
- public void initialize() throws Exception {
- super.initialize();
- m_transformerRole = Transformer.ROLE;
- String hint = m_component.getComponentHint();
- if (hint != null) {
- m_transformerRole += "/" + hint;
- }
- }
-
public final boolean invoke(Environment env, InvokeContext context)
throws Exception {
Map objectModel = env.getObjectModel();
context.getProcessingPipeline().addTransformer(
- m_transformerRole,
+ m_component.getComponentHint(),
m_src.resolve(context, objectModel),
VariableResolver.buildParameters(super.m_parameters, context,
objectModel),
super.m_pipelineHints == null
1.4 +2 -8
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ReadNode.java
Index: ReadNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ReadNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ReadNode.java 28 Jan 2004 17:25:30 -0000 1.3
+++ ReadNode.java 22 Feb 2004 15:07:57 -0000 1.4
@@ -80,7 +80,6 @@
private VariableResolver m_src;
private VariableResolver m_mimeType;
private int m_statusCode;
- private String m_readerLookupKey;
public ReadNode() {
}
@@ -98,11 +97,6 @@
}
m_statusCode = config.getAttributeAsInteger("status-code",-1);
m_type = config.getAttribute("type",null);
-
- m_readerLookupKey = Reader.ROLE;
- if (m_type != null) {
- m_readerLookupKey += "/" + m_type;
- }
}
public final boolean invoke(Environment env, InvokeContext context)
throws Exception {
@@ -118,7 +112,7 @@
}
pipeline.setReader(
- m_readerLookupKey,
+ m_type,
m_src.resolve(context, objectModel),
VariableResolver.buildParameters(m_parameters, context,
objectModel),
mimeType
1.21 +30 -30
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Index: AbstractCachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- AbstractCachingProcessingPipeline.java 5 Jan 2004 13:54:37 -0000
1.20
+++ AbstractCachingProcessingPipeline.java 22 Feb 2004 15:07:58 -0000
1.21
@@ -81,17 +81,17 @@
public abstract class AbstractCachingProcessingPipeline
extends BaseCachingProcessingPipeline {
- /** The role name of the generator */
- protected String generatorRole;
+ /** The generator hint */
+ protected String generatorHint;
- /** The role names of the transfomrers */
- protected ArrayList transformerRoles = new ArrayList();
+ /** The transformers hints */
+ protected ArrayList transformerHints = new ArrayList();
- /** The role name of the serializer */
- protected String serializerRole;
+ /** The serializer hint */
+ protected String serializerHint;
- /** The role name of the reader */
- protected String readerRole;
+ /** The reader hint */
+ protected String readerHint;
/** The cached byte stream */
protected byte[] cachedResponse;
@@ -125,7 +125,7 @@
* Abstract methods defined in subclasses
*/
protected abstract void cacheResults(Environment environment,
OutputStream os) throws Exception;
- protected abstract ComponentCacheKey newComponentCacheKey(int type,
String role,Serializable key);
+ protected abstract ComponentCacheKey newComponentCacheKey(int type,
String hint,Serializable key);
protected abstract void connectCachingPipeline(Environment
environment) throws ProcessingException;
/**
@@ -149,38 +149,38 @@
/**
* Set the generator.
*/
- public void setGenerator (String role, String source, Parameters param,
Parameters hintParam)
+ public void setGenerator (String hint, String source, Parameters param,
Parameters hintParam)
throws ProcessingException {
- super.setGenerator(role, source, param, hintParam);
- this.generatorRole = role;
+ super.setGenerator(hint, source, param, hintParam);
+ this.generatorHint = hint;
}
/**
* Add a transformer.
*/
- public void addTransformer (String role, String source, Parameters
param, Parameters hintParam)
+ public void addTransformer (String hint, String source, Parameters
param, Parameters hintParam)
throws ProcessingException {
- super.addTransformer(role, source, param, hintParam);
- this.transformerRoles.add(role);
+ super.addTransformer(hint, source, param, hintParam);
+ this.transformerHints.add(hint);
}
/**
* Set the serializer.
*/
- public void setSerializer (String role, String source, Parameters param,
Parameters hintParam, String mimeType)
+ public void setSerializer (String hint, String source, Parameters param,
Parameters hintParam, String mimeType)
throws ProcessingException {
- super.setSerializer(role, source, param, hintParam, mimeType);
- this.serializerRole = role;
+ super.setSerializer(hint, source, param, hintParam, mimeType);
+ this.serializerHint = hint;
}
/**
* Set the Reader.
*/
- public void setReader (String role, String source, Parameters param,
String mimeType)
+ public void setReader (String hint, String source, Parameters param,
String mimeType)
throws ProcessingException {
- super.setReader(role, source, param, mimeType);
- this.readerRole = role;
+ super.setReader(hint, source, param, mimeType);
+ this.readerHint = hint;
}
/**
@@ -320,7 +320,7 @@
if (key != null) {
this.toCacheKey = new PipelineCacheKey();
this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Generator,
- this.generatorRole,
+ this.generatorHint,
key)
);
@@ -338,7 +338,7 @@
}
if (key != null) {
this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Transformer,
-
(String)this.transformerRoles.get(this.firstNotCacheableTransformerIndex),
+
(String)this.transformerHints.get(this.firstNotCacheableTransformerIndex),
key));
this.firstNotCacheableTransformerIndex++;
@@ -357,7 +357,7 @@
}
if (key != null) {
this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Serializer,
- this.serializerRole,
+ this.serializerHint,
key)
);
this.cacheCompleteResponse = true;
@@ -683,7 +683,7 @@
// response is cacheable, build the key
pcKey = new PipelineCacheKey();
pcKey.addKey(new
ComponentCacheKey(ComponentCacheKey.ComponentType_Reader,
- this.readerRole,
+ this.readerHint,
readerKey)
);
@@ -898,10 +898,10 @@
*/
public void recycle() {
- this.generatorRole = null;
- this.transformerRoles.clear();
- this.serializerRole = null;
- this.readerRole = null;
+ this.generatorHint = null;
+ this.transformerHints.clear();
+ this.serializerHint = null;
+ this.readerHint = null;
this.fromCacheKey = null;
this.cachedResponse = null;
1.32 +24 -20
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- AbstractProcessingPipeline.java 13 Feb 2004 16:03:14 -0000 1.31
+++ AbstractProcessingPipeline.java 22 Feb 2004 15:07:58 -0000 1.32
@@ -213,26 +213,27 @@
* from the latest <code>ComponentManager</code> given by
<code>compose()</code>
* or <code>recompose()</code>.
*
- * @param role the generator role in the component manager.
+ * @param hint the generator hint in the component manager.
* @param source the source where to produce XML from, or
<code>null</code> if no
* source is given.
* @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,
Parameters hintParam)
+ public void setGenerator (String hint, String source, Parameters param,
Parameters hintParam)
throws ProcessingException {
if (this.generator != null) {
- throw new ProcessingException ("Generator already set. Cannot
set generator '" + role +
+ throw new ProcessingException ("Generator already set. Cannot
set generator '" + hint +
"' at " + getLocation(param));
}
if (this.reader != null) {
- throw new ProcessingException ("Reader already set. Cannot set
generator '" + role +
+ throw new ProcessingException ("Reader already set. Cannot set
generator '" + hint +
"' at " + getLocation(param));
}
try {
+ String role = hint == null ? Generator.ROLE : Generator.ROLE +
"/" + hint;
this.generator = (Generator) newManager.lookup(role);
} catch (ServiceException ce) {
- throw new ProcessingException("Lookup of generator selector
failed at " +getLocation(param), ce);
+ throw new ProcessingException("Lookup of generator failed at " +
getLocation(param), ce);
}
this.generatorSource = source;
this.generatorParam = param;
@@ -244,27 +245,28 @@
* from the latest <code>ComponentManager</code> given by
<code>compose()</code>
* or <code>recompose()</code>.
*
- * @param role the transformer role in the component manager.
+ * @param hint the transformer hint in the component manager.
* @param source the source used to setup the transformer (e.g. XSL
file), or
* <code>null</code> if no source is given.
* @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, Parameters hintParam)
+ public void addTransformer (String hint, String source, Parameters
param, Parameters hintParam)
throws ProcessingException {
if (this.reader != null) {
// Should normally never happen as setting a reader starts
pipeline processing
- throw new ProcessingException ("Reader already set. Cannot add
transformer '" + role +
+ throw new ProcessingException ("Reader already set. Cannot add
transformer '" + hint +
"' at " + getLocation(param));
}
if (this.generator == null) {
- throw new ProcessingException ("Must set a generator before
adding transformer '" + role +
+ throw new ProcessingException ("Must set a generator before
adding transformer '" + hint +
"' at " + getLocation(param));
}
try {
+ String role = hint == null ? Transformer.ROLE : Transformer.ROLE
+ "/" + hint;
this.transformers.add(newManager.lookup(role));
} catch (ServiceException ce) {
- throw new ProcessingException("Lookup of transformer '"+role+"'
failed at " + getLocation(param), ce);
+ throw new ProcessingException("Lookup of transformer '" + hint +
"' failed at " + getLocation(param), ce);
}
this.transformerSources.add(source);
this.transformerParams.add(param);
@@ -274,27 +276,28 @@
* Set the serializer for this pipeline
* @param mimeType Can be null
*/
- public void setSerializer (String role, String source, Parameters param,
Parameters hintParam, String mimeType)
+ public void setSerializer (String hint, String source, Parameters param,
Parameters hintParam, String mimeType)
throws ProcessingException {
if (this.serializer != null) {
// Should normally not happen as adding a serializer starts
pipeline processing
- throw new ProcessingException ("Serializer already set. Cannot
set serializer '" + role +
+ throw new ProcessingException ("Serializer already set. Cannot
set serializer '" + hint +
"' at " + getLocation(param));
}
if (this.reader != null) {
// Should normally never happen as setting a reader starts
pipeline processing
- throw new ProcessingException ("Reader already set. Cannot set
serializer '" + role +
+ throw new ProcessingException ("Reader already set. Cannot set
serializer '" + hint +
"' at " + getLocation(param));
}
if (this.generator == null) {
- throw new ProcessingException ("Must set a generator before
setting serializer '" + role +
+ throw new ProcessingException ("Must set a generator before
setting serializer '" + hint +
"' at " + getLocation(param));
}
try {
+ String role = hint == null ? Serializer.ROLE : Serializer.ROLE +
"/" + hint;
this.serializer = (Serializer) newManager.lookup(role);
} catch (ServiceException ce) {
- throw new ProcessingException("Lookup of serializer '" + role +
"' failed at " + getLocation(param), ce);
+ throw new ProcessingException("Lookup of serializer '" + hint +
"' failed at " + getLocation(param), ce);
}
this.serializerSource = source;
this.serializerParam = param;
@@ -306,23 +309,24 @@
* Set the reader for this pipeline
* @param mimeType Can be null
*/
- public void setReader (String role, String source, Parameters param,
String mimeType)
+ public void setReader (String hint, String source, Parameters param,
String mimeType)
throws ProcessingException {
if (this.reader != null) {
// Should normally never happen as setting a reader starts
pipeline processing
- throw new ProcessingException ("Reader already set. Cannot set
reader '" + role +
+ throw new ProcessingException ("Reader already set. Cannot set
reader '" + hint +
"' at " + getLocation(param));
}
if (this.generator != null) {
// Should normally never happen as setting a reader starts
pipeline processing
- throw new ProcessingException ("Generator already set. Cannot
use reader '" + role +
+ throw new ProcessingException ("Generator already set. Cannot
use reader '" + hint +
"' at " + getLocation(param));
}
try {
+ String role = hint == null ? Reader.ROLE : Reader.ROLE + "/" +
hint;
this.reader = (Reader) newManager.lookup(role);
} catch (ServiceException ce) {
- throw new ProcessingException("Lookup of reader '"+role+"'
failed at " + getLocation(param), ce);
+ throw new ProcessingException("Lookup of reader '" + hint + "'
failed at " + getLocation(param), ce);
}
this.readerSource = source;
this.readerParam = param;