CVS update: talon/src/java/talon/implementations

From: cvs@openprivacy.org
Date: Tue Jan 16 2001 - 08:06:30 PST


Date: Tuesday January 16, 19101 @ 8:06
Author: burton
CVSWEB Options: -------------------

Main CVSWeb: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi

View this module: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations

-----------------------------------

Update of /usr/local/cvsroot/talon/src/java/talon/implementations
In directory openprivacy.org:/tmp/cvs-serv18519/src/java/talon/implementations

Modified Files:
        PropertyFileManager.java
Added Files:
        SimpleLogger.java SimplePropertyManager.java
Log Message:
Impl of a basic Logger interface... stolen from Turbine/jEdit/Jetspeed

*****************************************************************
File: talon/src/java/talon/implementations/SimpleLogger.java

CVSWEB Options: -------------------

CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/SimpleLogger.java?annotate=1.1

CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/SimpleLogger.java?rev=1.1&content-type=text/x-cvsweb-markup

-----------------------------------

*****************************************************************
File: talon/src/java/talon/implementations/SimplePropertyManager.java

CVSWEB Options: -------------------

CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/SimplePropertyManager.java?annotate=1.1

CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/SimplePropertyManager.java?rev=1.1&content-type=text/x-cvsweb-markup

-----------------------------------

*****************************************************************
File: talon/src/java/talon/implementations/PropertyFileManager.java

CVSWEB Options: -------------------

CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/PropertyFileManager.java?annotate=1.2

CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/PropertyFileManager.java?rev=1.2&content-type=text/x-cvsweb-markup

CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/implementations/PropertyFileManager.java.diff?r1=1.2&r2=1.1

-----------------------------------

Index: talon/src/java/talon/implementations/PropertyFileManager.java
diff -u talon/src/java/talon/implementations/PropertyFileManager.java:1.1 talon/src/java/talon/implementations/PropertyFileManager.java:1.2
--- talon/src/java/talon/implementations/PropertyFileManager.java:1.1 Tue Jan 16 02:42:33 2001
+++ talon/src/java/talon/implementations/PropertyFileManager.java Tue Jan 16 08:06:30 2001
@@ -14,9 +14,13 @@
 import java.util.*;
 
 import talon.*;
+import talon.interfaces.*;
+import talon.util.*;
 
+
 /**
  * Used when working with property files.
+ *
  * <p>
  * This object depends on the following initialization properties:
  *
@@ -28,30 +32,25 @@
  * Singleton
  *
  * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
+ * @version $Id: PropertyFileManager.java,v 1.2 2001/01/16 16:06:30 burton Exp $
  */
-public class PropertyFileManager extends BaseComponent implements Component {
-
-
- /**
- * Places on disk to look for a project .properties file. This array is
- * searched from the begin until the end so that a [PROJECT].properties file
- * can be searched by priority. First the users personal
- * [PROJECT].properties, then the specific JVM's version, then the System's
- * version.
- */
+public class PropertyFileManager extends BasePropertyManager {
 
- private Properties props = new Properties();
 
+ public static final String INIT_PROPERTY_PROJECT = "project";
+
     /**
- Perform any necessary initialization
-
- @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
+ * Perform any necessary initialization
+ *
+ * @see Component
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: PropertyFileManager.java,v 1.2 2001/01/16 16:06:30 burton Exp $
      */
     public void init() throws TalonException {
+
 
- String project = this.getComponentHandle().getInitParameter( "project", true );
+ //FIXME: this needs to throw an Exception if it is not there...
+ String project = this.getComponentHandle().getInitProperties().getProperty( INIT_PROPERTY_PROJECT );
 
         String[] locations = getFileLocations( project );
         
@@ -74,9 +73,11 @@
         
         try {
 
- this.props = new Properties();
- this.props.load( new FileInputStream( file ) );
+ Properties props = new Properties();
+ props.load( new FileInputStream( file ) );
 
+ this.setProperties( props );
+
         } catch ( Exception e ) {
             e.printStackTrace();
         }
@@ -84,74 +85,24 @@
     }
 
     /**
- * Get a given property from parsed props.
+ * Given a project name, determine where its files might be stored.
      *
      * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
+ * @version $Id: PropertyFileManager.java,v 1.2 2001/01/16 16:06:30 burton Exp $
      */
- public String getProperty( String name ) {
-
- return this.props.getProperty( name );
-
- }
-
- /**
- * Get a property but assume it is a boolean
- *
- * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
- */
- public boolean getBoolean( String name ) {
- String value = getProperty( name );
+ private String[] getFileLocations( String project ) {
 
- //if it is null assume false.
- if ( value == null ) {
- return false;
- }
-
- return value.equalsIgnoreCase( "true" );
         
- }
-
- /**
- * Get a property but assume it is multivalued.
- *
- * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
- */
- public Vector getVector( String name ) {
-
         Vector v = new Vector();
-
- int i = 0;
- while( true ) {
-
- String prop = getProperty( name + "." + i );
-
- //terminate the while loop if we have no more variables.
- if ( prop == null) {
- break;
- }
-
- //Logger.debug( "Found vector prop: " + prop + " for name: " + name );
- v.addElement( prop );
-
- ++i;
- }
 
- return v;
- }
+ //if there is a System Property defined named PROJECT_PROPERTIES... use that
 
- /**
- * Given a project name, determine where its files might be stored.
- *
- * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: PropertyFileManager.java,v 1.1 2001/01/16 10:42:33 burton Exp $
- */
- private String[] getFileLocations( String project ) {
-
+ String prop = project.toUpperCase() + "_PROPERTIES";
+ String value = System.getProperty( prop );
         
- Vector v = new Vector();
+ if ( value != null ) {
+ v.addElement( value );
+ }
         
         v.addElement( System.getProperty( "user.home" ) +
                       File.separator +
@@ -174,5 +125,6 @@
         return s;
         
     }
+
     
 }



This archive was generated by hypermail 2b30 : Mon Jan 22 2001 - 15:52:15 PST