1 |
tdb |
1.11 |
//---PACKAGE DECLARATION--- |
2 |
ajm |
1.13 |
package uk.ac.ukc.iscream.core; |
3 |
tdb |
1.11 |
|
4 |
|
|
//---IMPORTS--- |
5 |
ajm |
1.14 |
import uk.ac.ukc.iscream.util.*; |
6 |
|
|
import java.util.Properties; |
7 |
|
|
import java.util.Date; |
8 |
tdb |
1.11 |
import java.text.DateFormat; |
9 |
|
|
|
10 |
|
|
/** |
11 |
|
|
* An implementation of the Configuration IDL |
12 |
|
|
* This class allows i-scream modules to read and even |
13 |
|
|
* set their configuration from a central location. |
14 |
|
|
* |
15 |
|
|
* When classes want their configuration, they contact |
16 |
ajm |
1.12 |
* the ConfigurationManager, which will locate their config, |
17 |
tdb |
1.11 |
* open it and pass it to a Configuration object which is |
18 |
|
|
* then passed back to the calling class. |
19 |
|
|
* |
20 |
|
|
* Essentially this class behaves in a similar fashion |
21 |
|
|
* to the java.util.Properties class. |
22 |
|
|
* |
23 |
ajm |
1.13 |
* @author $Author: ajm4 $ |
24 |
ajm |
1.14 |
* @version $Id: ConfigurationServant.java,v 1.13 2000/11/29 21:27:08 ajm4 Exp $ |
25 |
tdb |
1.11 |
*/ |
26 |
|
|
class ConfigurationServant extends ConfigurationPOA { |
27 |
|
|
|
28 |
|
|
//---FINAL ATTRIBUTES--- |
29 |
|
|
|
30 |
|
|
/** |
31 |
|
|
* The current CVS revision of this class |
32 |
|
|
*/ |
33 |
ajm |
1.14 |
public final String REVISION = "$Revision: 1.13 $"; |
34 |
tdb |
1.11 |
|
35 |
|
|
//---STATIC METHODS--- |
36 |
|
|
|
37 |
|
|
//---CONSTRUCTORS--- |
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* Creates a new ConfigurationServant taking a hook |
41 |
ajm |
1.12 |
* to a Properties object containing the configuration. |
42 |
tdb |
1.11 |
* |
43 |
ajm |
1.12 |
* @param properties a Properties object that contains the full properties for this configuration |
44 |
|
|
* @param fileList the list of config files used to build this configuration |
45 |
|
|
* @param lastModified the most recent last modified value for the file list |
46 |
|
|
* @param logRef a reference to the logger system |
47 |
tdb |
1.11 |
*/ |
48 |
ajm |
1.14 |
ConfigurationServant(Properties properties, String fileList, long lastModified) { |
49 |
ajm |
1.12 |
// assign local variables |
50 |
tdb |
1.11 |
_properties = properties; |
51 |
|
|
_lastModified = lastModified; |
52 |
|
|
_fileList = fileList; |
53 |
ajm |
1.14 |
_logger.write(toString(), Logger.SYSINIT, "created"); |
54 |
tdb |
1.11 |
String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(getLastModified())); |
55 |
ajm |
1.14 |
_logger.write(toString(), Logger.SYSMSG, "last modified - " + date); |
56 |
|
|
_logger.write(toString(), Logger.DEBUG, "file list - " + _fileList); |
57 |
tdb |
1.11 |
} |
58 |
|
|
|
59 |
|
|
//---PUBLIC METHODS--- |
60 |
|
|
|
61 |
|
|
/** |
62 |
|
|
* A wrapper for java.util.Properties.getProperty |
63 |
|
|
* When given a key it returns the value of that key |
64 |
|
|
* ie, key = value |
65 |
|
|
* |
66 |
|
|
* @param key the key the value of which is wanted |
67 |
|
|
*/ |
68 |
|
|
public String getProperty(String key) { |
69 |
|
|
return _properties.getProperty(key); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
/** |
73 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
74 |
|
|
* method to provide clean logging (every class should have this). |
75 |
|
|
* |
76 |
ajm |
1.14 |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
77 |
|
|
* to format the toString() |
78 |
|
|
* |
79 |
tdb |
1.11 |
* @return the name of this class and its CVS revision |
80 |
|
|
*/ |
81 |
|
|
public String toString() { |
82 |
ajm |
1.14 |
return FormatName.getName( |
83 |
|
|
_name, |
84 |
|
|
getClass().getName(), |
85 |
|
|
REVISION); |
86 |
tdb |
1.11 |
} |
87 |
|
|
|
88 |
|
|
//---PRIVATE METHODS--- |
89 |
|
|
|
90 |
ajm |
1.12 |
/** |
91 |
|
|
* Overridden for debugging purposes |
92 |
|
|
* to see when an instance of this class |
93 |
|
|
* is destroyed |
94 |
|
|
*/ |
95 |
tdb |
1.11 |
protected void finalize() throws Throwable { |
96 |
ajm |
1.14 |
_logger.write(this.toString(), Logger.DEBUG, "finalized"); |
97 |
tdb |
1.11 |
} |
98 |
|
|
|
99 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
100 |
|
|
|
101 |
|
|
/** |
102 |
|
|
* Returns the date stamp of the configuration file |
103 |
|
|
* this object is using. |
104 |
|
|
* |
105 |
|
|
* @return the last modified time for the file |
106 |
|
|
*/ |
107 |
|
|
public long getLastModified() { |
108 |
|
|
return _lastModified; |
109 |
|
|
} |
110 |
|
|
|
111 |
ajm |
1.12 |
/** |
112 |
|
|
* Returns the list of files used to build the Properties |
113 |
|
|
* this object is using. |
114 |
|
|
* |
115 |
|
|
* @return the list of files |
116 |
|
|
*/ |
117 |
tdb |
1.11 |
public String getFileList() { |
118 |
|
|
return _fileList; |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
//---ATTRIBUTES--- |
122 |
|
|
|
123 |
|
|
/** |
124 |
|
|
* The properties object that this class provides a CORBA interface to |
125 |
|
|
*/ |
126 |
|
|
private Properties _properties = new Properties(); |
127 |
|
|
|
128 |
|
|
/** |
129 |
ajm |
1.14 |
* This holds a reference to the |
130 |
|
|
* system logger that is being used. |
131 |
tdb |
1.11 |
*/ |
132 |
ajm |
1.14 |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
133 |
|
|
|
134 |
|
|
/** |
135 |
|
|
* This is the friendly identifier of the |
136 |
|
|
* component this class is running in. |
137 |
|
|
* eg, a Filter may be called "filter1", |
138 |
|
|
* If this class does not have an owning |
139 |
|
|
* component, a name from the configuration |
140 |
|
|
* can be placed here. This name could also |
141 |
|
|
* be changed to null for utility classes. |
142 |
|
|
*/ |
143 |
|
|
private String _name = Core.NAME; |
144 |
tdb |
1.11 |
|
145 |
|
|
/** |
146 |
|
|
* The date stamp of the configuration file |
147 |
|
|
* this object is using |
148 |
|
|
*/ |
149 |
|
|
private long _lastModified; |
150 |
ajm |
1.12 |
|
151 |
|
|
/** |
152 |
|
|
* The list of files that were used to build this configuration |
153 |
|
|
*/ |
154 |
tdb |
1.11 |
private String _fileList; |
155 |
|
|
|
156 |
|
|
//---STATIC ATTRIBUTES--- |
157 |
|
|
|
158 |
|
|
} |