From 93e6af77990e3fb2fa7fb1e39f18b131f0e08c62 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 25 Sep 2002 17:31:28 +0000 Subject: [PATCH] overrided load() function to load properties into a fresh map, added add() function to load a file without discarding old entries. --- src/helma/util/SystemProperties.java | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/helma/util/SystemProperties.java b/src/helma/util/SystemProperties.java index fcbbb40d..075ca849 100644 --- a/src/helma/util/SystemProperties.java +++ b/src/helma/util/SystemProperties.java @@ -79,7 +79,7 @@ public final class SystemProperties extends Properties { */ public long lastModified () { if (file == null || !file.exists ()) - return 0; + return lastread; return file.lastModified (); } @@ -98,20 +98,40 @@ public final class SystemProperties extends Properties { */ private synchronized void readFile () { // IServer.getLogger().log ("Reading properties from file "+file); - newProps = defaultProps == null ? - new Properties () : new Properties (defaultProps); + FileInputStream bpin = null; try { - FileInputStream bpin = new FileInputStream (file); + bpin = new FileInputStream (file); load (bpin); - bpin.close (); } catch (Exception x) { System.err.println ("Error reading properties from file "+file+": "+x); + } finally { + try { + bpin.close (); + } catch (Exception ignore) {} } + } + + + public synchronized void load (InputStream in) throws IOException { + newProps = defaultProps == null ? + new Properties () : new Properties (defaultProps); + super.load (in); lastread = System.currentTimeMillis (); props = newProps; newProps = null; } + + /** + * Similar to load(), but adds to the existing properties instead + * of discarding them. + */ + public synchronized void add (InputStream in) throws IOException { + super.load (in); + lastread = System.currentTimeMillis (); + } + + /* * This should not be used directly if properties are read from file, * otherwise changes will be lost whe the file is next modified.