1 |
//---PACKAGE DECLARATION--- |
2 |
|
3 |
//---IMPORTS--- |
4 |
import core.*; |
5 |
import java.util.*; |
6 |
import java.io.*; |
7 |
|
8 |
/** |
9 |
* An implementation of the Configuration IDL |
10 |
* This class allows i-scream modules to read and even |
11 |
* set their configuration from a central location. |
12 |
* |
13 |
* When classes want their configuration, they contact |
14 |
* the Configurator, which will locate their config, |
15 |
* open it and pass it to a Configuration object which is |
16 |
* then passed back to the calling class. |
17 |
* |
18 |
* Essentially this class behaves in a similar fashion |
19 |
* to the java.util.Properties class. |
20 |
* |
21 |
* @author $Author: ajm4 $ |
22 |
* @version $Id: TemplateClass.java,v 1.2 2000/11/08 18:18:07 ajm4 Exp $ |
23 |
*/ |
24 |
class ConfigurationServant extends ConfigurationPOA { |
25 |
|
26 |
//---FINAL ATTRIBUTES--- |
27 |
|
28 |
/** |
29 |
* The current CVS revision of this class |
30 |
*/ |
31 |
public final String REVISION = "$Revision: 1.2 $"; |
32 |
|
33 |
//---STATIC METHODS--- |
34 |
|
35 |
//---CONSTRUCTORS--- |
36 |
|
37 |
/** |
38 |
* Creates a new ConfigurationServant taking a hook |
39 |
* to a file containing the configuration. |
40 |
* |
41 |
* @param propertiesStream an InputStream connected to the configuration |
42 |
*/ |
43 |
ConfigurationServant(File configurationFile) { |
44 |
System.out.println(this.toString() + " - created."); |
45 |
try { |
46 |
InputStream configurationStream = new FileInputStream(configurationFile); |
47 |
properties.load(configurationStream); |
48 |
} catch (Exception e) { |
49 |
// **************************************** |
50 |
// either IOException from the .load() or |
51 |
// a SecurityException or FileNotFoundException from |
52 |
// the inputStream, not sure what to do yet!!! |
53 |
} |
54 |
} |
55 |
|
56 |
//---PUBLIC METHODS--- |
57 |
|
58 |
/** |
59 |
* A wrapper for java.util.Properties.getProperty |
60 |
* When given a key it returns the value of that key |
61 |
* ie, key = value |
62 |
* |
63 |
* @param key the key the value of which is wanted |
64 |
*/ |
65 |
public String getProperty(String key) { |
66 |
return properties.getProperty(key); |
67 |
} |
68 |
|
69 |
/** |
70 |
* Overrides the {@link #java.lang.Object.toString() Object.toString()} |
71 |
* method to provide clean logging (every class should have this). |
72 |
* |
73 |
* @return the name of this class and its CVS revision |
74 |
*/ |
75 |
public String toString() { |
76 |
return this.getClass().getName() + ":" + REVISION; |
77 |
} |
78 |
|
79 |
//---PRIVATE METHODS--- |
80 |
|
81 |
//---ACCESSOR/MUTATOR METHODS--- |
82 |
|
83 |
//---ATTRIBUTES--- |
84 |
|
85 |
/** |
86 |
* The properties object that this class provides a CORBA interface to |
87 |
*/ |
88 |
private Properties properties = new Properties(); |
89 |
|
90 |
//---STATIC ATTRIBUTES--- |
91 |
|
92 |
} |