You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2006/07/21 22:44:31 UTC
svn commit: r424452 - in /jakarta/turbine/fulcrum/trunk/configuration/impl:
src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java
src/test/TestComponentConfig.xml xdocs/index.xml
Author: tv
Date: Fri Jul 21 13:44:31 2006
New Revision: 424452
URL: http://svn.apache.org/viewvc?rev=424452&view=rev
Log:
ConfigurationService Improvements
- more flexible configuration built in
- added support for simple configuration settings
- enhanced documentation
- fixed JavaDocs
Modified:
jakarta/turbine/fulcrum/trunk/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java
jakarta/turbine/fulcrum/trunk/configuration/impl/src/test/TestComponentConfig.xml
jakarta/turbine/fulcrum/trunk/configuration/impl/xdocs/index.xml
Modified: jakarta/turbine/fulcrum/trunk/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java?rev=424452&r1=424451&r2=424452&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java (original)
+++ jakarta/turbine/fulcrum/trunk/configuration/impl/src/java/org/apache/fulcrum/configuration/DefaultConfigurationService.java Fri Jul 21 13:44:31 2006
@@ -1,19 +1,20 @@
package org.apache.fulcrum.configuration;
/*
* Copyright 2001-2004 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.
- */
+ */
+
import java.io.File;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -21,6 +22,9 @@
import java.util.List;
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -29,460 +33,592 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.ConfigurationFactory;
+import org.apache.commons.configuration.JNDIConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
/**
* Starts up a commons configuration Configuration object via an
* Avalon container.
*
+ *
+ * The component configuration is carved after the
+ * <a href="http://jakarta.apache.org/commons/configuration/howto_configurationfactory.html">CompositeConfiguraton</a>
+ * from Commons Configuration and allows similar expressions. The implementation understands the
+ * following types of configurations:<br>
+ * <pre>
+ *
+ * <ConfigurationService>
+ * <system/>
+ * <jndi prefix="java:comp/env"/>
+ * <properties fileName="test.properties" optional="true"/>
+ * <xml fileName="test.xml" optional="true"/>
+ * </ConfigurationService>
+ *
+ * </pre>
+ * All other XML elements are considered to be keys of a configuration and their contents is
+ * treated as string value.
+ *
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
* @avalon.component name="config" lifestyle="singleton"
* @avalon.service type="org.apache.commons.configuration.Configuration"
* @avalon.attribute key="urn:composition:deployment.timeout" value="0"
+ *
*/
public class DefaultConfigurationService
extends AbstractLogEnabled
implements org.apache.commons.configuration.Configuration, Configurable, Contextualizable, ThreadSafe
{
/**
- * The property specifying the location where to read in the configuration
- * path from.
- */
+ * The property specifying the location where to read in the configuration
+ * path from.
+ */
String CONFIGURATION_PATH = "configurationPath";
private String applicationRoot;
- private org.apache.commons.configuration.Configuration configuration;
+ private CompositeConfiguration configuration;
/**
- * @see org.apache.commons.configuration.Configuration
- */
+ * @see org.apache.commons.configuration.Configuration#addProperty(java.lang.String, java.lang.Object)
+ */
public void addProperty(String arg0, Object arg1)
{
configuration.addProperty(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- */
+ * @see org.apache.commons.configuration.Configuration#clearProperty(java.lang.String)
+ */
public void clearProperty(String arg0)
{
configuration.clearProperty(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#containsKey(java.lang.String)
+ */
public boolean containsKey(String arg0)
{
return configuration.containsKey(arg0);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
public boolean equals(Object obj)
{
return configuration.equals(obj);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getBoolean(java.lang.String)
+ */
public boolean getBoolean(String arg0)
{
return configuration.getBoolean(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getBoolean(java.lang.String, boolean)
+ */
public boolean getBoolean(String arg0, boolean arg1)
{
return configuration.getBoolean(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getBoolean(java.lang.String, java.lang.Boolean)
+ */
public Boolean getBoolean(String arg0, Boolean arg1)
{
return configuration.getBoolean(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getByte(java.lang.String)
+ */
public byte getByte(String arg0)
{
return configuration.getByte(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getByte(java.lang.String, byte)
+ */
public byte getByte(String arg0, byte arg1)
{
return configuration.getByte(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getByte(java.lang.String, java.lang.Byte)
+ */
public Byte getByte(String arg0, Byte arg1)
{
return configuration.getByte(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getDouble(java.lang.String)
+ */
public double getDouble(String arg0)
{
return configuration.getDouble(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getDouble(java.lang.String, double)
+ */
public double getDouble(String arg0, double arg1)
{
return configuration.getDouble(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getDouble(java.lang.String, java.lang.Double)
+ */
public Double getDouble(String arg0, Double arg1)
{
return configuration.getDouble(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getFloat(java.lang.String)
+ */
public float getFloat(String arg0)
{
return configuration.getFloat(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getFloat(java.lang.String, float)
+ */
public float getFloat(String arg0, float arg1)
{
return configuration.getFloat(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getFloat(java.lang.String, java.lang.Float)
+ */
public Float getFloat(String arg0, Float arg1)
{
return configuration.getFloat(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getInt(java.lang.String)
+ */
public int getInt(String arg0)
{
return configuration.getInt(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getInt(java.lang.String, int)
+ */
public int getInt(String arg0, int arg1)
{
return configuration.getInt(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getInteger(java.lang.String, java.lang.Integer)
+ */
public Integer getInteger(String arg0, Integer arg1)
{
return configuration.getInteger(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getKeys()
+ */
public Iterator getKeys()
{
return configuration.getKeys();
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getKeys(java.lang.String)
+ */
public Iterator getKeys(String arg0)
{
return configuration.getKeys(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getLong(java.lang.String)
+ */
public long getLong(String arg0)
{
return configuration.getLong(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getLong(java.lang.String, java.lang.Long)
+ */
public Long getLong(String arg0, Long arg1)
{
return configuration.getLong(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getLong(java.lang.String, long)
+ */
public long getLong(String arg0, long arg1)
{
return configuration.getLong(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getProperties(java.lang.String)
+ */
public Properties getProperties(String arg0)
{
return configuration.getProperties(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getProperty(java.lang.String)
+ */
public Object getProperty(String arg0)
{
return configuration.getProperty(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getShort(java.lang.String)
+ */
public short getShort(String arg0)
{
return configuration.getShort(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getShort(java.lang.String, java.lang.Short)
+ */
public Short getShort(String arg0, Short arg1)
{
return configuration.getShort(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getShort(java.lang.String, short)
+ */
public short getShort(String arg0, short arg1)
{
return configuration.getShort(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getString(java.lang.String)
+ */
public String getString(String arg0)
{
return configuration.getString(arg0);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getString(java.lang.String, java.lang.String)
+ */
public String getString(String arg0, String arg1)
{
return configuration.getString(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#getStringArray(java.lang.String)
+ */
public String[] getStringArray(String arg0)
{
return configuration.getStringArray(arg0);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
+ /**
+ * @see java.lang.Object#hashCode()
+ */
public int hashCode()
{
return configuration.hashCode();
}
/**
- * @see org.apache.commons.configuration.Configuration
- * @return
- */
+ * @see org.apache.commons.configuration.Configuration#isEmpty()
+ */
public boolean isEmpty()
{
return configuration.isEmpty();
}
/**
- * @see org.apache.commons.configuration.Configuration
- */
+ * @see org.apache.commons.configuration.Configuration#setProperty(java.lang.String, java.lang.Object)
+ */
public void setProperty(String arg0, Object arg1)
{
configuration.setProperty(arg0, arg1);
}
/**
- * @see org.apache.commons.configuration.Configuration
- */
+ * @see org.apache.commons.configuration.Configuration#subset(java.lang.String)
+ */
public org.apache.commons.configuration.Configuration subset(String arg0)
{
return configuration.subset(arg0);
}
/**
- * @param arg0
- * @return
+ * @see org.apache.commons.configuration.Configuration#getBigDecimal(java.lang.String)
*/
- public BigDecimal getBigDecimal(String arg0) {
+ public BigDecimal getBigDecimal(String arg0)
+ {
return configuration.getBigDecimal(arg0);
}
+
/**
- * @param arg0
- * @param arg1
- * @return
+ * @see org.apache.commons.configuration.Configuration#getBigDecimal(java.lang.String, java.math.BigDecimal)
*/
- public BigDecimal getBigDecimal(String arg0, BigDecimal arg1) {
+ public BigDecimal getBigDecimal(String arg0, BigDecimal arg1)
+ {
return configuration.getBigDecimal(arg0, arg1);
}
+
/**
- * @param arg0
- * @return
+ * @see org.apache.commons.configuration.Configuration#getBigInteger(java.lang.String)
*/
- public BigInteger getBigInteger(String arg0) {
+ public BigInteger getBigInteger(String arg0)
+ {
return configuration.getBigInteger(arg0);
}
+
/**
- * @param arg0
- * @param arg1
- * @return
+ * @see org.apache.commons.configuration.Configuration#getBigInteger(java.lang.String, java.math.BigInteger)
*/
- public BigInteger getBigInteger(String arg0, BigInteger arg1) {
+ public BigInteger getBigInteger(String arg0, BigInteger arg1)
+ {
return configuration.getBigInteger(arg0, arg1);
}
+
/**
- * @param arg0
- * @return
+ * @see org.apache.commons.configuration.Configuration#getList(java.lang.String)
*/
- public List getList(String arg0) {
+ public List getList(String arg0)
+ {
return configuration.getList(arg0);
}
+
/**
- * @param arg0
- * @param arg1
- * @return
+ * @see org.apache.commons.configuration.Configuration#getList(java.lang.String, java.util.List)
*/
- public List getList(String arg0, List arg1) {
+ public List getList(String arg0, List arg1)
+ {
return configuration.getList(arg0, arg1);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
+
+ /**
+ * @see java.lang.Object#toString()
+ */
public String toString()
{
return configuration.toString();
}
/**
+ * @see org.apache.commons.configuration.Configuration#clear()
+ */
+ public void clear()
+ {
+ configuration.clear();
+ }
+
+ /**
* Avalon component lifecycle method
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration conf) throws ConfigurationException
{
- String confPath = conf.getAttribute(CONFIGURATION_PATH);
- /*
- File confFile = new File(confPath);
- if(!confFile.exists()){
- confFile = new File(applicationRoot,confPath);
- }
- */
- //System.out.println( "PATH: " + confPath );
- //System.out.println( "HOME: " + applicationRoot );
- File file = new File( applicationRoot, confPath );
- //System.out.println( "REAL: " + file.getAbsolutePath());
+ configuration = new CompositeConfiguration();
+ // for backward compatibility
+ String confPath = conf.getAttribute(CONFIGURATION_PATH, null);
- if(!file.exists()){
- throw new ConfigurationException("XML file for ConfigurationFactory can not be found:" +file.getAbsolutePath());
- }
+ Configuration cfgs[] = conf.getChildren();
- ConfigurationFactory configurationFactory =
- new ConfigurationFactory(file.getAbsolutePath());
- configurationFactory.setBasePath(applicationRoot);
- try
+ if ((cfgs == null || cfgs.length == 0) && (confPath == null || confPath.length() == 0))
{
- configuration = configurationFactory.getConfiguration();
+ throw new ConfigurationException("Configuration should not be empty", conf);
}
- catch (Exception e)
+
+ if (confPath != null && confPath.length() > 0)
{
- throw new ConfigurationException(
- "Problem loading Configuration with Factory.",
- e);
+ File file = new File( applicationRoot, confPath );
+
+ if(!file.exists())
+ {
+ throw new ConfigurationException("XML file for ConfigurationFactory can not be found:" +file.getAbsolutePath());
+ }
+
+ ConfigurationFactory configurationFactory =
+ new ConfigurationFactory(file.getAbsolutePath());
+ configurationFactory.setBasePath(applicationRoot);
+ try
+ {
+ configuration.addConfiguration(configurationFactory.getConfiguration());
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException(
+ "Problem loading Configuration with Factory.",
+ e);
+ }
}
+
+ for (int i=0; i<cfgs.length; i++)
+ {
+ Configuration c = cfgs[i];
+ String name = c.getName();
+ if (name.equals("jndi"))
+ {
+ String jndi_context = c.getAttribute("prefix", null);
+
+ if (jndi_context == null || jndi_context.length() == 0)
+ {
+ throw new ConfigurationException("JNDI Configuration should have a prefix", c);
+ }
+
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ JNDIConfiguration jndi = new JNDIConfiguration(ctx, jndi_context);
+ configuration.addConfiguration(jndi);
+ }
+ catch (NamingException e)
+ {
+ throw new ConfigurationException("Could not create JNDI context", c, e);
+ }
+ }
+ else if (name.equals("properties"))
+ {
+ String fileName = c.getAttribute("fileName", null);
+ boolean optional = c.getAttributeAsBoolean("optional", false);
+
+ if (fileName == null || fileName.length() == 0)
+ {
+ throw new ConfigurationException("Property Configuration should have a file name", c);
+ }
+
+ File confFile = new File(fileName);
+ if(!confFile.exists())
+ {
+ confFile = new File(applicationRoot, fileName);
+ }
+
+ if (!confFile.exists() && !optional)
+ {
+ throw new ConfigurationException("Property Configuration file " + fileName + " does not exist", c);
+ }
+
+ if (confFile.exists())
+ {
+ try
+ {
+ PropertiesConfiguration prop = new PropertiesConfiguration(confFile);
+ configuration.addConfiguration(prop);
+ }
+ catch (org.apache.commons.configuration.ConfigurationException e)
+ {
+ throw new ConfigurationException("Property Configuration could not be created", c, e);
+ }
+ }
+ }
+ else if (name.equals("xml"))
+ {
+ String fileName = c.getAttribute("fileName", null);
+ boolean optional = c.getAttributeAsBoolean("optional", false);
+
+ if (fileName == null || fileName.length() == 0)
+ {
+ throw new ConfigurationException("XML Configuration should have a file name", c);
+ }
+
+ File confFile = new File(fileName);
+ if(!confFile.exists())
+ {
+ confFile = new File(applicationRoot, fileName);
+ }
+
+ if (!confFile.exists() && !optional)
+ {
+ throw new ConfigurationException("XML Configuration file " + fileName + " does not exist", c);
+ }
+
+ if (confFile.exists())
+ {
+ try
+ {
+ XMLConfiguration xml = new XMLConfiguration(confFile);
+ configuration.addConfiguration(xml);
+ }
+ catch (org.apache.commons.configuration.ConfigurationException e)
+ {
+ throw new ConfigurationException("XML Configuration could not be created", c, e);
+ }
+ }
+ }
+ else if (name.equals("system"))
+ {
+ SystemConfiguration system = new SystemConfiguration();
+ configuration.addConfiguration(system);
+ }
+ else
+ {
+ String value = c.getValue();
+
+ if (value != null)
+ {
+ configuration.addProperty(name, value);
+ }
+ else
+ {
+ throw new ConfigurationException("Invalid configuration key: " + name, c);
+ }
+ }
+ }
}
/**
- * @see org.apache.avalon.framework.context.Contextualizable
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
* @avalon.entry key="urn:avalon:home" type="java.io.File"
*/
public void contextualize(Context context) throws ContextException
{
- this.applicationRoot = context.get( "urn:avalon:home" ).toString();
- }
+ try
+ {
+ // first try Merlin and Yaafi context entries
+ applicationRoot = ((File)context.get("urn:avalon:home")).getAbsolutePath();
+ }
+ catch (ContextException e)
+ {
+ // Context entry not found
+ applicationRoot = null;
+ }
- public void clear() {
- configuration.clear();
-
+ if (applicationRoot == null || applicationRoot.length() == 0)
+ {
+ // try ECM, let exception throw on failure
+ applicationRoot = (String)context.get("componentAppRoot");
+ }
+
+ if (applicationRoot == null || applicationRoot.length() == 0)
+ {
+ throw new ContextException("Invalid Application Root");
+ }
}
-
}
Modified: jakarta/turbine/fulcrum/trunk/configuration/impl/src/test/TestComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/configuration/impl/src/test/TestComponentConfig.xml?rev=424452&r1=424451&r2=424452&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/configuration/impl/src/test/TestComponentConfig.xml (original)
+++ jakarta/turbine/fulcrum/trunk/configuration/impl/src/test/TestComponentConfig.xml Fri Jul 21 13:44:31 2006
@@ -1,3 +1,7 @@
<componentConfig>
- <config configurationPath="src/test/configuration.xml"/>
+ <config>
+ <properties fileName="src/test/org/test.properties"/>
+ <xml fileName="src/test/org/test.xml" optional="true"/>
+ <key>value</key>
+ </config>
</componentConfig>
Modified: jakarta/turbine/fulcrum/trunk/configuration/impl/xdocs/index.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/configuration/impl/xdocs/index.xml?rev=424452&r1=424451&r2=424452&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/configuration/impl/xdocs/index.xml (original)
+++ jakarta/turbine/fulcrum/trunk/configuration/impl/xdocs/index.xml Fri Jul 21 13:44:31 2006
@@ -19,11 +19,11 @@
API.
</p>
<p>
- It is written for use in any container compatible
- with Avalon's ECM container.
- </p>
+ It is written for use in any container compatible
+ with Avalon's Merlin or ECM container.
+ </p>
</section>
-
+
<section name="Configuration">
<p>
@@ -32,26 +32,78 @@
<source>
<![CDATA[
- <role
- name="org.apache.fulcrum.configuration.Config"
- shorthand="config"
- default-class="org.apache.fulcrum.configuration.DefaultConfigurationService"/>
+ <role
+ name="org.apache.commons.configuration.Configuration"
+ shorthand="config"
+ default-class="org.apache.fulcrum.configuration.DefaultConfigurationService"/>
]]>
</source>
<p>
- Now comes the basic configuration of the component. Here will will
- configure the various encryption providers
+ Now comes the basic configuration of the component. Here we will
+ configure the various configuration sources.
</p>
<source>
<![CDATA[
- <config configurationPath="src/test/configuration.xml"/>
+ <config>
+ <properties fileName="src/test/org/test.properties"/>
+ <xml fileName="src/test/org/test.xml" optional="true"/>
+ <key>value</key>
+ </config>
]]>
</source>
+ <p>
+ The component supports the following sources of configuration which can be
+ used as a list in arbitrary sequence. The order in that list is important. See
+ <a href="http://jakarta.apache.org/commons/configuration/">the Commons Configuration Site</a>
+ for details on the configuration sources.
+ </p>
+ <table>
+ <tr>
+ <th>Name</th>
+ <th>Attributes</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>properties</td>
+ <td><code>fileName="/path/to/file.properties"</code> (req.)<br />
+ <code>optional="true"</code> (opt.)
+ </td>
+ <td>Load config from a Java Properties file. If optional is set to true,
+ do not complain if the file is missing.</td>
+ </tr>
+ <tr>
+ <td>xml</td>
+ <td><code>fileName="/path/to/file.xml"</code> (req.)<br />
+ <code>optional="true"</code> (opt.)
+ </td>
+ <td>Load config from a XML file. If optional is set to true,
+ do not complain if the file is missing.</td>
+ </tr>
+ <tr>
+ <td>jndi</td>
+ <td><code>prefix="java:comp/env"</code> (req.)</td>
+ <td>Load config from a JNDI context.</td>
+ </tr>
+ <tr>
+ <td>system</td>
+ <td>none</td>
+ <td>Load config from the System Properties</td>
+ </tr>
+ <tr>
+ <td>everything else</td>
+ <td>none</td>
+ <td>Add contents of this tag as a property to the configuration.</td>
+ </tr>
+ </table>
+ <p>
+ The old syntax with the attribute <code>configurationPath="somepath"</code>
+ still works for reasons of backward compatibility.
+ </p>
</section>
-
+
<section name="Usage">
<p>
@@ -60,7 +112,7 @@
</p>
<p>
-To see an example, look at the test case
+To see an example, look at the test case
<a href="xref-test/org/apache/fulcrum/configuration/ConfigTest.html">ConfigTest</a>.
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org