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.1 by ajm, Wed Nov 8 21:24:33 2000 UTC vs.
Revision 1.21 by tdb, Sat May 18 18:16:01 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   //---PACKAGE DECLARATION---
21 + package uk.org.iscream.cms.server.core;
22  
23   //---IMPORTS---
24 < import core.*;
25 < import java.util.*;
26 < import java.io.*;
24 > import uk.org.iscream.cms.server.util.*;
25 > import uk.org.iscream.cms.server.componentmanager.*;
26 > import java.util.Properties;
27 > import java.util.Date;
28 > import java.text.DateFormat;
29  
30   /**
31   * An implementation of the Configuration IDL
# Line 11 | Line 33 | import java.io.*;
33   * set their configuration from a central location.
34   *
35   * When classes want their configuration, they contact
36 < * the Configurator, which will locate their config,
36 > * the ConfigurationManager, which will locate their config,
37   * open it and pass it to a Configuration object which is
38   * then passed back to the calling class.
39   *
# Line 36 | Line 58 | class ConfigurationServant extends ConfigurationPOA {
58  
59      /**
60       * Creates a new ConfigurationServant taking a hook
61 <     * to a file containing the configuration.
61 >     * to a Properties object containing the configuration.
62       *
63 <     * @param propertiesStream an InputStream connected to the configuration
63 >     * @param properties a Properties object that contains the full properties for this configuration
64 >     * @param fileList the list of config files used to build this configuration
65 >     * @param lastModified the most recent last modified value for the file list
66 >     * @param logRef a reference to the logger system
67       */
68 <    ConfigurationServant(File configurationFile) {
69 <        System.out.println(this.toString() + " - created.");
70 <        try {
71 <            InputStream configurationStream = new FileInputStream(configurationFile);
72 <            properties.load(configurationStream);
73 <        } catch (Exception e) {
74 <            // ****************************************
75 <            // either IOException from the .load() or
76 <            // a SecurityException or FileNotFoundException from
52 <            // the inputStream, not sure what to do yet!!!
53 <        }
68 >    ConfigurationServant(Properties properties, String fileList, long lastModified) {
69 >        // assign local variables
70 >        _properties = properties;
71 >        _lastModified = lastModified;
72 >        _fileList = fileList;
73 >        _logger.write(toString(), Logger.SYSINIT, "created");
74 >        String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(getLastModified()));
75 >        _logger.write(toString(), Logger.SYSMSG, "last modified - " + date);
76 >        _logger.write(toString(), Logger.DEBUG, "file list - " + _fileList);
77      }
78  
79   //---PUBLIC METHODS---
# Line 63 | Line 86 | class ConfigurationServant extends ConfigurationPOA {
86       * @param key the key the value of which is wanted
87       */
88      public String getProperty(String key) {
89 <        return properties.getProperty(key);
89 >        return _properties.getProperty(key);
90      }
91      
92      /**
93 <     * Overrides the {@link #java.lang.Object.toString() Object.toString()}
93 >     * Overrides the {@link java.lang.Object#toString() Object.toString()}
94       * method to provide clean logging (every class should have this).
95       *
96 +     * This uses the uk.org.iscream.cms.server.util.FormatName class
97 +     * to format the toString()
98 +     *
99       * @return the name of this class and its CVS revision
100       */
101      public String toString() {
102 <        return this.getClass().getName() + ":" + REVISION;
102 >        return FormatName.getName(
103 >            _name,
104 >            getClass().getName(),
105 >            REVISION);
106      }
107 +    
108 +    /**
109 +     * Unhooks this Configuration object from the ORB
110 +     */
111 +    public void disconnect() {
112 +        try {
113 +            byte[] oid = _refman.getRootPOA().servant_to_id(this);
114 +            _refman.getRootPOA().deactivate_object(oid);
115 +        } catch(Exception e) {
116 +            _logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e);
117 +        }
118 +    }
119 +        
120  
121   //---PRIVATE METHODS---
122  
123 +    /**
124 +     * Overridden for debugging purposes
125 +     * to see when an instance of this class
126 +     * is destroyed
127 +     */
128 +    protected void finalize() throws Throwable {
129 +        _logger.write(this.toString(), Logger.DEBUG, "finalized");
130 +    }
131 +
132   //---ACCESSOR/MUTATOR METHODS---
133  
134 +    /**
135 +     * Returns the date stamp of the configuration file
136 +     * this object is using.
137 +     *
138 +     * @return the last modified time for the file
139 +     */
140 +    public long getLastModified() {
141 +        return _lastModified;
142 +    }
143 +
144 +    /**
145 +     * Returns the list of files used to build the Properties
146 +     * this object is using.
147 +     *
148 +     * @return the list of files
149 +     */
150 +    public String getFileList() {
151 +        return _fileList;
152 +    }
153 +
154   //---ATTRIBUTES---
155  
156      /**
157       * The properties object that this class provides a CORBA interface to
158       */
159 <    private Properties properties = new Properties();
159 >    private Properties _properties = new Properties();
160  
161 +    /**
162 +     * This holds a reference to the
163 +     * system logger that is being used.
164 +     */
165 +    private Logger _logger = ReferenceManager.getInstance().getLogger();
166 +
167 +    /**
168 +     * A reference to the reference manager in use
169 +     */
170 +    private ReferenceManager _refman = ReferenceManager.getInstance();
171 +    
172 +    /**
173 +     * This is the friendly identifier of the
174 +     * component this class is running in.
175 +     * eg, a Filter may be called "filter1",
176 +     * If this class does not have an owning
177 +     * component,  a name from the configuration
178 +     * can be placed here.  This name could also
179 +     * be changed to null for utility classes.
180 +     */
181 +    private String _name = Core.NAME;
182 +
183 +    /**
184 +     * The date stamp of the configuration file
185 +     * this object is using
186 +     */
187 +    private long _lastModified;
188 +    
189 +    /**
190 +     * The list of files that were used to build this configuration
191 +     */
192 +    private String _fileList;
193 +    
194   //---STATIC ATTRIBUTES---
195  
196 < }
196 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines