ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/core/ConfigurationServant.java
Revision: 1.6
Committed: Mon Nov 13 18:21:15 2000 UTC (23 years, 6 months ago) by tdb
Branch: MAIN
Changes since 1.5: +3 -3 lines
Log Message:
Modified the toString of all the classes to bring in line with the standard

Modified CORE to startup nicer (output wise)

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2    
3     //---IMPORTS---
4 tdb 1.4 import uk.ac.ukc.iscream.core.*;
5 ajm 1.1 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 tdb 1.3 * @author $Author: tdb1 $
22 tdb 1.6 * @version $Id: ConfigurationServant.java,v 1.5 2000/11/13 17:07:07 tdb1 Exp $
23 ajm 1.1 */
24     class ConfigurationServant extends ConfigurationPOA {
25    
26     //---FINAL ATTRIBUTES---
27    
28     /**
29     * The current CVS revision of this class
30     */
31 tdb 1.6 public final String REVISION = "$Revision: 1.5 $";
32 ajm 1.1
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 tdb 1.2 ConfigurationServant(File configurationFile, Logger logRef) {
44 tdb 1.3 _lastModified = configurationFile.lastModified();
45    
46 tdb 1.2 _logRef = logRef;
47 tdb 1.3 _logRef.write(this.toString(), "created - last modified:" + getLastModified());
48    
49 ajm 1.1 try {
50     InputStream configurationStream = new FileInputStream(configurationFile);
51 tdb 1.2 _properties.load(configurationStream);
52 ajm 1.1 } catch (Exception e) {
53     // ****************************************
54     // either IOException from the .load() or
55     // a SecurityException or FileNotFoundException from
56     // the inputStream, not sure what to do yet!!!
57     }
58     }
59    
60     //---PUBLIC METHODS---
61    
62     /**
63     * A wrapper for java.util.Properties.getProperty
64     * When given a key it returns the value of that key
65     * ie, key = value
66     *
67     * @param key the key the value of which is wanted
68     */
69     public String getProperty(String key) {
70 tdb 1.2 return _properties.getProperty(key);
71 ajm 1.1 }
72    
73     /**
74 tdb 1.5 * Overrides the {@link java.lang.Object#toString() Object.toString()}
75 ajm 1.1 * 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 tdb 1.6 return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
81 ajm 1.1 }
82    
83     //---PRIVATE METHODS---
84    
85     //---ACCESSOR/MUTATOR METHODS---
86    
87 tdb 1.3 /**
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 ajm 1.1 //---ATTRIBUTES---
98    
99     /**
100     * The properties object that this class provides a CORBA interface to
101     */
102 tdb 1.2 private Properties _properties = new Properties();
103    
104     /**
105     * Reference to a Logger
106     */
107     private Logger _logRef;
108 ajm 1.1
109 tdb 1.3 /**
110     * The date stamp of the configuration file
111     * this object is using
112     */
113     private long _lastModified;
114    
115 ajm 1.1 //---STATIC ATTRIBUTES---
116    
117 tdb 1.2 }