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.13
Committed: Wed Nov 29 21:27:08 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Branch point for: SERVER_PACKAGEBUILD
Changes since 1.12: +4 -4 lines
Log Message:
Update for package move.

File Contents

# User Rev Content
1 tdb 1.11 //---PACKAGE DECLARATION---
2 ajm 1.13 package uk.ac.ukc.iscream.core;
3 tdb 1.11
4     //---IMPORTS---
5     import java.util.*;
6     import java.io.*;
7     import java.text.DateFormat;
8    
9     /**
10     * An implementation of the Configuration IDL
11     * This class allows i-scream modules to read and even
12     * set their configuration from a central location.
13     *
14     * When classes want their configuration, they contact
15 ajm 1.12 * the ConfigurationManager, which will locate their config,
16 tdb 1.11 * open it and pass it to a Configuration object which is
17     * then passed back to the calling class.
18     *
19     * Essentially this class behaves in a similar fashion
20     * to the java.util.Properties class.
21     *
22 ajm 1.13 * @author $Author: ajm4 $
23     * @version $Id: ConfigurationServant.java,v 1.12 2000/11/21 21:58:52 ajm4 Exp $
24 tdb 1.11 */
25     class ConfigurationServant extends ConfigurationPOA {
26    
27     //---FINAL ATTRIBUTES---
28    
29     /**
30     * The current CVS revision of this class
31     */
32 ajm 1.13 public final String REVISION = "$Revision: 1.12 $";
33 tdb 1.11
34     //---STATIC METHODS---
35    
36     //---CONSTRUCTORS---
37    
38     /**
39     * Creates a new ConfigurationServant taking a hook
40 ajm 1.12 * to a Properties object containing the configuration.
41 tdb 1.11 *
42 ajm 1.12 * @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 tdb 1.11 */
47     ConfigurationServant(Properties properties, String fileList, long lastModified, Logger logRef) {
48 ajm 1.12 // assign local variables
49 tdb 1.11 _properties = properties;
50     _lastModified = lastModified;
51     _fileList = fileList;
52     _logRef = logRef;
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, "last modified - " + date);
56     _logRef.write(this.toString(), Logger.DEBUG, "file list - " + _fileList);
57     }
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     * @return the name of this class and its CVS revision
77     */
78     public String toString() {
79     return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
80     }
81    
82     //---PRIVATE METHODS---
83    
84 ajm 1.12 /**
85     * Overridden for debugging purposes
86     * to see when an instance of this class
87     * is destroyed
88     */
89 tdb 1.11 protected void finalize() throws Throwable {
90     _logRef.write(this.toString(), Logger.DEBUG, "finalized (ick, us english!)");
91     }
92    
93     //---ACCESSOR/MUTATOR METHODS---
94    
95     /**
96     * Returns the date stamp of the configuration file
97     * this object is using.
98     *
99     * @return the last modified time for the file
100     */
101     public long getLastModified() {
102     return _lastModified;
103     }
104    
105 ajm 1.12 /**
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 tdb 1.11 public String getFileList() {
112     return _fileList;
113     }
114    
115     //---ATTRIBUTES---
116    
117     /**
118     * The properties object that this class provides a CORBA interface to
119     */
120     private Properties _properties = new Properties();
121    
122     /**
123     * Reference to a Logger
124     */
125     private Logger _logRef;
126    
127     /**
128     * The date stamp of the configuration file
129     * this object is using
130     */
131     private long _lastModified;
132    
133 ajm 1.12
134     /**
135     * The list of files that were used to build this configuration
136     */
137 tdb 1.11 private String _fileList;
138    
139     //---STATIC ATTRIBUTES---
140    
141     }