You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by rg...@apache.org on 2006/03/27 08:21:41 UTC
svn commit: r389028 - in /cocoon/branches/BRANCH_2_1_X: ./
src/blocks/portal/samples/ src/blocks/portal/samples/WEB-INF/
src/blocks/portal/samples/WEB-INF/properties/ src/java/org/apache/cocoon/
src/java/org/apache/cocoon/components/ src/java/org/apach...
Author: rgoers
Date: Sun Mar 26 22:21:40 2006
New Revision: 389028
URL: http://svn.apache.org/viewcvs?rev=389028&view=rev
Log:
Configuration values can now be set externally. The properties that can be modified can be identified by
ooking at the property files in WEB-INF/properties. The properties can be overriden by specifying them as
system properties when invoking Cocoon or by placing them in a property file and identifying its location via
the "org.apache.cocoon.settings" system property. The default Cocoon script sets this to ./cocoon.properties.
Added:
cocoon/branches/BRANCH_2_1_X/cocoon.properties (with props)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java (with props)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SimpleSourceResolver.java
cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/
cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties (with props)
Modified:
cocoon/branches/BRANCH_2_1_X/cocoon.sh
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/sitemap.xmap
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/Cocoon.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf
cocoon/branches/BRANCH_2_1_X/src/webapp/sitemap.xmap
cocoon/branches/BRANCH_2_1_X/status.xml
cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
cocoon/branches/BRANCH_2_1_X/tools/targets/webapp-build.xml
Added: cocoon/branches/BRANCH_2_1_X/cocoon.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/cocoon.properties?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/cocoon.properties (added)
+++ cocoon/branches/BRANCH_2_1_X/cocoon.properties Sun Mar 26 22:21:40 2006
@@ -0,0 +1 @@
+# Place any property overrides in this file
\ No newline at end of file
Propchange: cocoon/branches/BRANCH_2_1_X/cocoon.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/branches/BRANCH_2_1_X/cocoon.sh
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/cocoon.sh?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/cocoon.sh (original)
+++ cocoon/branches/BRANCH_2_1_X/cocoon.sh Sun Mar 26 22:21:40 2006
@@ -91,7 +91,7 @@
fi
if [ "$JAVA_OPTIONS" = "" ] ; then
- JAVA_OPTIONS='-Xms32M -Xmx512M'
+ JAVA_OPTIONS='-Xms32M -Xmx512M -Dorg.apache.cocoon.settings=cocoon.properties'
fi
if [ "$COCOON_HOME" = "" ] ; then
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties Sun Mar 26 22:21:40 2006
@@ -0,0 +1,2 @@
+# Properties for the portal block
+html-include-serializer.pool-max = 32
\ No newline at end of file
Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/WEB-INF/properties/sample-portal.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/sitemap.xmap?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/samples/sitemap.xmap Sun Mar 26 22:21:40 2006
@@ -50,7 +50,7 @@
<map:serializer name="html-include"
logger="sitemap.serializer.html"
mime-type="text/html"
- pool-max="32"
+ pool-max="${html-include-serializer.pool-max}"
src="org.apache.cocoon.portal.serialization.IncludingHTMLSerializer">
<doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/Cocoon.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/Cocoon.java?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/Cocoon.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/Cocoon.java Sun Mar 26 22:21:40 2006
@@ -40,6 +40,7 @@
import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.components.ComponentContext;
+import org.apache.cocoon.components.PropertyAwareSAXConfigurationHandler;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
@@ -49,6 +50,10 @@
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.util.ClassUtils;
import org.apache.cocoon.util.Deprecation;
+import org.apache.cocoon.util.SimpleSourceResolver;
+import org.apache.cocoon.util.Settings;
+import org.apache.cocoon.util.PropertySettings;
+import org.apache.cocoon.util.SettingsHelper;
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.LocationImpl;
import org.apache.cocoon.util.location.LocationUtils;
@@ -226,6 +231,7 @@
public void contextualize(Context context) throws ContextException {
if (this.context == null) {
this.context = new ComponentContext(context);
+ SettingsHelper.createSettings((DefaultContext)this.context, getLogger());
((DefaultContext) this.context).makeReadOnly();
this.classpath = (String)context.get(Constants.CONTEXT_CLASSPATH);
@@ -384,11 +390,12 @@
*/
public void configure(ExcaliburComponentManager startupManager) throws ConfigurationException, ContextException {
SAXParser p = null;
+ Settings settings = SettingsHelper.getSettings(this.context);
Configuration roles = null;
try {
p = (SAXParser) startupManager.lookup(SAXParser.ROLE);
- SAXConfigurationHandler b = new SAXConfigurationHandler();
+ SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
URL url = ClassUtils.getResource("org/apache/cocoon/cocoon.roles");
InputSource is = new InputSource(url.openStream());
is.setSystemId(url.toString());
@@ -408,7 +415,7 @@
try {
this.configurationFile.refresh();
p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
- SAXConfigurationHandler b = new SAXConfigurationHandler();
+ SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
InputSource is = SourceUtil.getInputSource(this.configurationFile);
p.parse(is, b);
this.configuration = b.getConfiguration();
@@ -436,7 +443,7 @@
if (!"".equals(userRoles)) {
try {
p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
- SAXConfigurationHandler b = new SAXConfigurationHandler();
+ SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
org.apache.cocoon.environment.Context context =
(org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
URL url = context.getResource(userRoles);
@@ -786,5 +793,21 @@
public ExcaliburComponentManager getComponentManager() {
return this.componentManager;
+ }
+
+ /**
+ * Create a simple source resolver.
+ */
+ protected SourceResolver createSourceResolver(Logger logger) throws ContextException {
+ // Create our own resolver
+ final SimpleSourceResolver resolver = new SimpleSourceResolver();
+ resolver.enableLogging(logger);
+ try {
+ resolver.contextualize(this.context);
+ } catch (ContextException ce) {
+ throw new ContextException(
+ "Cannot setup source resolver.", ce);
+ }
+ return resolver;
}
}
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components;
+
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.util.SettingsHelper;
+import org.apache.cocoon.util.Settings;
+
+/**
+ * Property Aware Configuration.
+ * This component extends the {@link DefaultConfiguration}
+ * by suppporting configurations that can contain placeholders for System Properties.
+ *
+ * @version SVN $Id: $
+ */
+public class PropertyAwareConfiguration extends DefaultConfiguration {
+ private Settings settings;
+ private Logger logger;
+
+ /**
+ * Copy constructor, to create a clone of another configuration.
+ * To modify children, use <code>getChild()</code>,
+ * <code>removeChild()</code> and <code>addChild()</code>.
+ *
+ * @param config the <code>Configuration</code> to copy
+ * @param deepCopy true will cause clones of the children to be added,
+ * false will add the original instances and is thus
+ * faster.
+ * @param settings The Settings to use when resolving tokens
+ * @param logger A Logger to use
+ * @throws ConfigurationException if an error occurs when copying
+ */
+ public PropertyAwareConfiguration(Configuration config, boolean deepCopy, Settings settings, Logger logger)
+ throws ConfigurationException {
+ super(config, deepCopy);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Shallow copy constructor, suitable for craeting a writable clone of
+ * a read-only configuration. To modify children, use <code>getChild()</code>,
+ * <code>removeChild()</code> and <code>addChild()</code>.
+ *
+ * @param config the <code>Configuration</code> to copy
+ * @param settings The Settings to use when resolving tokens
+ * @param logger A Logger to use
+ * @throws ConfigurationException if an error occurs when copying
+ */
+ public PropertyAwareConfiguration(Configuration config, Settings settings, Logger logger)
+ throws ConfigurationException {
+ super(config);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Create a new <code>DefaultConfiguration</code> instance.
+ *
+ * @param name a <code>String</code> value
+ */
+ public PropertyAwareConfiguration(final String name, Settings settings, Logger logger) {
+ super(name);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Create a new <code>DefaultConfiguration</code> instance.
+ *
+ * @param name a <code>String</code> value
+ * @param location a <code>String</code> value
+ * @param settings The Settings to use when resolving tokens
+ * @param logger A Logger to use
+ */
+ public PropertyAwareConfiguration(final String name, final String location, Settings settings, Logger logger) {
+ super(name, location);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Create a new <code>DefaultConfiguration</code> instance.
+ *
+ * @param name config node name
+ * @param location Builder-specific locator string
+ * @param ns Namespace string (typically a URI). Should not be null; use ""
+ * if no namespace.
+ * @param prefix A short string prefixed to element names, associating
+ * elements with a longer namespace string. Should not be null; use "" if no
+ * namespace.
+ * @param settings The Settings to use when resolving tokens
+ * @param logger A Logger to use
+ */
+ public PropertyAwareConfiguration(final String name,
+ final String location,
+ final String ns,
+ final String prefix,
+ Settings settings,
+ Logger logger) {
+ super(name, location, ns, prefix);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Create a new <code>DefaultConfiguration</code> instance.
+ *
+ * @param config A DefaultConfiguration
+ * @param settings The Settings to use when resolving tokens
+ * @param logger A Logger to use
+ */
+ public PropertyAwareConfiguration(final DefaultConfiguration config, Settings settings, Logger logger)
+ throws ConfigurationException {
+ super(config, false);
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Set the value of this <code>Configuration</code> object to the specified string.
+ *
+ * @param value a <code>String</code> value
+ */
+ public void setValue(final String value) {
+ super.setValue(SettingsHelper.replace(value, this.settings, this.logger));
+ }
+
+ /**
+ * Set the value of the specified attribute to the specified string.
+ *
+ * @param name name of the attribute to set
+ * @param value a <code>String</code> value
+ */
+ public void setAttribute(final String name, final String value) {
+ super.setAttribute(name, SettingsHelper.replace(value, this.settings, this.logger));
+ }
+}
\ No newline at end of file
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,63 @@
+package org.apache.cocoon.components;
+
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.configuration.NamespacedSAXConfigurationHandler;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.util.Settings;
+import org.apache.cocoon.util.location.LocatedRuntimeException;
+
+/**
+ * Property Aware SAX Configuration Handler.
+ * This component extends the {@link org.apache.avalon.framework.configuration.SAXConfigurationHandler}
+ * by creating configurations that can contain placeholders for System Properties.
+ *
+ * @version SVN $Id: $
+ */
+public class PropertyAwareNamespacedSAXConfigurationHandler extends NamespacedSAXConfigurationHandler {
+
+ private Settings settings;
+ private Logger logger;
+
+ public PropertyAwareNamespacedSAXConfigurationHandler(Settings settings, Logger logger) {
+ super();
+ this.settings = settings;
+ this.logger = logger;
+ }
+
+ /**
+ * Create a new <code>PropertyAwareConfiguration</code> with the specified
+ * local name and location.
+ *
+ * @param localName a <code>String</code> value
+ * @param location a <code>String</code> value
+ * @return a <code>DefaultConfiguration</code> value
+ */
+ protected DefaultConfiguration createConfiguration( final String localName,
+ final String location )
+ {
+ return new PropertyAwareConfiguration(localName, location, this.settings, this.logger);
+ }
+
+ /**
+ * Create a new <code>PropertyAwareConfiguration</code> with the specified
+ * local name and location.
+ *
+ * @param localName a <code>String</code> value
+ * @param location a <code>String</code> value
+ * @return a <code>DefaultConfiguration</code> value
+ */
+ protected DefaultConfiguration createConfiguration( final String localName,
+ final String namespaceURI,
+ final String location )
+ {
+ DefaultConfiguration config = super.createConfiguration(localName, namespaceURI, location);
+ try {
+ return new PropertyAwareConfiguration(config, this.settings, this.logger);
+ } catch (Exception e) {
+ // This will never happen as the DefaultConfiguration constructor will always create a
+ // proper object from which to create the PropertyAwareConfiguration
+ // But if it somehow does, just throw a generic runtime exception
+ throw new LocatedRuntimeException("", e);
+ }
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareNamespacedSAXConfigurationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components;
+
+import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.util.Settings;
+
+/**
+ * Property Aware SAX Configuration Handler.
+ * This component extends the {@link SAXConfigurationHandler}
+ * by creating configurations that can contain placeholders for System Properties.
+ *
+ * @version SVN $Id: $
+ */
+public class PropertyAwareSAXConfigurationHandler extends SAXConfigurationHandler {
+
+ private Settings settings;
+ private Logger logger;
+
+ /**
+ * Constructor
+ * @param settings The Settings to use when processing the configuration
+ */
+ public PropertyAwareSAXConfigurationHandler(Settings settings, Logger logger) {
+ super();
+ this.settings = settings;
+ this.logger = logger;
+ }
+ /**
+ * Create a new <code>PropertyAwareConfiguration</code> with the specified
+ * local name and location.
+ *
+ * @param localName a <code>String</code> value
+ * @param location a <code>String</code> value
+ * @return a <code>DefaultConfiguration</code> value
+ */
+ protected DefaultConfiguration createConfiguration( final String localName,
+ final String location )
+ {
+ return new PropertyAwareConfiguration(localName, location, this.settings, this.logger);
+ }
+}
\ No newline at end of file
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/PropertyAwareSAXConfigurationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java Sun Mar 26 22:21:40 2006
@@ -38,6 +38,7 @@
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.ExtendedComponentSelector;
import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.components.PropertyAwareNamespacedSAXConfigurationHandler;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
import org.apache.cocoon.sitemap.PatternException;
@@ -45,6 +46,8 @@
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.LocationImpl;
import org.apache.cocoon.util.location.LocationUtils;
+import org.apache.cocoon.util.Settings;
+import org.apache.cocoon.util.SettingsHelper;
import org.apache.excalibur.source.Source;
import java.util.ArrayList;
@@ -356,7 +359,9 @@
try {
// Build a namespace-aware configuration object
- NamespacedSAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler();
+ Settings settings = SettingsHelper.getSettings(this.context);
+ NamespacedSAXConfigurationHandler handler =
+ new PropertyAwareNamespacedSAXConfigurationHandler(settings, getLogger());
AnnotationsFilter annotationsFilter = new AnnotationsFilter(handler);
SourceUtil.toSAX( source, annotationsFilter );
Configuration treeConfig = handler.getConfiguration();
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Sun Mar 26 22:21:40 2006
@@ -35,9 +35,12 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.Processor;
+import org.apache.cocoon.util.Settings;
+import org.apache.cocoon.util.SettingsHelper;
import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.components.ExtendedComponentSelector;
import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.components.PropertyAwareSAXConfigurationHandler;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
@@ -204,7 +207,8 @@
try {
Source source = this.resolver.resolveURI(xconfURL);
try {
- SAXConfigurationHandler handler = new SAXConfigurationHandler();
+ Settings settings = SettingsHelper.getSettings(this.context);
+ SAXConfigurationHandler handler = new PropertyAwareSAXConfigurationHandler(settings, getLogger());
SourceUtil.toSAX( this.manager, source, null, handler);
builtin = handler.getConfiguration();
} finally {
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.util;
+
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.TraversableSource;
+import org.apache.avalon.framework.logger.Logger;
+
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Collections;
+import java.util.Set;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This object holds the property settings for Cocoon. This interface is loosely based on the Settings interface
+ * introduced in 2.2 but is note equivalent to it as it is only meant to hold configuration properties.
+ *
+ * @version $Id$
+ */
+public class PropertySettings implements Settings {
+ /** The list of properties used to configure Cocoon. */
+ private Map properties = new HashMap();
+
+ /** Parameter map for the context protocol */
+ protected static final Map CONTEXT_PARAMETERS = Collections.singletonMap("force-traversable", Boolean.TRUE);
+
+ /**
+ * Initialize the settings for Cocoon.
+ * This method reads several property files and merges the result. If there
+ * is more than one definition for a property, the last one wins.
+ * The property files are read in the following order:
+ * 1) context://WEB-INF/properties/*.properties
+ * Default values for the core and each block - the order in which the files are read is not guaranteed.
+ * 2) context://WEB-INF/properties/[RUNNING_MODE]/*.properties
+ * Default values for the running mode - the order in which the files are read is not guaranteed.
+ * 3) Property providers (ToBeDocumented)
+ * 4) The environment (CLI, Servlet etc.) adds own properties (e.g. from web.xml)
+ * 5) Additional property file specified by the "org.apache.cocoon.settings" system property or
+ * if the property is not found, the file ".cocoon/settings.properties" is tried to be read from
+ * the user directory.
+ * 6) System properties
+ *
+ */
+ public PropertySettings(SourceResolver resolver, Logger logger) {
+
+ // now read all properties from the properties directory
+ readProperties("context://WEB-INF/properties", resolver);
+
+ // read additional properties file
+
+ String additionalPropertyFile = properties.containsKey(Settings.PROPERTY_USER_SETTINGS) ?
+ (String)properties.get(Settings.PROPERTY_USER_SETTINGS) :
+ System.getProperty(Settings.PROPERTY_USER_SETTINGS);
+
+ // if there is no property defining the addition file, we try it in the home directory
+ if ( additionalPropertyFile == null ) {
+ additionalPropertyFile = System.getProperty("user.home") + File.separator + ".cocoon/settings.properties";
+ final File testFile = new File(additionalPropertyFile);
+ if ( !testFile.exists() ) {
+ additionalPropertyFile = null;
+ }
+ }
+ if ( additionalPropertyFile != null ) {
+ logger.debug("Reading user settings from '" + additionalPropertyFile + "'");
+ final Properties p = new Properties();
+ try {
+ FileInputStream fis = new FileInputStream(additionalPropertyFile);
+ p.load(fis);
+ fis.close();
+ } catch (IOException ignore) {
+ logger.warn("Unable to read '" + additionalPropertyFile + "'.", ignore);
+ logger.warn("Continuing initialization.");
+ }
+ properties.putAll(p);
+ }
+ // now overwrite with system properties
+ properties.putAll(System.getProperties());
+
+ if (logger.isDebugEnabled()){
+ Iterator iter = properties.keySet().iterator();
+ logger.debug("Cocoon Properties:");
+ while (iter.hasNext()) {
+ String key = (String)iter.next();
+ logger.debug("Key: " + key + " Value: " + properties.get(key));
+ }
+ }
+ }
+
+ /**
+ * Read all property files from the given directory and apply them to the settings.
+ */
+ private void readProperties(String directoryName,
+ SourceResolver resolver) {
+ Source directory = null;
+ try {
+ directory = resolver.resolveURI(directoryName, null, CONTEXT_PARAMETERS);
+ if (directory.exists() && directory instanceof TraversableSource) {
+ final Iterator c = ((TraversableSource) directory).getChildren().iterator();
+ while (c.hasNext()) {
+ final Source src = (Source) c.next();
+ if ( src.getURI().endsWith(".properties") ) {
+ Properties props = new Properties();
+ final InputStream propsIS = src.getInputStream();
+ props.load(propsIS);
+ propsIS.close();
+ properties.putAll(props);
+ }
+ }
+ }
+ } catch (IOException ignore) {
+
+ } finally {
+ resolver.release(directory);
+ }
+ }
+
+ /**
+ * @see org.apache.cocoon.util.Settings#getProperty(java.lang.String)
+ */
+ public String getProperty(String name) {
+ return this.getProperty(name, null);
+ }
+/**
+ * @see org.apache.cocoon.util.Settings#getProperty(java.lang.String, java.lang.String)
+ */
+ public String getProperty(String key, String defaultValue) {
+ if ( key == null ) {
+ return defaultValue;
+ }
+ String value = (String)properties.get(key);
+
+ if ( value == null ) {
+ value = defaultValue;
+ }
+ return value;
+ }
+/**
+ * @see org.apache.cocoon.util.Settings#getProperties(java.lang.String)
+ */
+ public List getProperties(String keyPrefix) {
+ final List props = new ArrayList();
+ final Iterator kI = this.properties.keySet().iterator();
+ while ( kI.hasNext() ) {
+ final String name = (String)kI.next();
+ if ( name.startsWith(keyPrefix) && !props.contains(name) ) {
+ props.add(name);
+ }
+ }
+ return props;
+ }
+
+ /**
+ * @see org.apache.cocoon.util.Settings#getProperties()
+ */
+ public List getProperties() {
+ final List props = new ArrayList();
+ props.addAll(this.properties.keySet());
+
+ return props;
+ }
+
+ public int size() {
+ return this.properties.size();
+ }
+}
+
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/PropertySettings.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.util;
+
+import java.util.List;
+
+/**
+ * This object holds the property settings for Cocoon. This interface is loosely based on the Settings interface
+ * introduced in 2.2 but is note equivalent to it as it is only meant to hold configuration properties.
+ *
+ * @version $Id$
+ */
+public interface Settings {
+ /** The role to lookup this bean. */
+ String ROLE = Settings.class.getName();
+
+ /** Name of the property specifying a custom user properties file. */
+ String PROPERTY_USER_SETTINGS = "org.apache.cocoon.settings";
+
+ /**
+ * Get the value of a property.
+ * @param key The name of the property.
+ * @return The value of the property or null.
+ */
+ String getProperty(String key);
+
+ /**
+ * Get the value of a property.
+ * @param key The name of the property.
+ * @param defaultValue The value returned if the property is not available.
+ * @return The value of the property or if the property cannot
+ * be found the default value.
+ */
+ String getProperty(String key, String defaultValue);
+
+ /**
+ * Return all available properties starting with the prefix.
+ * @param keyPrefix The prefix each property name must have.
+ * @return A list of property names (including the prefix) or
+ * an empty list.
+ */
+ List getProperties(String keyPrefix);
+
+ /**
+ * Return all available properties
+ * @return A list of all property names or an empty list.
+ */
+ List getProperties();
+
+ /**
+ * Return the number of properties that have been defined
+ * @return The number of properties that have been defined.
+ */
+ int size();
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/Settings.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.util;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.Logger;
+
+/**
+ * Helper class to create Stettings and for replacing property references with the value of the
+ * property
+ *
+ * @version $Id: $
+ * @since 2.1.9
+ */
+public class SettingsHelper {
+
+ /**
+ * Create the settings object
+ * @param context The current context
+ * @param logger A logger to use to log any errors.
+ * @throws ContextException
+ */
+ public static void createSettings(DefaultContext context, Logger logger) throws ContextException {
+ SimpleSourceResolver resolver = new SimpleSourceResolver();
+ resolver.enableLogging(logger);
+ resolver.contextualize(context);
+ Settings settings = new PropertySettings(resolver, logger);
+ context.put(Settings.PROPERTY_USER_SETTINGS, settings);
+ }
+
+ /**
+ * Return the Settings object
+ * @param context The context
+ * @return The global Settings
+ */
+ public static Settings getSettings(Context context) {
+ Settings settings = null;
+ try {
+ settings = (Settings) context.get(Settings.PROPERTY_USER_SETTINGS);
+ } catch (Exception e) {
+ // Ignore the exception;
+ }
+ return settings;
+ }
+
+ /**
+ * Replace all property references in the string with the current value
+ * and return it.
+ */
+ public static String replace(String value, Settings settings, Logger logger) {
+ // quick test for null or no references
+ if (value == null || value.indexOf("${") == -1 || settings == null) {
+ return value;
+ }
+ final StringBuffer buffer = new StringBuffer();
+ int prev = 0;
+ int pos;
+
+ // search for the next instance of $ from the 'prev' position
+ while ((pos = value.indexOf("$", prev)) >= 0) {
+
+ // if there was any text before this, add it
+ if (pos > prev) {
+ buffer.append(value.substring(prev, pos));
+ }
+
+ // if we are at the end of the string, end
+ if (pos == (value.length() - 1)) {
+ buffer.append("$");
+ prev = pos + 1;
+ } else if (value.charAt(pos + 1) != '{') {
+ // peek ahead to see if the next char is a property or not
+ // not a property: insert the char as a literal
+ buffer.append(value.substring(pos, pos + 2));
+ prev = pos + 2;
+
+ } else {
+ // start token found, check for end token
+ int endName = value.indexOf('}', pos);
+ if (endName == -1) {
+ // no end token found, just append the rest
+ buffer.append(value.substring(pos));
+ prev = value.length();
+ } else {
+ final String propertyName = value.substring(pos + 2, endName);
+ String propertyValue = getProperty(propertyName, settings);
+ // compatibility fallback - if the value is null, just readd token
+ if (propertyValue == null) {
+ logger.warn("Property " + propertyName + " not found.");
+ buffer.append("${");
+ buffer.append(propertyName);
+ buffer.append('}');
+ } else {
+ buffer.append(propertyValue);
+ }
+ prev = endName + 1;
+ }
+ }
+ }
+ // no more tokens found
+ // append the rest
+ if (prev < value.length()) {
+ buffer.append(value.substring(prev));
+ }
+ return buffer.toString();
+ }
+
+ static String getProperty(String name, Settings settings) {
+ String value = null;
+ if (settings != null) {
+ value = settings.getProperty(name);
+ }
+ if (value == null) {
+ value = System.getProperty(name);
+ }
+ return value;
+ }
+}
Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SettingsHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SimpleSourceResolver.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SimpleSourceResolver.java?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SimpleSourceResolver.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/SimpleSourceResolver.java Sun Mar 26 22:21:40 2006
@@ -0,0 +1,178 @@
+package org.apache.cocoon.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.source.impl.ContextSourceFactory;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.impl.ResourceSourceFactory;
+import org.apache.excalibur.source.impl.URLSourceFactory;
+
+/**
+ * A minimalist <code>SourceResolver</code> that handles a fixed restricted number of protocols. It is
+ * used as a bootstrap resolver to load roles and imported files in a service manager.
+ * <p>
+ * The supported protocols schemes are:
+ * <ul>
+ * <li><code>resource</code> to load resources in the classpath,</li>
+ * <li><code>context</code> to load resources from the context, defined by the <code>context-root</code>
+ * entry in the Avalon {@link Context} (either a {@link File} or an {@link URL}), or if not
+ * present, from the <code>user.dir</code> system property,</li>
+ * <li>all standard JDK schemes (http, file, etc).
+ * </ul>
+ * Relative URIs are resolved relatively to the context root, i.e. similarily to "<code>context:</code>".
+ *
+ * @version $Id: SimpleSourceResolver.java 380191 2006-02-23 18:31:51Z cziegeler $
+ * @since 2.2
+ */
+public final class SimpleSourceResolver extends AbstractLogEnabled
+ implements ThreadSafe, Contextualizable, SourceResolver {
+
+ // The base URI, initialized in contextualize()
+ private String contextBase;
+
+ // The three factories we use (no need for a selector nor a Map)
+ private ResourceSourceFactory resourceFactory = new ResourceSourceFactory();
+ private URLSourceFactory urlFactory = new URLSourceFactory();
+ private ContextSourceFactory contextFactory = new ContextSourceFactory();
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+ */
+ public void enableLogging(Logger logger) {
+ super.enableLogging(logger);
+ this.resourceFactory.enableLogging(logger);
+ this.urlFactory.enableLogging(logger);
+ this.contextFactory.enableLogging(logger);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.contextFactory.contextualize(context);
+ try {
+ this.contextFactory.service(new SimpleServiceManager(this));
+ } catch (ServiceException se) {
+ throw new ContextException("Unable to service context factory.", se);
+ }
+
+ try {
+ // Similar to Excalibur's SourceResolverImpl, and consistent with ContextHelper.CONTEXT_ROOT_URL
+ if( context.get("context-root") instanceof URL) {
+ contextBase = ((URL)context.get("context-root")).toExternalForm();
+ } else {
+ contextBase = ((File)context.get("context-root")).toURL().toExternalForm();
+ }
+ } catch(ContextException ce) {
+ // set the base URL to the current directory
+ try {
+ contextBase = new File(System.getProperty("user.dir")).toURL().toExternalForm();
+ } catch( MalformedURLException mue) {
+ throw new ContextException( "Malformed URL for user.dir, and no context-root exists", mue);
+ }
+ } catch( MalformedURLException mue) {
+ throw new ContextException("Malformed URL for context-root", mue);
+ }
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Base URL set to " + this.contextBase);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String)
+ */
+ public Source resolveURI(String uri) throws MalformedURLException, IOException {
+ return resolveURI(uri, contextBase, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String, java.lang.String, java.util.Map)
+ */
+ public Source resolveURI(String uri, String base, Map params) throws MalformedURLException, IOException {
+ if (uri.startsWith("resource://")) {
+ return resourceFactory.getSource(uri, null);
+ } else if (uri.startsWith("context://")) {
+ return this.contextFactory.getSource(uri, params);
+ } else {
+ // special handling for windows and unix file paths
+ if( uri.length() > 1 && uri.charAt( 1 ) == ':' ) {
+ uri = "file:/" + uri;
+ base = null;
+ } else if( uri.length() > 2 && uri.charAt(0) == '/' && uri.charAt(2) == ':' ) {
+ uri = "file:" + uri;
+ base = null;
+ }
+ URL url;
+ if ( base == null ) {
+ url = new URL(uri);
+ } else {
+ URL baseURL = new URL(base);
+ url = new URL(baseURL, uri);
+ }
+ return this.urlFactory.getSource(url.toExternalForm(), params);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.excalibur.source.SourceResolver#release(org.apache.excalibur.source.Source)
+ */
+ public void release(Source source) {
+ if ( source != null ) {
+ if ( "context".equals(source.getScheme()) ) {
+ this.contextFactory.release(source);
+ } else if ( "resource".equals(source.getScheme()) ) {
+ this.resourceFactory.release(source);
+ } else {
+ this.urlFactory.release(source);
+ }
+ }
+ }
+
+ public static final class SimpleServiceManager implements ServiceManager {
+
+ private final SourceResolver resolver;
+
+ public SimpleServiceManager(SourceResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.service.ServiceManager#hasService(java.lang.String)
+ */
+ public boolean hasService(String role) {
+ return SourceResolver.ROLE.equals(role);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.service.ServiceManager#lookup(java.lang.String)
+ */
+ public Object lookup(String role) throws ServiceException {
+ if ( !SourceResolver.ROLE.equals(role) ) {
+ throw new ServiceException("SimpleServiceManager", "Unable to lookup component with role: " + role);
+ }
+ return this.resolver;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.service.ServiceManager#release(java.lang.Object)
+ */
+ public void release(Object component) {
+ // nothing to do
+ }
+ }
+}
+
Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf Sun Mar 26 22:21:40 2006
@@ -91,8 +91,8 @@
<!-- FOM (Flow Object Model) -->
<component-instance name="javascript" class="org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter">
<load-on-startup>resource://org/apache/cocoon/components/flow/javascript/fom/fom_system.js</load-on-startup>
- <reload-scripts>true</reload-scripts>
- <check-time>4000</check-time>
+ <reload-scripts>${javascript.reload-scripts}</reload-scripts>
+ <check-time>${javascript.check-time}</check-time>
<!-- <debugger>enabled</debugger> --> <!-- JavaScript Debugger support -->
</component-instance>
</flow-interpreters>
@@ -124,12 +124,12 @@
| Enable this feature for web applications by setting
| 'session-bound-continuations' to true.
+-->
- <continuations-manager logger="flow.manager" time-to-live="3600000"
+ <continuations-manager logger="flow.manager" time-to-live="${continuations-manager.time-to-live}"
session-bound-continuations="false"
continuation-sharing-bug-compatible="false">
<expirations-check type="periodic">
- <offset>180000</offset>
- <period>180000</period>
+ <offset>${continuations-manager.expirations-check.offset}</offset>
+ <period>${continuations-manager.expirations-check.period}</period>
</expirations-check>
</continuations-manager>
@@ -346,7 +346,7 @@
| would appear in the serialized output again.
+-->
<xml-parser class="org.apache.excalibur.xml.impl.JaxpParser"
- logger="core.xml-parser" pool-max="32">
+ logger="core.xml-parser" pool-max="${xml-parser.pool-max}">
<parameter name="validate" value="false"/>
<parameter name="namespace-prefixes" value="false"/>
<parameter name="stop-on-warning" value="true"/>
@@ -436,7 +436,7 @@
| in the cache will be thrown out.
+-->
<transient-store logger="core.store.transient">
- <parameter name="maxobjects" value="1000"/>
+ <parameter name="maxobjects" value="${transient-store.maxobjects}"/>
</transient-store>
<!--+
@@ -451,7 +451,7 @@
| in the cache will be thrown out.
+-->
<store logger="core.store">
- <parameter name="maxobjects" value="1000"/>
+ <parameter name="maxobjects" value="${store.maxobjects}"/>
<parameter name="use-cache-directory" value="true"/>
</store>
@@ -482,19 +482,19 @@
| How much free memory shall be available in the jvm?
| If not specified, defaults to 1Mb.
+-->
- <parameter name="freememory" value="2048000"/>
+ <parameter name="freememory" value="${store-janitor.freememory}"/>
<!--+
| How much memory at max jvm can consume?
| The default max heapsize for Sun's JVM is (almost) 64Mb,
| can be increased by specifying -Xmx command line parameter.
| If not specified, defaults to 66600000 bytes.
+-->
- <parameter name="heapsize" value="66600000"/>
+ <parameter name="heapsize" value="${store-janitor.heapsize}"/>
<!--+
| How often shall the cleanup thread check memory?
| If not specified, defaults to 10 seconds.
+-->
- <parameter name="cleanupthreadinterval" value="10"/>
+ <parameter name="cleanupthreadinterval" value="${store-janitor.cleanup-thread-interval}"/>
<!--+
| Experimental adaptive algorithm for cleanup interval
<parameter name="adaptivethreadinterval" value="true"/>
@@ -503,7 +503,7 @@
| What percent of the store elements shall be dropped on low memory?
| If not specified, defaults to 10%
+-->
- <parameter name="percent_to_free" value="10"/>
+ <parameter name="percent_to_free" value="${store-janitor.percent-to-free}"/>
<!--+
| Shall garbage collector be invoked on low memory?
| If not specified, defaults to false.
@@ -571,7 +571,7 @@
| Reload check delay. Default 60000 (1 minute), 0 means no delay
| (check always), -1 means no reload.
+-->
- <reload-interval>60000</reload-interval>
+ <reload-interval>${i18n-bundles.reload-interval}</reload-interval>
<!--+
| Location of the default message catalogue. Optional.
+-->
@@ -594,8 +594,8 @@
| the intermediate results of the pipeline stages reducing the overhead
| of xml parsing/serialization.
+-->
- <xml-serializer class="org.apache.cocoon.components.sax.XMLByteStreamCompiler" logger="core.xml.serializer" pool-max="32"/>
- <xml-deserializer class="org.apache.cocoon.components.sax.XMLByteStreamInterpreter" logger="core.xml.deserializer" pool-max="32"/>
+ <xml-serializer class="org.apache.cocoon.components.sax.XMLByteStreamCompiler" logger="core.xml.serializer" pool-max="${xml-serializer.pool-max}"/>
+ <xml-deserializer class="org.apache.cocoon.components.sax.XMLByteStreamInterpreter" logger="core.xml.deserializer" pool-max="${xml-deserializer.pool-max}"/>
<!--+
| The Cache Manager is a component that can be used to cache content.
Added: cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties?rev=389028&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties (added)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties Sun Mar 26 22:21:40 2006
@@ -0,0 +1,44 @@
+javascript.reload-scripts = true
+javascript.check-time = 4000
+continuations-manager.time-to-live = 3600000
+continuations-manager.expirations-check.offset = 180000
+continuations-manager.expirations-check.period = 180000
+xml-parser.pool-max = 32
+transient-store.maxobjects = 1000
+store.maxobjects = 1000
+store-janitor.freememory = 2048000
+store-janitor.heapsize = 66600000
+store-janitor.cleanup-thread-interval = 10
+store-janitor.percent-to-free = 10
+i18n-bundles.reload-interval = 60000
+xml-serializer.pool-max = 32
+xml-deserializer.pool-max = 32
+# sitemap variables
+
+# Generators
+file-generator.pool-max = 16
+directory-generator.pool-max = 16
+request-generator.pool-max = 16
+stream-generator.pool-max = 16
+status-generator.pool-max = 16
+jx-generator.pool-max = 16
+# Transformers
+xslt-transformer.pool-max = 16
+xalan-transformer.pool-max = 16
+xsltc-transformer.pool-max = 16
+include-transformer.pool-max = 16
+xinclude-transformer.pool-max = 16
+cinclude-transformer.pool-max = 16
+log-transformer.pool-max = 16
+jx-transformer.pool-max = 16
+
+# Serializers
+html-serializer.pool-max = 32
+xhtml-serializer.pool-max = 64
+xhtml11-serializer.pool-max = 64
+
+# Readers
+resource-reader.pool-max = 32
+
+# Pipelines
+expires-pipeline.cache-expires = 180
Propchange: cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/properties/core.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/sitemap.xmap?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/sitemap.xmap Sun Mar 26 22:21:40 2006
@@ -65,15 +65,15 @@
| All components follow this scheme.
+-->
<map:generators default="file">
- <map:generator label="content" logger="sitemap.generator.file" name="file" pool-max="32" src="org.apache.cocoon.generation.FileGenerator"/>
- <map:generator label="content" logger="sitemap.generator.directory" name="directory" pool-max="16" src="org.apache.cocoon.generation.DirectoryGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.file" name="file" pool-max="${file-generator.pool-max}" src="org.apache.cocoon.generation.FileGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.directory" name="directory" pool-max="${directory-generator.pool-max}" src="org.apache.cocoon.generation.DirectoryGenerator"/>
<map:generator label="content" logger="sitemap.generator.xpathdirectory" name="xpathdirectory" src="org.apache.cocoon.generation.XPathDirectoryGenerator"/>
<map:generator label="content" logger="sitemap.generator.imagedirectory" name="imagedirectory" src="org.apache.cocoon.generation.ImageDirectoryGenerator"/>
<map:generator label="content" logger="sitemap.generator.mp3directory" name="mp3directory" src="org.apache.cocoon.generation.MP3DirectoryGenerator"/>
- <map:generator label="content" logger="sitemap.generator.request" name="request" pool-max="16" src="org.apache.cocoon.generation.RequestGenerator"/>
- <map:generator label="content" logger="sitemap.generator.stream" name="stream" pool-max="16" src="org.apache.cocoon.generation.StreamGenerator"/>
- <map:generator label="content" logger="sitemap.generator.status" name="status" pool-max="16" src="org.apache.cocoon.generation.StatusGenerator"/>
- <map:generator label="content" logger="sitemap.generator.jx" name="jx" pool-max="16" src="org.apache.cocoon.generation.JXTemplateGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.request" name="request" pool-max="${request-generator.pool-max}" src="org.apache.cocoon.generation.RequestGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.stream" name="stream" pool-max="${stream-generator.pool-max}" src="org.apache.cocoon.generation.StreamGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.status" name="status" pool-max="${status-generator.pool-max}" src="org.apache.cocoon.generation.StatusGenerator"/>
+ <map:generator label="content" logger="sitemap.generator.jx" name="jx" pool-max="${jx-generator.pool-max}" src="org.apache.cocoon.generation.JXTemplateGenerator"/>
<!-- The notifying generator can only be used in a <handle-errors> section -->
<map:generator name="notifying" src="org.apache.cocoon.sitemap.NotifyingGenerator"/>
<!-- The exception generator can only be used in a <handle-errors> section : it produces an XML
@@ -93,7 +93,7 @@
<map:transformers default="xslt">
<!-- NOTE: This is the default XSLT processor. -->
- <map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-max="32" src="org.apache.cocoon.transformation.TraxTransformer">
+ <map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-max="${xslt-transformer.pool-max}" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
@@ -102,7 +102,7 @@
</map:transformer>
<!-- NOTE: This is the same as the default processor but with a different name (for compatibility) -->
- <map:transformer logger="sitemap.transformer.xalan" name="xalan" pool-max="32" src="org.apache.cocoon.transformation.TraxTransformer">
+ <map:transformer logger="sitemap.transformer.xalan" name="xalan" pool-max="${xalan-transformer.pool-max}" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
@@ -111,7 +111,7 @@
</map:transformer>
<!-- NOTE: You can also try XSLTC as the default processor. If you use Xalan extensions, use the "xalan" transformer. -->
- <map:transformer logger="sitemap.transformer.xsltc" name="xsltc" pool-max="32" src="org.apache.cocoon.transformation.TraxTransformer">
+ <map:transformer logger="sitemap.transformer.xsltc" name="xsltc" pool-max="${xsltc-transformer.pool-max}" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
@@ -119,17 +119,17 @@
<check-includes>true</check-includes>
</map:transformer>
- <map:transformer logger="sitemap.transformer.include" name="include" pool-max="16" src="org.apache.cocoon.transformation.IncludeTransformer"/>
- <map:transformer logger="sitemap.transformer.xinclude" name="xinclude" pool-max="16" src="org.apache.cocoon.transformation.XIncludeTransformer"/>
- <map:transformer logger="sitemap.transformer.cinclude" name="cinclude" pool-max="16" src="org.apache.cocoon.transformation.CIncludeTransformer"/>
+ <map:transformer logger="sitemap.transformer.include" name="include" pool-max="${include-transformer.pool-max}" src="org.apache.cocoon.transformation.IncludeTransformer"/>
+ <map:transformer logger="sitemap.transformer.xinclude" name="xinclude" pool-max="${xinclude-transformer.pool-max}" src="org.apache.cocoon.transformation.XIncludeTransformer"/>
+ <map:transformer logger="sitemap.transformer.cinclude" name="cinclude" pool-max="${cinclude-transformer.pool-max}" src="org.apache.cocoon.transformation.CIncludeTransformer"/>
<map:transformer logger="sitemap.transformer.encodeURL" name="encodeURL" src="org.apache.cocoon.transformation.EncodeURLTransformer"/>
<map:transformer logger="sitemap.transformer.write-source" name="write-source" src="org.apache.cocoon.transformation.SourceWritingTransformer"/>
<map:transformer logger="sitemap.transformer.jpath" name="jpath" src="org.apache.cocoon.transformation.JPathTransformer"/>
<map:transformer logger="sitemap.transformer.filter" name="filter" src="org.apache.cocoon.transformation.FilterTransformer"/>
<map:transformer logger="sitemap.transformer.writeDOMsession" name="writeDOMsession" src="org.apache.cocoon.transformation.WriteDOMSessionTransformer"/>
<map:transformer logger="sitemap.transformer.readDOMsession" name="readDOMsession" src="org.apache.cocoon.transformation.ReadDOMSessionTransformer"/>
- <map:transformer logger="sitemap.transformer.log" name="log" pool-max="16" src="org.apache.cocoon.transformation.LogTransformer"/>
- <map:transformer logger="sitemap.transformer.jx" name="jx" pool-max="16" src="org.apache.cocoon.transformation.JXTemplateTransformer"/>
+ <map:transformer logger="sitemap.transformer.log" name="log" pool-max="${log-transformer.pool-max}" src="org.apache.cocoon.transformation.LogTransformer"/>
+ <map:transformer logger="sitemap.transformer.jx" name="jx" pool-max="${jx-transformer.pool-max}" src="org.apache.cocoon.transformation.JXTemplateTransformer"/>
<map:transformer logger="sitemap.transformer.paginate" name="paginate" src="org.apache.cocoon.transformation.pagination.Paginator"/>
</map:transformers>
@@ -142,7 +142,7 @@
<map:serializer logger="sitemap.serializer.links" name="links" src="org.apache.cocoon.serialization.LinkSerializer"/>
<map:serializer logger="sitemap.serializer.xml" mime-type="text/xml" name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
- <map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" pool-max="32" src="org.apache.cocoon.serialization.HTMLSerializer">
+ <map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" pool-max="${html-serializer.pool-max}" src="org.apache.cocoon.serialization.HTMLSerializer">
<doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
</map:serializer>
@@ -167,7 +167,7 @@
<doctype-system>http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd</doctype-system>
</map:serializer>
- <map:serializer logger="sitemap.serializer.xhtml" mime-type="text/html" name="xhtml" pool-max="64" src="org.apache.cocoon.serialization.XMLSerializer">
+ <map:serializer logger="sitemap.serializer.xhtml" mime-type="text/html" name="xhtml" pool-max="${xhtml-serializer.pool-max}" src="org.apache.cocoon.serialization.XMLSerializer">
<!--+
| You can choose from Strict, Transitional, or Frameset XHTML.
| For Strict XHTML set doctype to:
@@ -188,7 +188,7 @@
<encoding>UTF-8</encoding>
</map:serializer>
- <map:serializer logger="sitemap.serializer.xhtml" mime-type="application/xhtml+xml" name="xhtml11" pool-max="64" src="org.apache.cocoon.serialization.XMLSerializer">
+ <map:serializer logger="sitemap.serializer.xhtml" mime-type="application/xhtml+xml" name="xhtml11" pool-max="${xhtml11-serializer.pool-max}" src="org.apache.cocoon.serialization.XMLSerializer">
<doctype-public>-//W3C//DTD XHTML 1.1//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</doctype-system>
<encoding>UTF-8</encoding>
@@ -211,7 +211,7 @@
| reader. They are useful for delivering binary content like images.
+-->
<map:readers default="resource">
- <map:reader logger="sitemap.reader.resource" name="resource" pool-max="32" src="org.apache.cocoon.reading.ResourceReader">
+ <map:reader logger="sitemap.reader.resource" name="resource" pool-max="${resource-reader.pool-max}" src="org.apache.cocoon.reading.ResourceReader">
<!--+
| Resource reader has these configuration parameters:
<expires>-1</expires>
@@ -432,7 +432,7 @@
| period of time (expires). The cache key is the current uri.
+-->
<map:pipe name="expires" src="org.apache.cocoon.components.pipeline.impl.ExpiresCachingProcessingPipeline">
- <parameter name="cache-expires" value="180"/> <!-- Expires in secondes -->
+ <parameter name="cache-expires" value="${expires-pipeline.cache-expires}"/> <!-- Expires in secondes -->
</map:pipe>
</map:pipes>
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sun Mar 26 22:21:40 2006
@@ -180,6 +180,12 @@
<release version="@version@" date="@date@">
-->
<release version="2.1.9" date="TBD">
+ <action dev="RG" type="add">
+ Configuration values can now be set externally. The properties that can be modified can be identified by
+ looking at the property files in WEB-INF/properties. The properties can be overriden by specifying them as
+ system properties when invoking Cocoon or by placing them in a property file and identifying its location via
+ the "org.apache.cocoon.settings" system property. The default Cocoon script sets this to ./cocoon.properties.
+ </action>
<action dev="AG" type="fix" fixes-bug="COCOON-1814" due-to="Mark Lundquist" due-to-email="mlundquist2@comcast.net">
Deprecated method o.a.c.environment.Environment.getOutputStream() still used internally.
</action>
@@ -241,7 +247,7 @@
</action>
<action dev="AS" type="add" fixes-bug="COCOON-1789" due-to="Simone Gianni" due-to-email="s.gianni@thebug.it">
Add Char datatype to forms.
- </action>
+ </action>
<action dev="JBQ" type="add" fixes-bug="COCOON-1729" due-to="Rolf Metternich" due-to-email="rolf.metternich@ahafabrik.de">
Allow to add multiple rows at once to a Repeater using <fd:repeater-action command="add-row" number-of-rows="5" ...>
</action>
@@ -421,11 +427,11 @@
</action>
<action dev="CZ" type="add">
Portal Block: Provide user name to portlets.
- </action>
+ </action>
<action dev="CZ" type="fix">
Portal Block: Make wsrp event adapter thread safe, fix error in disposing wsrp
producer and update portals bridges to 1.0.
- </action>
+ </action>
<action dev="AG" type="update">
Replace deprecated library excalibur-io 1.1 with commons-io 1.1.
The file excalibur-io-1.1.jar is no longer part of the cocoon distribution.
@@ -434,7 +440,7 @@
</action>
<action dev="AG" type="update">
Updated asm to 2.1, asm-util to 2.1 and groovy to 1.0-jsr-04.
- </action>
+ </action>
<action dev="AN" type="fix">
XSP block: Reintroduce locally scoped xspAttr in xsp.xsl to improve backwards compatibility for pre-2.1.9
logicsheets. (Suggestion by Vadim Gritsenko).
@@ -576,7 +582,7 @@
CForms block: new Tree widget, heavily inspired by Swing's JTree. Features Ajax, selection listeners,
and a lightweight data model with two implementations: a generic one, and a source-based one to build
file explorers.
- </action>
+ </action>
<action dev="JHS" type="add" fixes-bug="36781" due-to="Thomas Lutz" due-to-email="mattom@gmx.at">
CForms: The repeater widget now supports min and max-size attributes.
</action>
Modified: cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl Sun Mar 26 22:21:40 2006
@@ -325,6 +325,7 @@
<fileset dir="@{{dir}}/samples">
<exclude name="**/*.gif"/>
<exclude name="**/*.jpg"/>
+ <exclude name="WEB-INF/**"/>
</fileset>
<fileset dir="@{{dir}}/conf" includes="*.xsamples"/>
</copy>
@@ -338,6 +339,17 @@
<copy todir="${{build.webapp.classes}}" filtering="off">
<fileset dir="${{build.blocks}}/@{{name}}/samples"/>
</copy>
+ <!-- Test if this block has sample WEB-INF files -->
+ <if>
+ <available type="dir" file="@{{dir}}/samples/WEB-INF/"/>
+ <then>
+ <copy filtering="on" todir="${{build.webapp.webinf}}">
+ <fileset dir="@{{dir}}/samples/WEB-INF/">
+ <include name="**"/>
+ </fileset>
+ </copy>
+ </then>
+ </if>
</then>
</if>
</sequential>
Modified: cocoon/branches/BRANCH_2_1_X/tools/targets/webapp-build.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/targets/webapp-build.xml?rev=389028&r1=389027&r2=389028&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/targets/webapp-build.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/targets/webapp-build.xml Sun Mar 26 22:21:40 2006
@@ -48,6 +48,7 @@
<include name="entities/**"/>
<include name="classes/**"/>
<include name="*.x*"/>
+ <include name="properties/**"/>
</fileset>
</copy>