cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r453145 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring: SettingsElementParser.java avalon/AvalonBeanPostProcessor.java avalon/AvalonElementParser.java avalon/AvalonServiceManager.java
Date Thu, 05 Oct 2006 08:36:51 GMT
Author: cziegeler
Date: Thu Oct  5 01:36:50 2006
New Revision: 453145

URL: http://svn.apache.org/viewvc?view=rev&rev=453145
Log:
Continue support for bean configuration (not finished yet)

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonServiceManager.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java?view=diff&rev=453145&r1=453144&r2=453145
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
Thu Oct  5 01:36:50 2006
@@ -66,7 +66,7 @@
         // register a PropertyPlaceholderConfigurer
         this.addComponent(CocoonPropertyOverrideConfigurer.class.getName(), CocoonPropertyOverrideConfigurer.class.getName(),
null, true, parserContext.getRegistry());
 
-        // add the servelt context as a bean
+        // add the servlet context as a bean
         this.addComponent(ServletContextFactoryBean.class.getName(), ServletContext.class.getName(),
null, false, parserContext.getRegistry());
         return null;
     }

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?view=diff&rev=453145&r1=453144&r2=453145
==============================================================================
--- 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
Thu Oct  5 01:36:50 2006
@@ -16,6 +16,9 @@
 */
 package org.apache.cocoon.core.container.spring.avalon;
 
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -73,6 +76,56 @@
         this.logger = logger;
     }
 
+    public void init() {
+        if ( true ) {
+            return;
+        }
+        // replace properties in configuration objects
+        final Iterator i = this.configurationInfo.getComponents().values().iterator();
+        while ( i.hasNext() ) {
+            final ComponentInfo info = (ComponentInfo) i.next();
+            if ( info.getConfiguration() != null ) {
+                final List names = this.settings.getPropertyNames(info.getRole() + '.');
+                if ( info.getAlias() != null ) {
+                    names.addAll(this.settings.getPropertyNames(info.getAlias() + '.'));
+                }
+                final Iterator namesIter = names.iterator();
+                while ( namesIter.hasNext() ) {
+                    final String name = (String)namesIter.next();
+                    final String value = this.settings.getProperty(name);
+                    String propName;
+                    if ( name.startsWith(info.getRole()) ) {
+                        propName = name.substring(info.getRole().length() + 1);
+                    } else {
+                        propName = name.substring(info.getAlias().length() + 1);
+                    }
+                    Configuration config = info.getConfiguration();
+                    int pos;
+                    do {
+                        pos = propName.indexOf('.');
+                        if ( pos != - 1 ) {
+                            config = this.getAndCreateConfiguration(config, propName.substring(0,
pos));
+                            propName = propName.substring(pos+1);
+                        }
+                    } while ( pos != -1 );
+                    if ( propName.startsWith("@") ) {
+                        ((DefaultConfiguration)config).setAttribute(propName.substring(1),
value);
+                    } else {
+                        config = this.getAndCreateConfiguration(config, propName);
+                        ((DefaultConfiguration)config).setValue(value);
+                    }
+                }
+             }
+        }
+    }
+
+    protected Configuration getAndCreateConfiguration(Configuration config, String name)
{
+        if ( config.getChild(name, false) == null ) {
+            final DefaultConfiguration newConfig = new DefaultConfiguration(name, config.getLocation());
+            ((DefaultConfiguration)config).addChild(newConfig);
+        }
+        return config.getChild(name, false);
+    }
     /**
      * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
java.lang.String)
      */

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java?view=diff&rev=453145&r1=453144&r2=453145
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
Thu Oct  5 01:36:50 2006
@@ -125,7 +125,7 @@
         this.registerComponentInfo(info, registry);
 
         // and finally add avalon bean post processor
-        final RootBeanDefinition beanDef = this.createBeanDefinition(AvalonBeanPostProcessor.class,
null, true);
+        final RootBeanDefinition beanDef = this.createBeanDefinition(AvalonBeanPostProcessor.class,
"init", true);
         beanDef.getPropertyValues().addPropertyValue("logger", new RuntimeBeanReference(ProcessingUtil.LOGGER_ROLE));
         beanDef.getPropertyValues().addPropertyValue("context", new RuntimeBeanReference(ProcessingUtil.CONTEXT_ROLE));
         beanDef.getPropertyValues().addPropertyValue("configurationInfo", new RuntimeBeanReference(ConfigurationInfo.class.getName()));

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonServiceManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonServiceManager.java?view=diff&rev=453145&r1=453144&r2=453145
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonServiceManager.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonServiceManager.java
Thu Oct  5 01:36:50 2006
@@ -18,6 +18,7 @@
 
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.configuration.Settings;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanFactoryAware;



Mime
View raw message