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 2005/09/06 20:48:42 UTC

svn commit: r279062 - in /cocoon: blocks/hsqldb/trunk/WEB-INF/properties/ blocks/hsqldb/trunk/conf/ trunk/src/java/org/apache/cocoon/core/ trunk/src/java/org/apache/cocoon/generation/

Author: cziegeler
Date: Tue Sep  6 11:48:21 2005
New Revision: 279062

URL: http://svn.apache.org/viewcvs?rev=279062&view=rev
Log:
Start using per block properties
Add simple interface for own property definitions

Added:
    cocoon/blocks/hsqldb/trunk/WEB-INF/properties/
    cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties   (with props)
    cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java   (with props)
Removed:
    cocoon/blocks/hsqldb/trunk/conf/hsql.driver.xweb
Modified:
    cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java
    cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
    cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java
    cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java

Added: cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties
URL: http://svn.apache.org/viewcvs/cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties?rev=279062&view=auto
==============================================================================
--- cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties (added)
+++ cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties Tue Sep  6 11:48:21 2005
@@ -0,0 +1,14 @@
+# 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.
+org.apache.cocoon.classloader.load.classes=org.hsqldb.jdbcDriver

Propchange: cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/hsqldb/trunk/WEB-INF/properties/cocoon-hsqldb.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java?rev=279062&r1=279061&r2=279062&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java Tue Sep  6 11:48:21 2005
@@ -163,6 +163,11 @@
     String KEY_LOGGING_OVERRIDE_LOGLEVEL = "override.loglevel";
 
     /**
+     * This key allows to add own {@link PropertyProvider}s.
+     */
+    String KEY_PROPERTY_PROVIDER = "property.provider";
+
+    /**
      * @return Returns the configuration.
      * @see #KEY_CONFIGURATION
      */
@@ -268,4 +273,10 @@
      * The creation time of the current Cocoon instance.
      */
     long getCreationTime();
+
+    /**
+     * @return All property providers.
+     * @see #KEY_PROPERTY_PROVIDER
+     */
+    List getPropertyProviders();
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java?rev=279062&r1=279061&r2=279062&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java Tue Sep  6 11:48:21 2005
@@ -391,6 +391,18 @@
             resolver.release(directory);
         }
 
+        // Next look for custom property providers
+        Iterator i = s.getPropertyProviders().iterator();
+        while ( i.hasNext() ) {
+            final String className = (String)i.next();
+            try {
+                PropertyProvider provider = (PropertyProvider)ClassUtils.newInstance(className);
+                s.fill(provider.getProperties());
+            } catch (Exception ignore) {
+                env.log("Unable to get property provider for class " + className, ignore);
+                env.log("Continuing initialization.");            
+            }
+        }
         // fill from the environment configuration, like web.xml etc.
         env.configure(s);
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java?rev=279062&r1=279061&r2=279062&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java Tue Sep  6 11:48:21 2005
@@ -225,6 +225,9 @@
     /** The time the cocoon instance was created. */
     protected long creationTime;
 
+    /** The property providers. */
+    protected List propertyProviders = new ArrayList();
+
     /**
      * Create a new settings object
      */
@@ -298,6 +301,8 @@
                         this.addToLoadClasses(value);
                     } else if ( key.startsWith(KEY_EXTRA_CLASSPATHS) ) {
                         this.addToExtraClasspaths(value);
+                    } else if ( key.startsWith(KEY_PROPERTY_PROVIDER) ) {
+                        this.addToPropertyProviders(value);
                     } else if ( key.startsWith(KEY_FORCE_PROPERTIES) ) {
                         key = key.substring(KEY_FORCE_PROPERTIES.length() + 1);
                         this.addToForceProperties(key, value);
@@ -582,6 +587,8 @@
                 this.toString(this.extraClasspaths);
             } else if ( key.equals(KEY_FORCE_PROPERTIES) ) {
                 this.toString(this.forceProperties);
+            } else if ( key.equals(KEY_PROPERTY_PROVIDER) ) {
+                this.toString(this.propertyProviders);
             }
         }
 
@@ -923,5 +930,20 @@
         // Don't check read only here as this will change if Cocoon
         // is reloaded while the settings remain the same.
         this.creationTime = value;
+    }
+
+    /**
+     * @see org.apache.cocoon.core.BaseSettings#getPropertyProviders()
+     */
+    public List getPropertyProviders() {
+        return this.propertyProviders;
+    }
+
+    /**
+     * Add a property provider.
+     */
+    public void addToPropertyProviders(String className) {
+        this.checkWriteable();
+        this.propertyProviders.add(className);
     }
 }

Added: cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java?rev=279062&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java Tue Sep  6 11:48:21 2005
@@ -0,0 +1,30 @@
+/*
+ * 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.core;
+
+import java.util.Properties;
+
+/**
+ * This is an interface for custom components delivering properties to
+ * configure Cocoon.
+ *
+ * @version $Id$
+ */
+public interface PropertyProvider {
+
+    Properties getProperties();
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/core/PropertyProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java?rev=279062&r1=279061&r2=279062&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java Tue Sep  6 11:48:21 2005
@@ -431,6 +431,7 @@
         this.addMultilineValue(Settings.KEY_EXTRA_CLASSPATHS, s.getExtraClasspaths());
         this.addMultilineValue(Settings.KEY_LOAD_CLASSES, s.getLoadClasses());
         this.addValue(Settings.KEY_FORCE_PROPERTIES, s.getForceProperties());
+        this.addValue(Settings.KEY_PROPERTY_PROVIDER, s.getPropertyProviders());
         this.addValue(Settings.KEY_LOGGING_CONFIGURATION, s.getLoggingConfiguration());
         this.addValue(Settings.KEY_LOGGING_BOOTSTRAP_LOGLEVEL, s.getBootstrapLogLevel());
         this.addValue(Settings.KEY_LOGGING_MANAGER_CLASS, s.getLoggerManagerClassName());