cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r452470 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring: AbstractSettingsBeanFactoryPostProcessor.java CocoonPropertyOverrideConfigurer.java SettingsElementParser.java SettingsProperties.java
Date Tue, 03 Oct 2006 12:56:59 GMT
Author: cziegeler
Date: Tue Oct  3 05:56:59 2006
New Revision: 452470

URL: http://svn.apache.org/viewvc?view=rev&rev=452470
Log:
Add support for spring property override configuration

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
  (with props)
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java?view=diff&rev=452470&r1=452469&r2=452470
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
Tue Oct  3 05:56:59 2006
@@ -250,30 +250,6 @@
         }
     }
 
-    protected static class SettingsProperties extends Properties {
-
-        protected final Settings settings;
-
-        public SettingsProperties(Settings s) {
-            this.settings = s;
-        }
-
-        /**
-         * @see java.util.Properties#getProperty(java.lang.String, java.lang.String)
-         */
-        public String getProperty(String key, String defaultValue) {
-            return this.settings.getProperty(key, defaultValue);
-        }
-
-        /**
-         * @see java.util.Properties#getProperty(java.lang.String)
-         */
-        public String getProperty(String key) {
-            return this.settings.getProperty(key);
-        }
-        
-    }
-
     /**
      * @see org.springframework.beans.factory.FactoryBean#getObject()
      */

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java?view=auto&rev=452470
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
Tue Oct  3 05:56:59 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.Settings;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
+
+/**
+ * Our version of the property override configurer which uses the settings
+ * object to get the properties.
+ * @version $Id$
+ */
+public class CocoonPropertyOverrideConfigurer extends PropertyOverrideConfigurer {
+
+    protected Settings settings;
+
+    public void setSettings(Settings object) {
+        this.settings = object;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.config.PropertyResourceConfigurer#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
+     */
+    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws
BeansException {
+        Properties mergedProps = new SettingsProperties(this.settings);
+
+        // Convert the merged properties, if necessary.
+        convertProperties(mergedProps);
+
+        // Let the subclass process the properties.
+        processProperties(beanFactory, mergedProps);
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonPropertyOverrideConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Id

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=452470&r1=452469&r2=452470
==============================================================================
--- 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
Tue Oct  3 05:56:59 2006
@@ -63,6 +63,10 @@
         // register settings bean
         this.register(beanDef, Settings.ROLE, parserContext.getRegistry());
 
+        // register a PropertyPlaceholderConfigurer
+        this.addComponent(CocoonPropertyOverrideConfigurer.class.getName(), CocoonPropertyOverrideConfigurer.class.getName(),
null, true, parserContext.getRegistry());
+
+        // add the servelt context as a bean
         this.addComponent(ServletContextFactoryBean.class.getName(), ServletContext.class.getName(),
null, false, parserContext.getRegistry());
         return null;
     }

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java?view=auto&rev=452470
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
Tue Oct  3 05:56:59 2006
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.Settings;
+
+/**
+ * A properties implementation using the settings object.
+ * @version $Id$
+ */
+public class SettingsProperties extends Properties {
+
+    protected final Settings settings;
+
+    public SettingsProperties(Settings s) {
+        this.settings = s;
+    }
+
+    /**
+     * @see java.util.Properties#getProperty(java.lang.String, java.lang.String)
+     */
+    public String getProperty(String key, String defaultValue) {
+        return this.settings.getProperty(key, defaultValue);
+    }
+
+    /**
+     * @see java.util.Properties#getProperty(java.lang.String)
+     */
+    public String getProperty(String key) {
+        return this.settings.getProperty(key);
+    }
+    
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsProperties.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message