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
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/core/ConfigurationServant.java (file contents):
Revision 1.4 by tdb, Mon Nov 13 16:36:03 2000 UTC vs.
Revision 1.14 by ajm, Tue Dec 12 18:26:52 2000 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.core;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.core.*;
6 < import java.util.*;
7 < import java.io.*;
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
# Line 11 | Line 13 | import java.io.*;
13   * set their configuration from a central location.
14   *
15   * When classes want their configuration, they contact
16 < * the Configurator, which will locate their config,
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   *
# Line 36 | Line 38 | class ConfigurationServant extends ConfigurationPOA {
38  
39      /**
40       * Creates a new ConfigurationServant taking a hook
41 <     * to a file containing the configuration.
41 >     * to a Properties object containing the configuration.
42       *
43 <     * @param propertiesStream an InputStream connected to the configuration
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(File configurationFile, Logger logRef) {
49 <        _lastModified = configurationFile.lastModified();
50 <        
51 <        _logRef = logRef;
52 <        _logRef.write(this.toString(), "created - last modified:" + getLastModified());
53 <        
54 <        try {
55 <            InputStream configurationStream = new FileInputStream(configurationFile);
56 <            _properties.load(configurationStream);
52 <        } 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 <        }
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---
# Line 71 | Line 70 | class ConfigurationServant extends ConfigurationPOA {
70      }
71      
72      /**
73 <     * Overrides the {@link #java.lang.Object.toString() Object.toString()}
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 this.getClass().getName() + ":" + REVISION;
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      /**
# Line 94 | Line 108 | class ConfigurationServant extends ConfigurationPOA {
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      /**
# Line 102 | Line 126 | class ConfigurationServant extends ConfigurationPOA {
126      private Properties _properties = new Properties();
127  
128      /**
129 <     * Reference to a Logger
129 >     * This holds a reference to the
130 >     * system logger that is being used.
131       */
132 <    private Logger _logRef;
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines