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.
This commit is contained in:
hns 2002-10-29 17:30:14 +00:00
parent f4002ac605
commit d5e6cfe623
2 changed files with 22 additions and 4 deletions

View file

@ -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.
*/

View file

@ -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