You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/06/14 16:04:42 UTC
svn commit: r414259 - in /cocoon/trunk: commons/
core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/
core/cocoon-core/src/main/java/org/apache/cocoon/core/
Author: cziegeler
Date: Wed Jun 14 07:04:41 2006
New Revision: 414259
URL: http://svn.apache.org/viewvc?rev=414259&view=rev
Log:
Property files are read in alphabetical order to provide a reliable read order.
Add setting "org.apache.cocoon.sitemap.internalonly.disable" to disable all internal pipelines for
development purposes.
Modified:
cocoon/trunk/commons/status.xml
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
Modified: cocoon/trunk/commons/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/commons/status.xml?rev=414259&r1=414258&r2=414259&view=diff
==============================================================================
--- cocoon/trunk/commons/status.xml (original)
+++ cocoon/trunk/commons/status.xml Wed Jun 14 07:04:41 2006
@@ -176,6 +176,13 @@
<!-- These are the changes from the last 2.1.x version. -->
<changes>
<release version="@version@" date="@date@">
+ <action dev="CZ" type="fix">
+ Property files are read in alphabetical order to provide a reliable read order.
+ </action>
+ <action dev="CZ" type="add">
+ Add setting "org.apache.cocoon.sitemap.internalonly.disable" to disable all internal pipelines for
+ development purposes.
+ </action>
<action dev="CZ" type="remove">
Remove the SitemapConfigurable interface completly. The new include and property mechanism provides
a cleaner way of per sitemap configurations.
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java?rev=414259&r1=414258&r2=414259&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java Wed Jun 14 07:04:41 2006
@@ -20,10 +20,13 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.ProcessingUtil;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.TreeBuilder;
+import org.apache.cocoon.core.Settings;
/**
* Builds a <map:pipeline>
@@ -32,18 +35,47 @@
*/
public class PipelineNodeBuilder extends AbstractParentProcessingNodeBuilder {
+ private static final String ATTRIBUTE_INTERNAL_ONLY = "internal-only";
+
+ private static final String PROPERTY_SITEMAP_INTERNALONLY = "org.apache.cocoon.sitemap.internalonly.disable";
+
+ /** Will the ignore-internal flag of a pipeline be ignored? */
+ protected boolean ignoreInternalOnly;
+
+ /**
+ * @see org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder#setBuilder(org.apache.cocoon.components.treeprocessor.TreeBuilder)
+ */
+ public void setBuilder(TreeBuilder treeBuilder) {
+ super.setBuilder(treeBuilder);
+ // check ssettings for ignoring of internal only pipeline flags
+ this.ignoreInternalOnly = false;
+ final Settings settings = (Settings)treeBuilder.getBeanFactory().getBean(ProcessingUtil.SETTINGS_ROLE);
+ final String value = settings.getProperty(PipelineNodeBuilder.PROPERTY_SITEMAP_INTERNALONLY);
+ if ( value != null ) {
+ this.ignoreInternalOnly = Boolean.valueOf(value).booleanValue();
+ }
+ }
+
/** This builder can have parameters -- return <code>true</code> */
protected boolean hasParameters() {
return true;
}
+ /**
+ * @see org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder#buildNode(org.apache.avalon.framework.configuration.Configuration)
+ */
public ProcessingNode buildNode(Configuration config)
throws Exception {
String type = this.treeBuilder.getTypeForStatement(config, ProcessingPipeline.ROLE);
PipelineNode node = new PipelineNode(type);
this.treeBuilder.setupNode(node, config);
- node.setInternalOnly(config.getAttributeAsBoolean("internal-only", false));
+ // if internal only is ignore, all pipelines are directly accessible
+ if ( this.ignoreInternalOnly ) {
+ node.setInternalOnly(false);
+ } else {
+ node.setInternalOnly(config.getAttributeAsBoolean(PipelineNodeBuilder.ATTRIBUTE_INTERNAL_ONLY, false));
+ }
// Main (with no "type" attribute) error handler: new in Cocoon 2.1, must have a generator
ProcessingNode mainHandler = null;
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=414259&r1=414258&r2=414259&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Wed Jun 14 07:04:41 2006
@@ -62,6 +62,7 @@
import org.apache.cocoon.components.treeprocessor.TreeBuilder;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.core.CoreUtil;
import org.apache.cocoon.core.MutableSettings;
import org.apache.cocoon.core.PropertyProvider;
import org.apache.cocoon.core.Settings;
@@ -1107,19 +1108,28 @@
try {
directory = resolver.resolveURI(directoryName, null, CONTEXT_PARAMETERS);
if (directory.exists() && directory instanceof TraversableSource) {
+ final List propertyUris = new ArrayList();
final Iterator c = ((TraversableSource) directory).getChildren().iterator();
while (c.hasNext()) {
final Source src = (Source) c.next();
if ( src.getURI().endsWith(".properties") ) {
- final InputStream propsIS = src.getInputStream();
- if ( this.getLogger().isDebugEnabled() ) {
- this.getLogger().debug("Reading settings from '" + src.getURI() + "'.");
- }
- final Properties p = new Properties();
- p.load(propsIS);
- propsIS.close();
- s.fill(p);
+ propertyUris.add(src);
}
+ }
+ // sort
+ Collections.sort(propertyUris, CoreUtil.getSourceComparator());
+ // now process
+ final Iterator i = propertyUris.iterator();
+ while ( i.hasNext() ) {
+ final Source src = (Source)i.next();
+ final InputStream propsIS = src.getInputStream();
+ if ( this.getLogger().isDebugEnabled() ) {
+ this.getLogger().debug("Reading settings from '" + src.getURI() + "'.");
+ }
+ final Properties p = new Properties();
+ p.load(propsIS);
+ propsIS.close();
+ s.fill(p);
}
}
} catch (IOException ignore) {
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java?rev=414259&r1=414258&r2=414259&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java Wed Jun 14 07:04:41 2006
@@ -22,9 +22,12 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Enumeration;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -450,24 +453,53 @@
try {
directory = resolver.resolveURI(directoryName, null, CONTEXT_PARAMETERS);
if (directory.exists() && directory instanceof TraversableSource) {
+ final List propertyUris = new ArrayList();
final Iterator c = ((TraversableSource) directory).getChildren().iterator();
while (c.hasNext()) {
final Source src = (Source) c.next();
if ( src.getURI().endsWith(".properties") ) {
- final InputStream propsIS = src.getInputStream();
- this.environmentContext.log("Reading settings from '" + src.getURI() + "'.");
- final Properties p = new Properties();
- p.load(propsIS);
- propsIS.close();
- s.fill(p);
+ propertyUris.add(src);
}
}
+ // sort
+ Collections.sort(propertyUris, getSourceComparator());
+ // now process
+ final Iterator i = propertyUris.iterator();
+ while ( i.hasNext() ) {
+ final Source src = (Source)i.next();
+ final InputStream propsIS = src.getInputStream();
+ this.environmentContext.log("Reading settings from '" + src.getURI() + "'.");
+ final Properties p = new Properties();
+ p.load(propsIS);
+ propsIS.close();
+ s.fill(p);
+ }
}
} catch (IOException ignore) {
this.environmentContext.log("Unable to read from directory " + directoryName, ignore);
this.environmentContext.log("Continuing initialization.");
} finally {
resolver.release(directory);
+ }
+ }
+
+ /**
+ * Return a source comparator
+ */
+ public static Comparator getSourceComparator() {
+ return new SourceComparator();
+ }
+
+ protected final static class SourceComparator implements Comparator {
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2) {
+ if ( !(o1 instanceof Source) || !(o2 instanceof Source)) {
+ return 0;
+ }
+ return ((Source)o1).getURI().compareTo(((Source)o2).getURI());
}
}