12 |
|
* set their configuration from a central location. |
13 |
|
* |
14 |
|
* When classes want their configuration, they contact |
15 |
< |
* the Configurator, which will locate their config, |
15 |
> |
* the ConfigurationManager, which will locate their config, |
16 |
|
* open it and pass it to a Configuration object which is |
17 |
|
* then passed back to the calling class. |
18 |
|
* |
37 |
|
|
38 |
|
/** |
39 |
|
* Creates a new ConfigurationServant taking a hook |
40 |
< |
* to a file containing the configuration. |
40 |
> |
* to a Properties object containing the configuration. |
41 |
|
* |
42 |
< |
* @param propertiesStream an InputStream connected to the configuration |
42 |
> |
* @param properties a Properties object that contains the full properties for this configuration |
43 |
> |
* @param fileList the list of config files used to build this configuration |
44 |
> |
* @param lastModified the most recent last modified value for the file list |
45 |
> |
* @param logRef a reference to the logger system |
46 |
|
*/ |
47 |
< |
ConfigurationServant(File configurationFile, Logger logRef) { |
48 |
< |
_lastModified = configurationFile.lastModified(); |
47 |
> |
ConfigurationServant(Properties properties, String fileList, long lastModified, Logger logRef) { |
48 |
> |
// assign local variables |
49 |
> |
_properties = properties; |
50 |
> |
_lastModified = lastModified; |
51 |
> |
_fileList = fileList; |
52 |
|
_logRef = logRef; |
53 |
< |
|
53 |
> |
_logRef.write(this.toString(), Logger.SYSINIT, "created"); |
54 |
|
String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(getLastModified())); |
55 |
< |
_logRef.write(this.toString(), Logger.SYSMSG, "created: " + configurationFile.getName() + "(" + date + ")" ); |
56 |
< |
|
51 |
< |
try { |
52 |
< |
InputStream configurationStream = new FileInputStream(configurationFile); |
53 |
< |
_properties.load(configurationStream); |
54 |
< |
} catch (Exception e) { |
55 |
< |
// **************************************** |
56 |
< |
// either IOException from the .load() or |
57 |
< |
// a SecurityException or FileNotFoundException from |
58 |
< |
// the inputStream, not sure what to do yet!!! |
59 |
< |
} |
55 |
> |
_logRef.write(this.toString(), Logger.SYSMSG, "last modified - " + date); |
56 |
> |
_logRef.write(this.toString(), Logger.DEBUG, "file list - " + _fileList); |
57 |
|
} |
58 |
|
|
59 |
|
//---PUBLIC METHODS--- |
81 |
|
|
82 |
|
//---PRIVATE METHODS--- |
83 |
|
|
84 |
+ |
/** |
85 |
+ |
* Overridden for debugging purposes |
86 |
+ |
* to see when an instance of this class |
87 |
+ |
* is destroyed |
88 |
+ |
*/ |
89 |
+ |
protected void finalize() throws Throwable { |
90 |
+ |
_logRef.write(this.toString(), Logger.DEBUG, "finalized (ick, us english!)"); |
91 |
+ |
} |
92 |
+ |
|
93 |
|
//---ACCESSOR/MUTATOR METHODS--- |
94 |
|
|
95 |
|
/** |
102 |
|
return _lastModified; |
103 |
|
} |
104 |
|
|
105 |
+ |
/** |
106 |
+ |
* Returns the list of files used to build the Properties |
107 |
+ |
* this object is using. |
108 |
+ |
* |
109 |
+ |
* @return the list of files |
110 |
+ |
*/ |
111 |
+ |
public String getFileList() { |
112 |
+ |
return _fileList; |
113 |
+ |
} |
114 |
+ |
|
115 |
|
//---ATTRIBUTES--- |
116 |
|
|
117 |
|
/** |
129 |
|
* this object is using |
130 |
|
*/ |
131 |
|
private long _lastModified; |
132 |
+ |
|
133 |
+ |
|
134 |
+ |
/** |
135 |
+ |
* The list of files that were used to build this configuration |
136 |
+ |
*/ |
137 |
+ |
private String _fileList; |
138 |
|
|
139 |
|
//---STATIC ATTRIBUTES--- |
140 |
|
|