From d5e6cfe6237144e7b2206a26c3b7b4cb89e3088e Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 29 Oct 2002 17:30:14 +0000 Subject: [PATCH] Implemented methods to obtain a checksum that signals changes in the object. These checksums are included in Message Digests so that they change when something in the Application changes. --- src/helma/framework/core/Application.java | 11 ++++++++++- src/helma/util/SystemProperties.java | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 31594495..1987121c 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -163,7 +163,7 @@ public final class Application implements IPathElement, Runnable { dbDir = customDbDir; // system-wide properties, default to null - Properties sysProps, sysDbProps; + SystemProperties sysProps, sysDbProps; sysProps = sysDbProps = null; home = null; @@ -1251,6 +1251,15 @@ public final class Application implements IPathElement, Runnable { } + /** + * Get a checksum that mirrors the state of this application in the sense + * that if anything in the applciation changes, the checksum hopefully will + * change, too. + */ + public long getChecksum () { + return starttime + typemgr.getChecksum() + props.getChecksum(); + } + /** * Proxy method to get a property from the applications properties. */ diff --git a/src/helma/util/SystemProperties.java b/src/helma/util/SystemProperties.java index c129cee2..041c3922 100644 --- a/src/helma/util/SystemProperties.java +++ b/src/helma/util/SystemProperties.java @@ -15,7 +15,7 @@ public final class SystemProperties extends Properties { private Properties props; // wrapped properties private Properties newProps; // used while building up props - private Properties defaultProps; // the default/fallback properties. + private SystemProperties defaultProps; // the default/fallback properties. private File file; // the underlying properties file from which we read. private long lastread, lastcheck, lastadd; // time we last read/checked the underlying properties file @@ -59,7 +59,7 @@ public final class SystemProperties extends Properties { /** * Contstruct a properties object with the given default properties. */ - public SystemProperties (Properties defaultProps) { + public SystemProperties (SystemProperties defaultProps) { this (null, defaultProps); } @@ -67,7 +67,7 @@ public final class SystemProperties extends Properties { /** * Construct a properties object from a file name with the given default properties */ - public SystemProperties (String filename, Properties defaultProps) { + public SystemProperties (String filename, SystemProperties defaultProps) { // System.err.println ("building sysprops with file "+filename+" and node "+node); this.defaultProps = defaultProps; props = defaultProps == null ? new Properties () : new Properties (defaultProps); @@ -83,6 +83,15 @@ public final class SystemProperties extends Properties { return lastadd; return Math.max (file.lastModified (), lastadd); } + + /** + * Return a checksum that changes when something in the properties changes. + */ + public long getChecksum () { + if (defaultProps == null) + return lastModified (); + return lastModified () + defaultProps.lastModified (); + } /** * Private method to read file if it has been changed since the last time we did