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.14
Committed: Tue Dec 12 18:26:52 2000 UTC (23 years, 5 months ago) by ajm
Branch: MAIN
Changes since 1.13: +31 -14 lines
Log Message:
tidied up the code

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.core;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import java.util.Properties;
7 import java.util.Date;
8 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 * the ConfigurationManager, which will locate their config,
17 * 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 * @author $Author: ajm4 $
24 * @version $Id: ConfigurationServant.java,v 1.13 2000/11/29 21:27:08 ajm4 Exp $
25 */
26 class ConfigurationServant extends ConfigurationPOA {
27
28 //---FINAL ATTRIBUTES---
29
30 /**
31 * The current CVS revision of this class
32 */
33 public final String REVISION = "$Revision: 1.13 $";
34
35 //---STATIC METHODS---
36
37 //---CONSTRUCTORS---
38
39 /**
40 * Creates a new ConfigurationServant taking a hook
41 * to a Properties object containing the configuration.
42 *
43 * @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 */
48 ConfigurationServant(Properties properties, String fileList, long lastModified) {
49 // assign local variables
50 _properties = properties;
51 _lastModified = lastModified;
52 _fileList = fileList;
53 _logger.write(toString(), Logger.SYSINIT, "created");
54 String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(getLastModified()));
55 _logger.write(toString(), Logger.SYSMSG, "last modified - " + date);
56 _logger.write(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 * This uses the uk.ac.ukc.iscream.util.FormatName class
77 * to format the toString()
78 *
79 * @return the name of this class and its CVS revision
80 */
81 public String toString() {
82 return FormatName.getName(
83 _name,
84 getClass().getName(),
85 REVISION);
86 }
87
88 //---PRIVATE METHODS---
89
90 /**
91 * Overridden for debugging purposes
92 * to see when an instance of this class
93 * is destroyed
94 */
95 protected void finalize() throws Throwable {
96 _logger.write(this.toString(), Logger.DEBUG, "finalized");
97 }
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 /**
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 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 * This holds a reference to the
130 * system logger that is being used.
131 */
132 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
145 /**
146 * The date stamp of the configuration file
147 * this object is using
148 */
149 private long _lastModified;
150
151 /**
152 * The list of files that were used to build this configuration
153 */
154 private String _fileList;
155
156 //---STATIC ATTRIBUTES---
157
158 }