unico 2004/01/28 09:25:31
Modified: src/java/org/apache/cocoon/components/cprocessor/sitemap
SerializeNode.java GenerateNode.java ReadNode.java
AggregateNode.java TransformNode.java
src/java/org/apache/cocoon/components/cprocessor
ContainerNode.java ProcessingNode.java
sitemap2xconf.xsl SitemapContainer.java
NamedProcessingNode.java
Added: src/java/org/apache/cocoon/components/cprocessor/sitemap
GeneratorNode.java ViewNodeImpl.java
ReaderNode.java TransformerNode.java
ViewablePipelineComponentNode.java
AbstractPipelineComponentNode.java
SerializerNode.java AbstractComponentNode.java
src/java/org/apache/cocoon/components/cprocessor
ViewNode.java ComponentNode.java
Removed: src/java/org/apache/cocoon/components/cprocessor/sitemap
ViewNode.java
PipelineEventComponentProcessingNode.java
ComponentNode.java
Log:
make sitemap component inheritance work properly
Revision Changes Path
1.4 +7 -3
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SerializeNode.java 5 Jan 2004 08:17:30 -0000 1.3
+++ SerializeNode.java 28 Jan 2004 17:25:30 -0000 1.4
@@ -77,7 +77,7 @@
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=serialize-node
*/
-public class SerializeNode extends PipelineEventComponentProcessingNode {
+public class SerializeNode extends ViewablePipelineComponentNode {
private VariableResolver m_mimeType;
private int m_statusCode;
@@ -101,7 +101,7 @@
public void initialize() throws Exception {
super.initialize();
m_serializerRole = Serializer.ROLE;
- String hint = getComponentId();
+ String hint = m_component.getComponentHint();
if (hint != null) {
m_serializerRole += "/" + hint;
}
@@ -168,6 +168,10 @@
// Return true : pipeline is finished.
return true;
}
+ }
+
+ protected String getComponentNodeRole() {
+ return SerializerNode.ROLE;
}
/**
1.5 +8 -3
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GenerateNode.java 27 Jan 2004 10:33:05 -0000 1.4
+++ GenerateNode.java 28 Jan 2004 17:25:30 -0000 1.5
@@ -55,6 +55,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.components.cprocessor.*;
import org.apache.cocoon.components.cprocessor.InvokeContext;
import org.apache.cocoon.components.cprocessor.ProcessingNode;
import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
@@ -74,7 +75,7 @@
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=generate-node
*/
-public class GenerateNode extends PipelineEventComponentProcessingNode
+public class GenerateNode extends ViewablePipelineComponentNode
implements ProcessingNode {
private VariableResolver m_src;
@@ -98,7 +99,7 @@
public void initialize() throws Exception {
super.initialize();
m_generatorRole = Generator.ROLE;
- String hint = getComponentId();
+ String hint = m_component.getComponentHint();
if (hint != null) {
m_generatorRole += "/" + hint;
}
@@ -137,6 +138,10 @@
// Return false to continue sitemap invocation
return false;
+ }
+
+ protected String getComponentNodeRole() {
+ return GeneratorNode.ROLE;
}
/**
1.3 +11 -13
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ReadNode.java 5 Jan 2004 08:17:30 -0000 1.2
+++ ReadNode.java 28 Jan 2004 17:25:30 -0000 1.3
@@ -54,7 +54,6 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.cocoon.components.cprocessor.AbstractProcessingNode;
import org.apache.cocoon.components.cprocessor.InvokeContext;
import org.apache.cocoon.components.cprocessor.ProcessingNode;
import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
@@ -75,7 +74,7 @@
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=read-node
*/
-public class ReadNode extends AbstractProcessingNode implements
ProcessingNode {
+public class ReadNode extends AbstractPipelineComponentNode implements
ProcessingNode {
private String m_type;
private VariableResolver m_src;
@@ -113,15 +112,11 @@
ProcessingPipeline pipeline = context.getProcessingPipeline();
String mimeType = m_mimeType.resolve(context, objectModel);
- /* TODO:
- * either
- *
- if (mimeType == null) {
- mimeType = m_readerComponentNode.getMimeType();
- }
- *
- * or do this during sitemap2xconf transformation
- */
+
+ if (mimeType == null) {
+ mimeType = m_component.getMimeType();
+ }
+
pipeline.setReader(
m_readerLookupKey,
m_src.resolve(context, objectModel),
@@ -137,11 +132,14 @@
if (!context.isBuildingPipelineOnly()) {
// Process pipeline
return pipeline.process(env);
-
} else {
// Return true : pipeline is finished.
return true;
}
+ }
+
+ protected String getComponentNodeRole() {
+ return ReaderNode.ROLE;
}
/**
1.3 +3 -2
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AggregateNode.java
Index: AggregateNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AggregateNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AggregateNode.java 5 Jan 2004 08:17:30 -0000 1.2
+++ AggregateNode.java 28 Jan 2004 17:25:30 -0000 1.3
@@ -60,6 +60,7 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.components.cprocessor.*;
import org.apache.cocoon.components.cprocessor.AbstractProcessingNode;
import org.apache.cocoon.components.cprocessor.InvokeContext;
import org.apache.cocoon.components.cprocessor.ProcessingNode;
@@ -266,7 +267,7 @@
if (view == null) {
try {
view = (ViewNode) super.m_manager.lookup(
- ProcessingNode.ROLE + "/v-" + name);
+ ViewNode.ROLE + "/v-" + name);
}
catch (ServiceException e) {
// TODO: record no such view
1.3 +7 -3
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransformNode.java 28 Dec 2003 22:11:19 -0000 1.2
+++ TransformNode.java 28 Jan 2004 17:25:30 -0000 1.3
@@ -74,7 +74,7 @@
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=transform-node
*/
-public class TransformNode extends PipelineEventComponentProcessingNode {
+public class TransformNode extends ViewablePipelineComponentNode {
private VariableResolver m_src;
private String m_transformerRole;
@@ -96,7 +96,7 @@
public void initialize() throws Exception {
super.initialize();
m_transformerRole = Transformer.ROLE;
- String hint = getComponentId();
+ String hint = m_component.getComponentHint();
if (hint != null) {
m_transformerRole += "/" + hint;
}
@@ -135,6 +135,10 @@
// Return false to contine sitemap invocation
return false;
+ }
+
+ protected String getComponentNodeRole() {
+ return TransformerNode.ROLE;
}
/**
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/GeneratorNode.java
Index: GeneratorNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*
* @avalon.component
* @avalon.service type=GeneratorNode
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=generator-node
*/
public class GeneratorNode extends AbstractComponentNode {
public static final String ROLE = GeneratorNode.class.getName();
public GeneratorNode() {
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ViewNodeImpl.java
Index: ViewNodeImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.components.cprocessor.NamedContainerNode;
import org.apache.cocoon.components.cprocessor.ViewNode;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*
* @avalon.component
* @avalon.service type=ViewNode
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=view-node
*/
public class ViewNodeImpl extends NamedContainerNode implements ViewNode {
private static final String FROM_LABEL_ATTR = "from-label";
private static final String FROM_POSITION_ATTR = "from-position";
private String m_label;
public ViewNodeImpl() {
}
public void configure(Configuration config) throws ConfigurationException
{
super.configure(config);
// Get the label or position (pseudo-label) of this view.
m_label = config.getAttribute(FROM_LABEL_ATTR, null);
if (m_label == null) {
String position = config.getAttribute(FROM_POSITION_ATTR);
if ("first".equals(position)) {
m_label = FIRST_POS_LABEL;
} else if ("last".equals(position)) {
m_label = LAST_POS_LABEL;
} else {
String msg = "Bad value for 'from-position' at " +
getLocation();
throw new ConfigurationException(msg);
}
}
}
public String getLabel() {
return m_label;
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ReaderNode.java
Index: ReaderNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*
* @avalon.component
* @avalon.service type=ReaderNode
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=reader-node
*/
public class ReaderNode extends AbstractComponentNode {
public static final String ROLE = ReaderNode.class.getName();
public ReaderNode() {
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/TransformerNode.java
Index: TransformerNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*
* @avalon.component
* @avalon.service type=TransformerNode
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=transformer-node
*/
public class TransformerNode extends AbstractComponentNode {
public static final String ROLE = TransformerNode.class.getName();
public TransformerNode() {
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ViewablePipelineComponentNode.java
Index: ViewablePipelineComponentNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.cocoon.components.cprocessor.ViewNode;
import org.apache.cocoon.util.StringUtils;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
public abstract class ViewablePipelineComponentNode extends
AbstractPipelineComponentNode {
private Map m_views = new HashMap();
protected Collection m_labels;
public ViewablePipelineComponentNode() {
}
public void configure(Configuration config) throws ConfigurationException
{
super.configure(config);
m_labels = splitLabels(config.getAttribute("label",null));
}
public void initialize() throws Exception {
super.initialize();
// add the labels defined at the component node
m_labels.addAll(m_component.getLabels());
}
/**
* Split a list of space/comma separated labels into a Collection
*
* @return the collection of labels (may be empty, nut never null)
*/
private static final Collection splitLabels(String labels) {
if (labels == null) {
return new HashSet(0);
} else {
return Arrays.asList(StringUtils.split(labels, ", \t\n\r"));
}
}
protected final ViewNode getViewNode(String name) {
ViewNode view = (ViewNode) m_views.get(name);
if (view == null) {
try {
view = (ViewNode) super.m_manager.lookup(ViewNode.ROLE +
"/v-" + name);
if (m_labels.contains(view.getLabel())) {
m_views.put(name,view);
}
else {
if (getLogger().isDebugEnabled()) {
getLogger().debug("view '" + name + "' not applicable
" + "to statement at '" + getLocation() + "'");
}
view = null;
}
}
catch (ServiceException e) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("no such view: '" + name + "'");
}
view = null;
}
}
return view;
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AbstractPipelineComponentNode.java
Index: AbstractPipelineComponentNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
import java.util.Map;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.components.cprocessor.AbstractProcessingNode;
import org.apache.cocoon.components.cprocessor.ComponentNode;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Melhem</a>
* @version CVS $Id: AbstractPipelineComponentNode.java,v 1.1 2004/01/28
17:25:30 unico Exp $
*/
public abstract class AbstractPipelineComponentNode extends
AbstractProcessingNode
implements Initializable {
private String m_type;
protected ComponentNode m_component;
// TODO: implement pipeline hints
protected Map m_pipelineHints;
public AbstractPipelineComponentNode() {
}
public void configure(Configuration config) throws ConfigurationException
{
super.configure(config);
m_type = config.getAttribute("type",null);
}
public void initialize() throws Exception {
String key = getComponentNodeRole();
if (m_type != null) {
key += "/" + m_type;
}
// TODO: meaningful error message
m_component = (ComponentNode) super.m_manager.lookup(key);
}
protected abstract String getComponentNodeRole();
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/SerializerNode.java
Index: SerializerNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*
* @avalon.component
* @avalon.service type=SerializerNode
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=serializer-node
*/
public class SerializerNode extends AbstractComponentNode {
public static final String ROLE = SerializerNode.class.getName();
public SerializerNode() {
}
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AbstractComponentNode.java
Index: AbstractComponentNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor.sitemap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.components.cprocessor.ComponentNode;
import org.apache.cocoon.util.StringUtils;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
public abstract class AbstractComponentNode implements ComponentNode,
Serviceable, Configurable {
private ServiceManager m_manager;
private Collection m_labels;
private String m_componentHint;
private String m_mimeType;
public AbstractComponentNode() {
}
public void service(ServiceManager manager) throws ServiceException {
m_manager = manager;
}
public void configure(Configuration config) throws ConfigurationException
{
m_componentHint = config.getChild("component").getAttribute("hint");
Collection labels = splitLabels(config.getAttribute("label",null));
m_labels = Collections.unmodifiableCollection(labels);
m_mimeType = config.getAttribute("mime-type",null);
}
public Collection getLabels() {
return m_labels;
}
public String getComponentHint() {
return m_componentHint;
}
public String getMimeType() {
return m_mimeType;
}
/**
* Split a list of space/comma separated labels into a Collection
*
* @return the collection of labels (may be empty, never null)
*/
private static final Collection splitLabels(String labels) {
if (labels == null) {
return Collections.EMPTY_SET;
} else {
return Arrays.asList(StringUtils.split(labels, ", \t\n\r"));
}
}
}
1.3 +2 -2
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ContainerNode.java
Index: ContainerNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ContainerNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContainerNode.java 27 Jan 2004 10:33:02 -0000 1.2
+++ ContainerNode.java 28 Jan 2004 17:25:31 -0000 1.3
@@ -81,5 +81,5 @@
public final boolean invoke(Environment env, InvokeContext context)
throws Exception {
return invokeNodes(getChildNodes(), env, context);
}
-
+
}
1.4 +3 -3
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ProcessingNode.java
Index: ProcessingNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ProcessingNode.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProcessingNode.java 27 Jan 2004 13:27:47 -0000 1.3
+++ ProcessingNode.java 28 Jan 2004 17:25:31 -0000 1.4
@@ -65,7 +65,7 @@
public static final String ROLE = ProcessingNode.class.getName();
/**
- * Process this node with the suppled environment information. Will
recursively
+ * Process this node with the supplied environment information. Will
recursively
* process child nodes.
*
* @param env The Environment object used to process a request.
@@ -73,7 +73,7 @@
* @return <code>true</code> if a redirect has been issued.
* @throws Exception if the processing was not successful.
*/
- boolean invoke( Environment env, InvokeContext context ) throws
Exception;
+ boolean invoke(Environment env, InvokeContext context) throws Exception;
/**
* Get the location of this node.
1.8 +31 -108
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap2xconf.xsl
Index: sitemap2xconf.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap2xconf.xsl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- sitemap2xconf.xsl 27 Jan 2004 13:27:47 -0000 1.7
+++ sitemap2xconf.xsl 28 Jan 2004 17:25:31 -0000 1.8
@@ -12,13 +12,35 @@
</sitemap>
</xsl:template>
- <xsl:template match="map:components/*/*">
- <component-node id="[EMAIL PROTECTED]()}-node"
logger="sitemap.processor">
+ <xsl:template match="map:components">
+ <meta>
+ <xsl:for-each select="*">
+ <default type="{local-name()}" hint="[EMAIL PROTECTED]"/>
+ </xsl:for-each>
+ </meta>
+ <xsl:apply-templates select="*/*" />
+ </xsl:template>
+
+
+ <xsl:template
match="map:generator|map:transformer|map:serializer|map:reader">
+ <xsl:element name="{local-name()}-node">
+ <xsl:attribute name="id">
+ <xsl:value-of select="@name"/>
+ </xsl:attribute>
+ <xsl:attribute name="logger">
+ <xsl:text>sitemap.processor</xsl:text>
+ </xsl:attribute>
<xsl:apply-templates select="@label|@mime-type" mode="copy" />
- <component id-ref="[EMAIL PROTECTED]()}" />
- </component-node>
- <component id="[EMAIL PROTECTED]()}" class="[EMAIL PROTECTED]">
- <xsl:apply-templates
select="@logger|@pool-min|@pool-max|@pool-grow|child::node()" mode="copy"/>
+ <component hint="[EMAIL PROTECTED]" />
+ </xsl:element>
+ <component id="[EMAIL PROTECTED]" class="[EMAIL PROTECTED]">
+ <xsl:apply-templates select="@*|child::node()" mode="copy"/>
+ </component>
+ </xsl:template>
+
+ <xsl:template match="map:matcher|map:selector|map:action|map:pipe">
+ <component id="[EMAIL PROTECTED]" class="[EMAIL PROTECTED]">
+ <xsl:apply-templates select="@*|child::node()" mode="copy"/>
</component>
</xsl:template>
@@ -163,22 +185,6 @@
</xsl:variable>
<match-node id="{$id}" logger="sitemap.processor">
<xsl:apply-templates select="@*" mode="copy" />
- <xsl:choose>
- <xsl:when test="@type">
- <xsl:attribute name="type">
- <xsl:value-of select="@type"/>
- <xsl:text>-matcher</xsl:text>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="/map:sitemap/map:components/map:matchers/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:matchers/@default"/>
- <xsl:text>-matcher</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
<xsl:for-each
select="map:match|map:select|map:act|map:call|map:aggregate|map:generate|map:transform|map:serialize|map:read|map:mount|map:redirect-to">
<xsl:element name="{local-name()}">
<xsl:attribute name="id-ref">
@@ -202,22 +208,6 @@
</xsl:variable>
<select-node id="{$id}" logger="sitemap.processor">
<xsl:apply-templates select="@*" mode="copy" />
- <xsl:choose>
- <xsl:when test="@type">
- <xsl:attribute name="type">
- <xsl:value-of select="@type"/>
- <xsl:text>-selector</xsl:text>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="/map:sitemap/map:components/map:selectors/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:selectors/@default"/>
- <xsl:text>-selector</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
<xsl:apply-templates select="map:parameter" mode="copy" />
<xsl:apply-templates select="map:when|map:otherwise" mode="config">
<xsl:with-param name="parent-id">
@@ -268,22 +258,6 @@
</xsl:variable>
<act-node id="{$id}" logger="sitemap.processor">
<xsl:apply-templates select="@*" mode="copy" />
- <xsl:choose>
- <xsl:when test="@type">
- <xsl:attribute name="type">
- <xsl:value-of select="@type"/>
- <xsl:text>-action</xsl:text>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="/map:sitemap/map:components/map:actions/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:actions/@default" />
- <xsl:text>-action</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
<xsl:for-each
select="map:match|map:select|map:act|map:call|map:aggregate|map:generate|map:transform|map:serialize|map:read|map:mount|map:redirect-to">
<xsl:element name="{local-name()}">
<xsl:attribute name="id-ref">
@@ -306,24 +280,7 @@
<xsl:value-of select="$parent-id"/>-<xsl:value-of select="position()"/>
</xsl:variable>
<generate-node id="{$id}" logger="sitemap.processor">
- <xsl:apply-templates select="@*" mode="copy" />
- <xsl:choose>
- <xsl:when test="not(@type)">
- <xsl:if test="/map:sitemap/map:components/map:generators/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:generators/@default" />
- <xsl:text>-generator-node</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="type">
- <xsl:value-of select="@type" />
- <xsl:text>-generator-node</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="map:parameter" mode="copy" />
+ <xsl:apply-templates select="@*|map:parameter" mode="copy" />
</generate-node>
</xsl:template>
@@ -333,24 +290,7 @@
<xsl:value-of select="$parent-id"/>-<xsl:value-of select="position()"/>
</xsl:variable>
<transform-node id="{$id}" logger="sitemap.processor">
- <xsl:apply-templates select="@*" mode="copy" />
- <xsl:choose>
- <xsl:when test="not(@type)">
- <xsl:if
test="/map:sitemap/map:components/map:transformers/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:transformers/@default" />
- <xsl:text>-transformer-node</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="type">
- <xsl:value-of select="@type" />
- <xsl:text>-transformer-node</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="map:parameter" mode="copy" />
+ <xsl:apply-templates select="@*|map:parameter" mode="copy" />
</transform-node>
</xsl:template>
@@ -360,24 +300,7 @@
<xsl:value-of select="$parent-id"/>-<xsl:value-of select="position()"/>
</xsl:variable>
<serialize-node id="{$id}" logger="sitemap.processor">
- <xsl:apply-templates select="map:parameter" mode="copy" />
- <xsl:choose>
- <xsl:when test="not(@type)">
- <xsl:if
test="/map:sitemap/map:components/map:serializers/@default">
- <xsl:attribute name="type">
- <xsl:value-of
select="/map:sitemap/map:components/map:serializers/@default" />
- <xsl:text>-serializer-node</xsl:text>
- </xsl:attribute>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="type">
- <xsl:value-of select="@type" />
- <xsl:text>-serializer-node</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="map:parameter" mode="copy" />
+ <xsl:apply-templates select="@*|map:parameter" mode="copy" />
</serialize-node>
</xsl:template>
1.3 +87 -6
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/SitemapContainer.java
Index: SitemapContainer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/SitemapContainer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SitemapContainer.java 5 Jan 2004 08:16:00 -0000 1.2
+++ SitemapContainer.java 28 Jan 2004 17:25:31 -0000 1.3
@@ -50,29 +50,71 @@
*/
package org.apache.cocoon.components.cprocessor;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.avalon.fortress.impl.ComponentHandlerMetaData;
import org.apache.avalon.fortress.impl.DefaultContainer;
+import org.apache.avalon.fortress.impl.lookup.FortressServiceManager;
import org.apache.avalon.fortress.util.CompositeException;
+import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.acting.Action;
+import org.apache.cocoon.components.cprocessor.sitemap.GeneratorNode;
+import org.apache.cocoon.components.cprocessor.sitemap.ReaderNode;
+import org.apache.cocoon.components.cprocessor.sitemap.SerializerNode;
+import org.apache.cocoon.components.cprocessor.sitemap.TransformerNode;
+import org.apache.cocoon.components.pipeline.ProcessingPipeline;
+import org.apache.cocoon.matching.Matcher;
+import org.apache.cocoon.selection.Selector;
import org.apache.cocoon.sitemap.NotifyingGenerator;
import org.apache.cocoon.sitemap.ContentAggregator;
import org.apache.cocoon.sitemap.LinkTranslator;
import org.apache.cocoon.sitemap.LinkGatherer;
/**
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
public class SitemapContainer extends DefaultContainer {
+ private static final Map TYPES2ROLES = new HashMap(8);
+
+ static {
+ TYPES2ROLES.put("generators",GeneratorNode.ROLE);
+ TYPES2ROLES.put("transformers",TransformerNode.ROLE);
+ TYPES2ROLES.put("serializers",SerializerNode.ROLE);
+ TYPES2ROLES.put("readers",ReaderNode.ROLE);
+ TYPES2ROLES.put("matchers",Matcher.ROLE);
+ TYPES2ROLES.put("selectors",Selector.ROLE);
+ TYPES2ROLES.put("actions",Action.ROLE);
+ TYPES2ROLES.put("pipes",ProcessingPipeline.ROLE);
+ }
+
+ private final Map m_defaultHints = new HashMap(8);
+
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ super.configure(configuration);
+ Configuration meta = configuration.getChild("meta");
+
+ // default component mappings
+ Configuration[] defaults = meta.getChildren("default");
+ for (int i = 0; i < defaults.length; i++) {
+ String type = defaults[i].getAttribute("type");
+ String hint = defaults[i].getAttribute("hint");
+ String role = (String) TYPES2ROLES.get(type);
+ m_defaultHints.put(role,hint);
+ }
+ }
+
public void initialize() throws CompositeException, Exception {
- ensureExists("<notifier>",NotifyingGenerator.class);
- ensureExists("<aggregator>",ContentAggregator.class);
- ensureExists("<translator>",LinkTranslator.class);
- ensureExists("<gatherer>",LinkGatherer.class);
+ addNativeComponent("<notifier>",NotifyingGenerator.class);
+ addNativeComponent("<aggregator>",ContentAggregator.class);
+ addNativeComponent("<translator>",LinkTranslator.class);
+ addNativeComponent("<gatherer>",LinkGatherer.class);
super.initialize();
}
@@ -81,7 +123,13 @@
return (ProcessingNode)
super.getServiceManager().lookup(ProcessingNode.ROLE);
}
- private void ensureExists(String hint, Class klass) throws
ConfigurationException {
+ protected ServiceManager provideServiceManager(ServiceManager parent)
+ throws ServiceException {
+
+ return new SitemapServiceManager(this,parent,m_defaultHints);
+ }
+
+ private void addNativeComponent(String hint, Class klass) throws
ConfigurationException {
final DefaultConfiguration config =
new DefaultConfiguration("component","autogenerated");
config.setAttribute("name", hint);
@@ -94,6 +142,39 @@
catch (Exception e) {
throw new ConfigurationException("Could not add component", e);
}
+ }
+
+ private static final class SitemapServiceManager extends
FortressServiceManager {
+
+ private final Map m_defaultHints;
+
+ private SitemapServiceManager(SitemapContainer container,
ServiceManager parent, Map defaultHints) {
+ super(container,parent);
+ m_defaultHints = defaultHints;
+ }
+
+ public boolean hasService(String role) {
+ final int index = role.indexOf('/');
+ if (index == -1) {
+ final String defaultHint = (String) m_defaultHints.get(role);
+ if (defaultHint != null) {
+ role += "/" + defaultHint;
+ }
+ }
+ return super.hasService(role);
+ }
+
+ public Object lookup(String role) throws ServiceException {
+ final int index = role.indexOf('/');
+ if (index == -1) {
+ final String defaultHint = (String) m_defaultHints.get(role);
+ if (defaultHint != null) {
+ role += "/" + defaultHint;
+ }
+ }
+ return super.lookup(role);
+ }
+
}
}
1.2 +6 -5
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/NamedProcessingNode.java
Index: NamedProcessingNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/NamedProcessingNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamedProcessingNode.java 28 Dec 2003 21:03:17 -0000 1.1
+++ NamedProcessingNode.java 28 Jan 2004 17:25:31 -0000 1.2
@@ -51,14 +51,15 @@
package org.apache.cocoon.components.cprocessor;
/**
- * A <code>ProcessingNode</code> that has a name. This is primarily used by
- * <code>CategoryNode</code> to access its children.
+ * A <code>ProcessingNode</code> that has a name.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Id$
*/
-
public interface NamedProcessingNode extends ProcessingNode {
-
+
+ /**
+ * Return this node's name.
+ */
String getName();
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ViewNode.java
Index: ViewNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
public interface ViewNode extends NamedProcessingNode {
public static final String ROLE = ViewNode.class.getName();
/**
* Pseudo-label for views <code>from-position="first"</code> (i.e.
generator).
*/
public static final String FIRST_POS_LABEL = "!first!";
/**
* Pseudo-label for views <code>from-position="last"</code> (i.e.
serializer).
*/
public static final String LAST_POS_LABEL = "!last!";
/**
* Return this view's label.
*/
public String getLabel();
}
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/ComponentNode.java
Index: ComponentNode.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.cprocessor;
import java.util.Collection;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Unico Hommes</a>
*/
public interface ComponentNode {
public static final String ROLE = ComponentNode.class.getName();
/**
* Return the labels associated with this sitemap
* component declaration statement. Only relevant if
* this represents a generator, transformer or serializer.
*/
public Collection getLabels();
/**
* Return the hint of the sitemap component this node represents.
*/
public String getComponentHint();
/**
* Return the mime-type attribute of this sitemap
* component declaration statement. Only relevant if
* this represents a reader or serializer.
*/
public String getMimeType();
}