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/08/30 08:34:51 UTC
svn commit: r438393 - in
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon:
components/treeprocessor/sitemap/SitemapLanguage.java
core/container/spring/avalon/AvalonBeanPostProcessor.java
core/container/spring/avalon/AvalonUtils.java
Author: cziegeler
Date: Tue Aug 29 23:34:50 2006
New Revision: 438393
URL: http://svn.apache.org/viewvc?rev=438393&view=rev
Log:
Continue implementation
Added:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java (with props)
Modified:
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/container/spring/avalon/AvalonBeanPostProcessor.java
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=438393&r1=438392&r2=438393&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 Tue Aug 29 23:34:50 2006
@@ -66,6 +66,7 @@
import org.apache.cocoon.configuration.impl.PropertyHelper;
import org.apache.cocoon.configuration.impl.SettingsHelper;
import org.apache.cocoon.core.container.spring.BeanFactoryFactoryImpl;
+import org.apache.cocoon.core.container.spring.avalon.AvalonUtils;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
import org.apache.cocoon.generation.Generator;
@@ -447,7 +448,7 @@
}
// replace properties?
if ( componentConfig == null || componentConfig.getAttributeAsBoolean("replace-properties", true) ) {
- tree = this.replaceProperties(tree, settings);
+ tree = AvalonUtils.replaceProperties(tree, settings);
}
// if we want to add the default includes and have no component section
@@ -582,32 +583,6 @@
return result;
}
- /**
- * Replace all properties
- */
- protected Configuration replaceProperties(Configuration tree, Settings settings)
- throws ConfigurationException {
- final DefaultConfiguration root = new DefaultConfiguration(tree, true);
- this.convert(root, settings);
- return tree;
- }
-
- protected void convert(DefaultConfiguration config, Settings settings)
- throws ConfigurationException {
- final String[] names = config.getAttributeNames();
- for(int i=0; i<names.length; i++) {
- final String value = config.getAttribute(names[i]);
- config.setAttribute(names[i], PropertyHelper.replace(value, settings));
- }
- final String value = config.getValue(null);
- if ( value != null ) {
- config.setValue(PropertyHelper.replace(value, settings));
- }
- final Configuration[] children = config.getChildren();
- for(int m=0; m<children.length; m++) {
- convert((DefaultConfiguration)children[m], settings);
- }
- }
/**
* Return the list of <code>ProcessingNodes</code> part of this tree that
* are <code>Disposable</code>. Care should be taken to properly dispose
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java?rev=438393&r1=438392&r2=438393&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java Tue Aug 29 23:34:50 2006
@@ -1,11 +1,8 @@
package org.apache.cocoon.core.container.spring.avalon;
-import java.io.ByteArrayInputStream;
-
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
-import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.logger.Logger;
@@ -13,7 +10,6 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.core.container.util.ConfigurationBuilder;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory;
@@ -113,10 +109,7 @@
if ( config == null ) {
config = EMPTY_CONFIG;
}
- ConfigurationBuilder builder = new ConfigurationBuilder(this.settings);
- // this is a little bit hacky but should do the trick
- DefaultConfigurationSerializer serializer = new DefaultConfigurationSerializer();
- config = builder.build(new ByteArrayInputStream(serializer.serialize(config).getBytes("utf-8")));
+ config = AvalonUtils.replaceProperties(config, this.settings);
info.setProcessedConfiguration(config);
}
if ( bean instanceof Configurable ) {
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java?rev=438393&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java Tue Aug 29 23:34:50 2006
@@ -0,0 +1,58 @@
+/*
+ * 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.core.container.spring.avalon;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.configuration.impl.PropertyHelper;
+
+/**
+ * Some utility methods for handling Avalon stuff.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class AvalonUtils {
+
+ /**
+ * Replace all properties
+ */
+ public static Configuration replaceProperties(Configuration tree, Settings settings)
+ throws ConfigurationException {
+ final DefaultConfiguration root = new DefaultConfiguration(tree, true);
+ convert(root, settings);
+ return tree;
+ }
+
+ protected static void convert(DefaultConfiguration config, Settings settings)
+ throws ConfigurationException {
+ final String[] names = config.getAttributeNames();
+ for(int i=0; i<names.length; i++) {
+ final String value = config.getAttribute(names[i]);
+ config.setAttribute(names[i], PropertyHelper.replace(value, settings));
+ }
+ final String value = config.getValue(null);
+ if ( value != null ) {
+ config.setValue(PropertyHelper.replace(value, settings));
+ }
+ final Configuration[] children = config.getChildren();
+ for(int m=0; m<children.length; m++) {
+ convert((DefaultConfiguration)children[m], settings);
+ }
+ }
+}
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java
------------------------------------------------------------------------------
svn:keywords = Id