You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ak...@apache.org on 2003/12/05 04:20:49 UTC
cvs commit: avalon/util/xdocs/defaults index.xml
akarasulu 2003/12/04 19:20:49
Modified: util/xdocs/defaults index.xml
Log:
example
Revision Changes Path
1.2 +65 -1 avalon/util/xdocs/defaults/index.xml
Index: index.xml
===================================================================
RCS file: /home/cvs/avalon/util/xdocs/defaults/index.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- index.xml 4 Dec 2003 21:01:32 -0000 1.1
+++ index.xml 5 Dec 2003 03:20:49 -0000 1.2
@@ -56,7 +56,71 @@
<body>
<section name="Defaults">
<subsection name="Overview">
- <p>IN PREPARATION</p>
+ <p>
+ A simple default property value discovery API that makes it very
+ easy to define a policy for searching for and merging property values.
+ </p>
+
+ <p>
+ The Defaults class is a Properties subclass that holds the default
+ property values discovered. It contains special methods to access
+ multi-valued properties using a property name based enumeration scheme.
+ Other nice features include a macro expansion facility and prepackaged
+ finders for locating defaults in other default property sources.
+ </p>
+
+ <p>
+ Below in order is an the environment listing, the contents of
+ a properties file, and the code used to discover and print out
+ the default values discovered. The last item is the output.
+ The defaults are searched for in the defaults.properties file,
+ the shell environment and the system properties:
+ </p>
+
+ <source>
+akarasulu@franklin ~
+$ env
+...
+MERLIN_HOME=f:/apache/avalon/merlin
+...
+ </source>
+
+ <source>
+# defaults.properties
+targets.0=./conf/webserver.xml
+targets.1=./conf/eve.xml
+targets.2=./conf/ftpserver.xml
+targets.3=${mailserver}
+...
+ </source>
+
+ <source>
+// Load defaults.properties
+Properties props = new Properties() ;
+props.load(new FileReader( "defaults.properties" ) ) ;
+props.setProperty( "mailserver", "./conf/james.xml" ) ;
+
+// Perpare to discover defaults of interest in sources
+DefaultFinders [] finders = {
+ new SystemDefaultsFinder(),
+ new SimpleDefaultsFinder( env ),
+ new SimpleDefaultsFinder( props )
+ };
+String singles = { MERLIN_HOME, mailserver } ;
+String enumerated = { targets } ;
+Defaults defaults = Defaults( singles, enumerated, finders ) ;
+
+// Access and print
+String home = defaults.getProperty( "MERLIN_HOME" ) ;
+System.out.println( "MERLIN_HOME = " + home ) ;
+String [] targets = defaults.getEnumerated( "targets" ) ;
+printout( targets ) ;
+ </source>
+
+ <source>
+MERLIN_HOME=f:/apache/avalon/merlin
+[ ./conf/webserver.xml, ./conf/eve.xml, ./conf/ftpserver.xml, ./conf/james.xml ]
+ </source>
</subsection>
</section>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org