[Jukebox-cvs] CVS update: J4/src/java/gnu/j4/config Configuration.java
Brought to you by:
vtt
From: CVS B. <vt...@fr...> - 2000-05-13 00:20:34
|
User: vt Date: 00/05/12 17:20:31 Modified: src/java/gnu/j4/config Configuration.java Log: Fixed (or, should I say, closed) bug #102384 Revision Changes Path 1.26 +44 -8 J4/src/java/gnu/j4/config/Configuration.java CVSWEB Options: ------------------- CVSWeb: Annotate this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java?annotate=1.26&cvsroot=jukebox4 CVSWeb: View this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java?rev=1.26&content-type=text/x-cvsweb-markup&cvsroot=jukebox4 CVSWeb: Diff to previous version: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java.diff?r1=1.26&r2=1.25&cvsroot=jukebox4 ----------------------------------- Index: Configuration.java =================================================================== RCS file: /usr/local/cvs/J4/src/java/gnu/j4/config/Configuration.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- Configuration.java 2000/05/12 22:44:32 1.25 +++ Configuration.java 2000/05/13 00:20:31 1.26 @@ -4,19 +4,28 @@ import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; +import java.util.StringTokenizer; import java.util.Vector; /** * This object holds the configuration in a way similar to - * <code>Hashtable</code>, but provides a convenient way to load it. + * <code>Hashtable</code>, but provides a convenient way to load and extract + * it. + * + * <p> + * + * The basic concept is a {@link #createChain configuration chain}: first, + * the system-wide configuration is read, then the user defaults are read, + * then the application configuration, and then the configuration settings + * from the current directory. * - * @author Copyright © <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1998 + * @author Copyright © <a href="mailto:vt...@fr...">Vadim Tkachenko</a> 1998-2000 * * @author Significant influence from <a href="http://java.apache.org/" * target=_top>Java-Apache Project</a> in general and code written by <a * href="mailto:st...@ap...">Stefano Mazzocchi</a> in particular. * - * @version $Id: Configuration.java,v 1.25 2000/05/12 22:44:32 vt Exp $ + * @version $Id: Configuration.java,v 1.26 2000/05/13 00:20:31 vt Exp $ */ public class Configuration extends Hashtable { @@ -31,6 +40,10 @@ /** * Default configuration, if any. * + * If the value for the requested configuration keyword is not found, + * the result is sought from the default configuration. Note that + * multiple levels of default configurations are available. + * * @serial Default configuration, if any. */ protected Configuration defaultCfg = null; @@ -54,6 +67,7 @@ * Create a configuration chain from the file with a given name. * * @param confName Base name of the file to read the configuration from. + * * @return Configuration chain. */ public static Configuration createChain(String confName) { @@ -65,18 +79,24 @@ * configuration. * * <p> - + * * Configuration file with the given name is created with defaults read * as follows: - + * * <ol> * * <li><code>${prefix}/etc/`basename <confName>`</code> (see * {@link gnu.j4.LocalConfig LocalConfig} for exact prefix). * + * <li><code>${jukebox.confpath}/`basename <confName>`</code>, + * where <code>jukebox.confpath</code> is the environment property + * (<strong>not variable!</strong>). Multiple values can be present + * here, divided by the platform dependent path separator + * (<code>File.pathSeparatorChar</code>). + * * <li><code>$HOME/.jukebox/`basename <confName>`</code> * - * <li><code>./etc/`basename <confName>`</code> (if the name is relative) + * <li><code>./.`basename <confName>`</code> (if the name is relative) * * <br><code><confName></code> (if the name is absolute) * @@ -99,15 +119,31 @@ + File.separatorChar + "etc", base.toString())); + + // Read ${jukebox.confpath}/ ... second + + String confPath = System.getProperty("jukebox.confpath"); + + StringTokenizer st = new StringTokenizer(confPath, File.pathSeparator); - // Read $HOME/.jukebox/... second + while ( st.hasMoreTokens() ) { + + String item = st.nextToken(); + + File confFile = new File(item, base.toString()); + + path.addElement(confFile); + } + + + // Read $HOME/.jukebox/... third File home = new File(System.getProperty("user.home"), "."+jukebox); path.addElement(new File(home, base.toString())); // If the configuration name is absolute, use it as is, otherwise - // prepend "./etc/" and make it absolute. + // prepend "." and make it absolute. if ( !target.isAbsolute() ) { target = new File(System.getProperty("user.dir"), "." + base.toString()); |