1 |
|
//---PACKAGE DECLARATION--- |
2 |
|
|
3 |
|
//---IMPORTS--- |
4 |
< |
import core.*; |
4 |
> |
import uk.ac.ukc.iscream.core.*; |
5 |
|
import java.util.*; |
6 |
|
import java.io.*; |
7 |
|
|
40 |
|
* |
41 |
|
* @param propertiesStream an InputStream connected to the configuration |
42 |
|
*/ |
43 |
< |
ConfigurationServant(File configurationFile) { |
44 |
< |
System.out.println(this.toString() + " - created."); |
43 |
> |
ConfigurationServant(File configurationFile, Logger logRef) { |
44 |
> |
_lastModified = configurationFile.lastModified(); |
45 |
> |
|
46 |
> |
_logRef = logRef; |
47 |
> |
_logRef.write(this.toString(), "created - last modified:" + getLastModified()); |
48 |
> |
|
49 |
|
try { |
50 |
|
InputStream configurationStream = new FileInputStream(configurationFile); |
51 |
< |
properties.load(configurationStream); |
51 |
> |
_properties.load(configurationStream); |
52 |
|
} catch (Exception e) { |
53 |
|
// **************************************** |
54 |
|
// either IOException from the .load() or |
67 |
|
* @param key the key the value of which is wanted |
68 |
|
*/ |
69 |
|
public String getProperty(String key) { |
70 |
< |
return properties.getProperty(key); |
70 |
> |
return _properties.getProperty(key); |
71 |
|
} |
72 |
|
|
73 |
|
/** |
74 |
< |
* Overrides the {@link #java.lang.Object.toString() Object.toString()} |
74 |
> |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
75 |
|
* method to provide clean logging (every class should have this). |
76 |
|
* |
77 |
|
* @return the name of this class and its CVS revision |
78 |
|
*/ |
79 |
|
public String toString() { |
80 |
< |
return this.getClass().getName() + ":" + REVISION; |
80 |
> |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
81 |
|
} |
82 |
|
|
83 |
|
//---PRIVATE METHODS--- |
84 |
|
|
85 |
|
//---ACCESSOR/MUTATOR METHODS--- |
86 |
|
|
87 |
+ |
/** |
88 |
+ |
* Returns the date stamp of the configuration file |
89 |
+ |
* this object is using. |
90 |
+ |
* |
91 |
+ |
* @return the last modified time for the file |
92 |
+ |
*/ |
93 |
+ |
public long getLastModified() { |
94 |
+ |
return _lastModified; |
95 |
+ |
} |
96 |
+ |
|
97 |
|
//---ATTRIBUTES--- |
98 |
|
|
99 |
|
/** |
100 |
|
* The properties object that this class provides a CORBA interface to |
101 |
|
*/ |
102 |
< |
private Properties properties = new Properties(); |
102 |
> |
private Properties _properties = new Properties(); |
103 |
|
|
104 |
+ |
/** |
105 |
+ |
* Reference to a Logger |
106 |
+ |
*/ |
107 |
+ |
private Logger _logRef; |
108 |
+ |
|
109 |
+ |
/** |
110 |
+ |
* The date stamp of the configuration file |
111 |
+ |
* this object is using |
112 |
+ |
*/ |
113 |
+ |
private long _lastModified; |
114 |
+ |
|
115 |
|
//---STATIC ATTRIBUTES--- |
116 |
|
|
117 |
< |
} |
117 |
> |
} |